mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Added GroupModelView
This commit is contained in:
parent
c6d348c4f3
commit
699192201f
2 changed files with 19 additions and 2 deletions
|
@ -187,9 +187,27 @@ class PartStudentModelView(SecureModelView):
|
||||||
form_excluded_columns = ["experiment_marks"]
|
form_excluded_columns = ["experiment_marks"]
|
||||||
|
|
||||||
|
|
||||||
|
class GroupModelView(SecureModelView):
|
||||||
|
partsLabels = getConfig("partsLabels")
|
||||||
|
column_filters = [PartFilter(Group.part_id, "Part", options=list(zip(partsLabels, partsLabels)))]
|
||||||
|
|
||||||
|
def validate_form(self, form):
|
||||||
|
if request.method == "POST":
|
||||||
|
if Group.query.filter(Group.number == form.number.data, Group.part == form.part.data).first():
|
||||||
|
lastTakenGroupNumber = (
|
||||||
|
Group.query.filter(Group.part == form.part.data).order_by(Group.number)[-1].number
|
||||||
|
)
|
||||||
|
flash(
|
||||||
|
f"Group number taken in this part! Last group number taken in this part is {lastTakenGroupNumber}.",
|
||||||
|
"warning",
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
return super().validate_form(form)
|
||||||
|
|
||||||
|
|
||||||
admin.add_view(StudentModelView(Student, db.session))
|
admin.add_view(StudentModelView(Student, db.session))
|
||||||
admin.add_view(PartStudentModelView(PartStudent, db.session))
|
admin.add_view(PartStudentModelView(PartStudent, db.session))
|
||||||
admin.add_view(SecureModelView(Group, db.session))
|
admin.add_view(GroupModelView(Group, db.session))
|
||||||
admin.add_view(SecureModelView(GroupExperiment, db.session))
|
admin.add_view(SecureModelView(GroupExperiment, db.session))
|
||||||
admin.add_view(SecureModelView(Experiment, db.session))
|
admin.add_view(SecureModelView(Experiment, db.session))
|
||||||
admin.add_view(SecureModelView(PartExperiment, db.session))
|
admin.add_view(SecureModelView(PartExperiment, db.session))
|
||||||
|
|
|
@ -99,7 +99,6 @@ def partFromLabelInUserActiveSemester(partLabel):
|
||||||
for part in userActiveSemester().parts:
|
for part in userActiveSemester().parts:
|
||||||
if part.label == partLabel:
|
if part.label == partLabel:
|
||||||
return part
|
return part
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def setActiveSemester(semesterId):
|
def setActiveSemester(semesterId):
|
||||||
|
|
Loading…
Reference in a new issue