diff --git a/app/bug_reports.py b/app/bug_reports.py index 29eda20..e60ae97 100644 --- a/app/bug_reports.py +++ b/app/bug_reports.py @@ -69,27 +69,23 @@ def get(status): query = None if current_user.gm_level > 0: - if status == "all": - query = db.session.query().select_from(BugReport) - elif status == "resolved": + if status == "resolved": query = db.session.query().select_from(BugReport).filter(BugReport.resolved_time != None) elif status == "unresolved": query = db.session.query().select_from(BugReport).filter(BugReport.resolved_time == None) else: - raise Exception("Not a valid filter") + query = db.session.query().select_from(BugReport) else: chars = CharacterInfo.query.with_entities(CharacterInfo.id).filter(CharacterInfo.account_id == current_user.id).all() char_ids = [] for char in chars: char_ids.append(char[0]) - if status == "all": - query = db.session.query().select_from(BugReport).filter(BugReport.reporter_id.in_(char_ids)) - elif status == "resolved": + if status == "resolved": query = db.session.query().select_from(BugReport).filter(BugReport.reporter_id.in_(char_ids)).filter(BugReport.resolved_time != None) elif status == "unresolved": query = db.session.query().select_from(BugReport).filter(BugReport.reporter_id.in_(char_ids)).filter(BugReport.resolved_time == None) else: - raise Exception("Not a valid filter") + query = db.session.query().select_from(BugReport).filter(BugReport.reporter_id.in_(char_ids)) params = request.args.to_dict() diff --git a/app/characters.py b/app/characters.py index fe67357..f85c617 100644 --- a/app/characters.py +++ b/app/characters.py @@ -225,14 +225,12 @@ def get(status): ] query = None - if status == "all": - query = db.session.query().select_from(CharacterInfo).join(Account) - elif status == "approved": + if status == "approved": query = db.session.query().select_from(CharacterInfo).join(Account).filter((CharacterInfo.pending_name == "") & (CharacterInfo.needs_rename == False)) elif status == "unapproved": query = db.session.query().select_from(CharacterInfo).join(Account).filter((CharacterInfo.pending_name != "") | (CharacterInfo.needs_rename == True)) else: - raise Exception("Not a valid filter") + query = db.session.query().select_from(CharacterInfo).join(Account) params = request.args.to_dict() diff --git a/app/moderation.py b/app/moderation.py index 8e69094..642ecfc 100644 --- a/app/moderation.py +++ b/app/moderation.py @@ -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() diff --git a/app/properties.py b/app/properties.py index 3209983..e9963a7 100644 --- a/app/properties.py +++ b/app/properties.py @@ -194,9 +194,7 @@ def get(status="all"): ] query = None - if status == "all": - query = db.session.query().select_from(Property).join(CharacterInfo, CharacterInfo.id == Property.owner_id).join(Account) - elif status == "approved": + if status == "approved": query = db.session.query().select_from(Property).join( CharacterInfo, CharacterInfo.id == Property.owner_id ).join(Account).filter(Property.mod_approved == True).filter(Property.privacy_option == 2) @@ -205,7 +203,7 @@ def get(status="all"): CharacterInfo, CharacterInfo.id == Property.owner_id ).join(Account).filter(Property.mod_approved == False).filter(Property.privacy_option == 2) else: - raise Exception("Not a valid filter") + query = db.session.query().select_from(Property).join(CharacterInfo, CharacterInfo.id == Property.owner_id).join(Account) params = request.args.to_dict()