diff --git a/advlabdb/assistantModelViews.py b/advlabdb/assistantModelViews.py index 627ae77..325ecfa 100644 --- a/advlabdb/assistantModelViews.py +++ b/advlabdb/assistantModelViews.py @@ -112,14 +112,13 @@ class AssistantExperimentMarkView(SecureAssistantModelView): column_default_sort = [("oral_mark", False), ("protocol_mark", False)] - def queryFilter(self): - return ExperimentMark.group_experiment.has( - GroupExperiment.semester_experiment.has( - and_( - SemesterExperiment.semester == current_user.active_semester, - SemesterExperiment.assistants.any(Assistant.user == current_user), - ) - ) + def query_modifier(self, query): + return ( + query.join(GroupExperiment) + .join(SemesterExperiment) + .where(SemesterExperiment.semester == current_user.active_semester) + .join(SemesterExperiment.assistants) + .where(Assistant.user == current_user) ) def update_model(self, form, model): @@ -180,8 +179,8 @@ class AssistantUserView(SecureAssistantModelView): "assistant.semester_experiments": "Semester Experiments", } - def queryFilter(self): - return User.id == current_user.id + def query_modifier(self, query): + return query.where(User.id == current_user.id) def on_model_change(self, form, model, is_created): if form.generate_new_password.data: