1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-11-08 21:21:06 +00:00

Added GroupExperimentModelView

This commit is contained in:
Mo 2021-06-24 19:39:26 +02:00
parent 61cbfe9ec8
commit 27c8d3d952

View file

@ -333,10 +333,42 @@ class AssistantModelView(SecureModelView):
form_excluded_columns = ["experiment_marks"]
class GroupExperimentModelView(SecureModelView):
column_list = ["group", "part_experiment", "appointments", "experiment_marks"]
def get_query(self):
return (
super()
.get_query()
.filter(
GroupExperiment.group_id.in_(
[
g.id
for g in Group.query.filter(Group.part_id.in_([part.id for part in userActiveSemester().parts]))
]
)
)
)
def get_count_query(self):
return (
self.session.query(func.count("*"))
.select_from(self.model)
.filter(
GroupExperiment.group_id.in_(
[
g.id
for g in Group.query.filter(Group.part_id.in_([part.id for part in userActiveSemester().parts]))
]
)
)
)
admin.add_view(StudentModelView(Student, db.session))
admin.add_view(PartStudentModelView(PartStudent, db.session))
admin.add_view(GroupModelView(Group, db.session))
admin.add_view(SecureModelView(GroupExperiment, db.session))
admin.add_view(GroupExperimentModelView(GroupExperiment, db.session))
admin.add_view(ExperimentModelView(Experiment, db.session))
admin.add_view(PartExperimentModelView(PartExperiment, db.session))
admin.add_view(AssistantModelView(Assistant, db.session))