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

Use query_modifier in adminSpace

This commit is contained in:
Mo 2022-05-21 18:32:34 +02:00
parent 1ba0659f71
commit 303d8b23be

View file

@ -404,8 +404,8 @@ class PartView(SecureAdminModelView):
column_searchable_list = ["program.label", "number"] column_searchable_list = ["program.label", "number"]
def queryFilter(self): def query_modifier(self, query):
return Part.semester == current_user.active_semester return query.where(Part.semester == current_user.active_semester)
def customCreateModel(self, form): def customCreateModel(self, form):
return Part(program=form.program.data, number=form.number.data, semester=current_user.active_semester) return Part(program=form.program.data, number=form.number.data, semester=current_user.active_semester)
@ -560,8 +560,8 @@ class PartStudentView(SecureAdminModelView):
), ),
] ]
def queryFilter(self): def query_modifier(self, query):
return PartStudent.part.has(Part.semester == current_user.active_semester) return query.join(Part).where(Part.semester == current_user.active_semester)
def on_model_change(self, form, model, is_created): def on_model_change(self, form, model, is_created):
PartStudent.check(model.part, model.group) PartStudent.check(model.part, model.group)
@ -627,8 +627,8 @@ class GroupView(SecureAdminModelView):
) )
refreshFiltersCache = True refreshFiltersCache = True
def queryFilter(self): def query_modifier(self, query):
return Group.semester == current_user.active_semester return query.wher(Group.semester == current_user.active_semester)
def customCreateModel(self, form): def customCreateModel(self, form):
return Group.customInit(form.part_students.data) return Group.customInit(form.part_students.data)
@ -788,8 +788,8 @@ class SemesterExperimentView(SecureAdminModelView):
), ),
] ]
def queryFilter(self): def query_modifier(self, query):
return SemesterExperiment.semester == current_user.active_semester return query.where(SemesterExperiment.semester == current_user.active_semester)
def customCreateModel(self, form): def customCreateModel(self, form):
return SemesterExperiment( return SemesterExperiment(
@ -1044,8 +1044,8 @@ class GroupExperimentView(SecureAdminModelView):
), ),
] ]
def queryFilter(self): def query_modifier(self, query):
return GroupExperiment.group.has(Group.semester == current_user.active_semester) return query.join(Group).where(Group.semester == current_user.active_semester)
def customCreateModel(self, form): def customCreateModel(self, form):
return GroupExperiment(semester_experiment=form.semester_experiment.data, group=form.group.data) return GroupExperiment(semester_experiment=form.semester_experiment.data, group=form.group.data)
@ -1164,9 +1164,11 @@ class AppointmentView(SecureAdminModelView):
), ),
] ]
def queryFilter(self): def query_modifier(self, query):
return Appointment.group_experiment.has( return (
GroupExperiment.semester_experiment.has(SemesterExperiment.semester == current_user.active_semester) query.join(GroupExperiment)
.join(SemesterExperiment)
.where(SemesterExperiment.semester == current_user.active_semester)
) )
def customCreateModel(self, form): def customCreateModel(self, form):
@ -1340,9 +1342,11 @@ class ExperimentMarkView(SecureAdminModelView):
""" """
# Deactivated for the experiments history of a student. # Deactivated for the experiments history of a student.
def queryFilter(self): def query_modifier(self, query):
return ExperimentMark.group_experiment.has( return (
GroupExperiment.semester_experiment.has(SemesterExperiment.semester == current_user.active_semester) query.join(GroupExperiment)
.join(SemesterExperiment)
.where(SemesterExperiment.semester == current_user.active_semester)
) )
""" """