mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Can't edit final_part_mark and fixed setting edited_by_admin
This commit is contained in:
parent
bd393796f5
commit
05d17d151d
1 changed files with 17 additions and 21 deletions
|
@ -312,9 +312,6 @@ def groupQueryFactory():
|
|||
return Group.query.filter(Group.semester == userActiveSemester())
|
||||
|
||||
|
||||
markChoices = [(-1, "-")] + list(zip(range(16)[::-1], range(16)[::-1]))
|
||||
|
||||
|
||||
class PartStudentView(SecureAdminModelView):
|
||||
class CreateForm(Form):
|
||||
def studentQueryFactory():
|
||||
|
@ -344,7 +341,6 @@ class PartStudentView(SecureAdminModelView):
|
|||
class EditForm(CreateForm):
|
||||
student = None
|
||||
part = None
|
||||
final_part_mark = SelectField("Final Part Mark", choices=markChoices, coerce=int)
|
||||
|
||||
form = EditForm
|
||||
|
||||
|
@ -360,12 +356,6 @@ class PartStudentView(SecureAdminModelView):
|
|||
def on_model_change(self, form, model, is_created):
|
||||
PartStudent.check(model.group, model.part)
|
||||
|
||||
def update_model(self, form, model):
|
||||
if form.final_part_mark.data == -1:
|
||||
form.final_part_mark.data = None
|
||||
|
||||
return super().update_model(form, model)
|
||||
|
||||
|
||||
def partStudentQueryFactory():
|
||||
return PartStudent.query.filter(PartStudent.part.has(Part.semester == userActiveSemester()))
|
||||
|
@ -446,10 +436,8 @@ class ExperimentView(SecureAdminModelView):
|
|||
form_args = {
|
||||
"wiki_link": {"validators": [URL()]},
|
||||
"oral_weighting": {
|
||||
"default": 0.5,
|
||||
"description": "Oral and protocol weighting have to add to 1! Both are rounded to 2 decimal digits.",
|
||||
"description": "Oral and protocol weighting have to add to 1! Both are rounded to 2 decimal digits."
|
||||
},
|
||||
"protocol_weighting": {"default": 0.5},
|
||||
}
|
||||
form_extra_fields = {
|
||||
"program": QuerySelectField(
|
||||
|
@ -702,6 +690,8 @@ class ExperimentMarkView(SecureAdminModelView):
|
|||
blank_text="-",
|
||||
)
|
||||
|
||||
markChoices = [(-1, "-")] + list(zip(range(16)[::-1], range(16)[::-1]))
|
||||
|
||||
oral_mark = SelectField("Oral Mark", choices=markChoices, coerce=int)
|
||||
protocol_mark = SelectField("Protocol Mark", choices=markChoices, coerce=int)
|
||||
|
||||
|
@ -753,15 +743,9 @@ class ExperimentMarkView(SecureAdminModelView):
|
|||
def create_model(self, form):
|
||||
form = ExperimentMarkView.checkForm(form)
|
||||
|
||||
return super().create_model(form)
|
||||
model = super().create_model(form)
|
||||
|
||||
def update_model(self, form, model):
|
||||
form = ExperimentMarkView.checkForm(form)
|
||||
|
||||
return super().update_model(form, model)
|
||||
|
||||
def after_model_change(self, form, model, is_created):
|
||||
if model.oral_mark or model.protocol_mark:
|
||||
if model and (model.oral_mark or model.protocol_mark):
|
||||
try:
|
||||
model.edited_by_admin = True
|
||||
|
||||
|
@ -771,6 +755,18 @@ class ExperimentMarkView(SecureAdminModelView):
|
|||
|
||||
self.session.rollback()
|
||||
|
||||
return model
|
||||
|
||||
def update_model(self, form, model):
|
||||
form = ExperimentMarkView.checkForm(form)
|
||||
|
||||
if (form.oral_mark and form.oral_mark.data != model.oral_mark) or (
|
||||
form.protocol_mark and form.protocol_mark.data != model.protocol_mark
|
||||
):
|
||||
model.edited_by_admin = True
|
||||
|
||||
return super().update_model(form, model)
|
||||
|
||||
|
||||
class ProgramView(SecureAdminModelView):
|
||||
can_view_details = True
|
||||
|
|
Loading…
Reference in a new issue