switch all to be the default if filter is invalid

This commit is contained in:
Aaron Kimbre
2022-04-03 12:00:14 -05:00
parent 44689aad36
commit e5428dcd4d
4 changed files with 10 additions and 20 deletions

View File

@@ -54,14 +54,12 @@ def get_pets(status="all"):
]
query = None
if status == "all":
query = db.session.query().select_from(PetNames)
elif status == "approved":
if status == "approved":
query = db.session.query().select_from(PetNames).filter(PetNames.approved == 2)
elif status == "unapproved":
query = db.session.query().select_from(PetNames).filter(PetNames.approved == 1)
else:
raise Exception("Not a valid filter")
query = db.session.query().select_from(PetNames)
params = request.args.to_dict()