From d50ce61abb9a896cb96b93b74db176db1baa4ae4 Mon Sep 17 00:00:00 2001 From: Mo8it Date: Wed, 2 Mar 2022 02:31:31 +0100 Subject: [PATCH] Fix database blocking by unintended generators --- advlabdb/adminModelViews.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/advlabdb/adminModelViews.py b/advlabdb/adminModelViews.py index 0233f1a..c07d721 100644 --- a/advlabdb/adminModelViews.py +++ b/advlabdb/adminModelViews.py @@ -405,9 +405,7 @@ def groupQueryFactory(): def partFilterOptions(): if has_request_context(): parts = Part.query.filter(Part.semester == userActiveSemester()) - return ((part.id, f"{part.program.repr()}{part.number}") for part in parts) - else: - return + return tuple((part.id, f"{part.program.repr()}{part.number}") for part in parts) class PartStudentView(SecureAdminModelView): @@ -497,7 +495,7 @@ class GroupView(SecureAdminModelView): class ProgramFilter(FilterEqual): def get_options(self, view): programs = Program.query - return ((program.id, program.repr()) for program in programs) + return tuple((program.id, program.repr()) for program in programs) def apply(self, query, value, alias=None): return query.filter(self.column.program_id == int(value)) @@ -725,7 +723,7 @@ assistantBlankText = "Auto assign if experiment has only one assistant" def experimentFilterOptions(): activeExperiments = Experiment.query.filter(Experiment.active == True) - return ( + return tuple( ( f"{activeExperiment.number},{activeExperiment.program.id}", f"{activeExperiment.number} {activeExperiment.program.repr()}", @@ -850,7 +848,7 @@ def groupExperimentQueryFactory(): def assistantFilterOptions(): assistants = Assistant.query.filter(Assistant.user.has(User.active == True)) - return ((assistant.id, assistant.repr()) for assistant in assistants) + return tuple((assistant.id, assistant.repr()) for assistant in assistants) class AppointmentView(SecureAdminModelView): @@ -979,7 +977,7 @@ class ExperimentMarkView(SecureAdminModelView): class AdminFilter(FilterEqual): def get_options(self, view): admins = Admin.query.filter(Admin.user.has(User.active == True)) - return ((admin.id, admin.repr()) for admin in admins) + return tuple((admin.id, admin.repr()) for admin in admins) def apply(self, query, value, alias=None): return query.filter(self.column.admin_id == int(value)) @@ -1009,7 +1007,7 @@ class ExperimentMarkView(SecureAdminModelView): class ProgramFilter(FilterEqual): def get_options(self, view): programs = Program.query - return ((program.id, program.repr()) for program in programs) + return tuple((program.id, program.repr()) for program in programs) def apply(self, query, value, alias=None): return query.filter(self.column.part_student.has(PartStudent.part.has(Part.program_id == int(value)))) @@ -1024,7 +1022,7 @@ class ExperimentMarkView(SecureAdminModelView): class SemesterFilter(FilterEqual): def get_options(self, view): semesters = Semester.query.order_by(Semester.id.desc()) - return ((semester.id, semester.repr()) for semester in semesters) + return tuple((semester.id, semester.repr()) for semester in semesters) def apply(self, query, value, alias=None): return query.filter(