From 4c64a8cefde100686be47579a8c133aa92dd15de Mon Sep 17 00:00:00 2001 From: Mo8it Date: Fri, 17 Jun 2022 19:58:43 +0200 Subject: [PATCH] Further deduplication --- advlabdb/adminModelViews.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/advlabdb/adminModelViews.py b/advlabdb/adminModelViews.py index 9e88838..98ace69 100644 --- a/advlabdb/adminModelViews.py +++ b/advlabdb/adminModelViews.py @@ -1135,6 +1135,14 @@ class AppointmentView(SecureAdminModelView): ) +def mark_field(mark_type: str): + return IntegerField( + mark_type + " Mark", + validators=[Optional(), NumberRange(MIN_MARK, MAX_MARK)], + description=f"Between {MIN_MARK} and {MAX_MARK}.", + ) + + class ExperimentMarkView(SecureAdminModelView): class StudentFilter(FilterEqual): def validate(self, value): @@ -1215,16 +1223,8 @@ class ExperimentMarkView(SecureAdminModelView): ) class EditForm(Form): - oral_mark = IntegerField( - "Oral Mark", - validators=[Optional(), NumberRange(MIN_MARK, MAX_MARK)], - description=f"Between {MIN_MARK} and {MAX_MARK}.", - ) - protocol_mark = IntegerField( - "Protocol Mark", - validators=[Optional(), NumberRange(MIN_MARK, MAX_MARK)], - description=f"Between {MIN_MARK} and {MAX_MARK}.", - ) + oral_mark = mark_field("Oral") + protocol_mark = mark_field("Protocol") column_descriptions = { "oral_mark": f"Between {MIN_MARK} and {MAX_MARK}",