From 3425947f3e55f565f375b148022f454a1a4add2f Mon Sep 17 00:00:00 2001 From: Mo8it Date: Mon, 16 Aug 2021 23:32:46 +0200 Subject: [PATCH] Added some descriptions and applied last commit --- advlabdb/adminModelViews.py | 42 +++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/advlabdb/adminModelViews.py b/advlabdb/adminModelViews.py index 7a1a2ca..cc959e7 100644 --- a/advlabdb/adminModelViews.py +++ b/advlabdb/adminModelViews.py @@ -278,6 +278,7 @@ class StudentView(SecureAdminModelView): can_view_details = True column_list = ["student_number", "first_name", "last_name", "uni_email", "contact_email", "part_students"] + column_descriptions = {"contact_email": "The preferred contact email address if entered by the student"} column_details_list = column_list + ["bachelor_thesis", "bachelor_thesis_work_group", "note"] column_sortable_list = ["student_number", "first_name", "last_name"] @@ -381,7 +382,10 @@ class GroupView(SecureAdminModelView): class CustomForm(Form): part_students = QuerySelectMultipleField( - "Part Students", query_factory=query_factory, validators=[DataRequired()] + "Part Students", + query_factory=query_factory, + validators=[DataRequired()], + description="The part students have to be in the same program!", ) return CustomForm @@ -417,6 +421,7 @@ class ExperimentView(SecureAdminModelView): column_filters = ["active"] column_list = ["number", "program", "title", "active"] + column_descriptions = {"active": "Active experiments are present in new semesters"} column_details_list = column_list + [ "description", "wiki_link", @@ -429,17 +434,29 @@ class ExperimentView(SecureAdminModelView): "final_weighting", "semester_experiments", ] + + form_columns = column_details_list.copy() + form_columns.remove("semester_experiments") + column_editable_list = ["active"] - form_columns = column_details_list - - form_args = {"wiki_link": {"validators": [URL()]}} + 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.", + }, + "protocol_weighting": {"default": 0.5}, + } form_extra_fields = { "program": QuerySelectField( "Program", query_factory=programQueryFactory, validators=[DataRequired()], allow_blank=True, blank_text="-" ) } + def on_model_change(self, form, model, is_created): + model.checkWeightings(roundWeightings=True) + def assistantQueryFactory(): return Assistant.query.filter(Assistant.user.has(User.active == True)) @@ -533,7 +550,11 @@ class GroupExperimentView(SecureAdminModelView): blank_text="-", ) - appointment1_date = DateField("Appointment-1 Date", validators=[Optional()]) + appointment1_date = DateField( + "Appointment-1 Date", + validators=[Optional()], + description="Set if you already want to add an appointment. Otherwise, leave it blank and you can do it later under the Appointment tab.", + ) appointment1_special = BooleanField("Appointment-1 Special", default=False) appointment1_assistant = QuerySelectField( "Appointment-1 Assistant", @@ -542,7 +563,9 @@ class GroupExperimentView(SecureAdminModelView): blank_text=assistantBlankText, ) - appointment2_date = DateField("Appointment-2 Date", validators=[Optional()]) + appointment2_date = DateField( + "Appointment-2 Date", validators=[Optional()], description="Add a second appointment (see above)." + ) appointment2_special = BooleanField("Appointment-2 Special", default=False) appointment2_assistant = QuerySelectField( "Appointment-2 Assistant", @@ -681,6 +704,13 @@ class ExperimentMarkView(SecureAdminModelView): form = CreateForm + column_descriptions = { + "oral_mark": "Between 0 and 15", + "protocol_mark": "Between 0 and 15", + "assistant": "The assistant who assigned the mark", + "edited_by_admin": "If the mark was edited by an admin", + } + column_editable_list = ["oral_mark", "protocol_mark"] form_args = { "oral_mark": {"validators": [NumberRange(0, 15)]},