mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Fix some problems with app context
This commit is contained in:
parent
b9d5aad18d
commit
3fd804d175
1 changed files with 20 additions and 3 deletions
|
@ -76,6 +76,9 @@ def semesterExperimentQueryFactory():
|
|||
|
||||
class SemesterRowFilter(FilterEqual):
|
||||
def get_options(self, view):
|
||||
if not has_request_context():
|
||||
return tuple()
|
||||
|
||||
semesters = Semester.query.order_by(Semester.id.desc())
|
||||
return tuple((semester.id, semester.repr()) for semester in semesters)
|
||||
|
||||
|
@ -470,7 +473,9 @@ def groupQueryFactory():
|
|||
|
||||
class PartRowFilter(FilterEqual):
|
||||
def get_options(self, view):
|
||||
if has_request_context():
|
||||
if not has_request_context():
|
||||
return tuple()
|
||||
|
||||
parts = Part.query.filter(Part.semester == userActiveSemester())
|
||||
return tuple((part.id, f"{part.program.repr()}{part.number}") for part in parts)
|
||||
|
||||
|
@ -570,6 +575,9 @@ def partStudentQueryFactory():
|
|||
|
||||
class ProgramRowFilter(FilterEqual):
|
||||
def get_options(self, view):
|
||||
if not has_request_context():
|
||||
return tuple()
|
||||
|
||||
programs = Program.query
|
||||
return tuple((program.id, program.repr()) for program in programs)
|
||||
|
||||
|
@ -904,6 +912,9 @@ assistantBlankText = "Auto assign if experiment has only one assistant"
|
|||
|
||||
class ExperimentRowFilter(FilterEqual):
|
||||
def get_options(self, view):
|
||||
if not has_request_context():
|
||||
return tuple()
|
||||
|
||||
activeExperiments = Experiment.query.filter(Experiment.active == True)
|
||||
return tuple(
|
||||
(
|
||||
|
@ -1052,6 +1063,9 @@ def groupExperimentQueryFactory():
|
|||
|
||||
class AssistantRowFilter(FilterEqual):
|
||||
def get_options(self, view):
|
||||
if not has_request_context():
|
||||
return tuple()
|
||||
|
||||
activeAssistants = assistantQueryFactory()
|
||||
return tuple((assistant.id, assistant.repr()) for assistant in activeAssistants)
|
||||
|
||||
|
@ -1187,6 +1201,9 @@ class ExperimentMarkView(SecureAdminModelView):
|
|||
|
||||
class AdminFilter(FilterEqual):
|
||||
def get_options(self, view):
|
||||
if not has_request_context():
|
||||
return tuple()
|
||||
|
||||
admins = Admin.query.filter(Admin.user.has(User.active == True))
|
||||
return tuple((admin.id, admin.repr()) for admin in admins)
|
||||
|
||||
|
|
Loading…
Reference in a new issue