1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-20 23:41:20 +00:00

Fix database blocking by unintended generators

This commit is contained in:
Mo 2022-03-02 02:31:31 +01:00
parent 7b09842932
commit d50ce61abb

View file

@ -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(