From 6ee368d0ef69178f1b98e60309d6d9792a64fd1d Mon Sep 17 00:00:00 2001 From: Mo8it Date: Thu, 29 Jul 2021 16:27:15 +0200 Subject: [PATCH] Done PartView and SemesterView --- advlabdb/modelViews.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/advlabdb/modelViews.py b/advlabdb/modelViews.py index c487dfc..6bf9280 100644 --- a/advlabdb/modelViews.py +++ b/advlabdb/modelViews.py @@ -96,28 +96,29 @@ class RoleView(SecureModelView): class SemesterView(SecureModelView): + class CreateForm(Form): + label = RadioField("Semester", choices=["WS", "SS"], validators=[DataRequired()]) + year = TextField("Year", validators=[DataRequired()]) + transfer_parts = BooleanField( + "Transfer parts", + description="This option transfers the parts you have in your current active semester. Make sure that your semester is the last semester before creating a new one (recommended)!", + default=True, + ) + transfer_assistants = BooleanField( + "Transfer Assistants", + description="This option transfers assistants of your active semester to active experiments in the new semester. Make sure that your semester is the last semester before creating a new one (recommended)! Active experiments are transfered anyway. If you do not want an experiment to be transfered, set it to inactive before creating the new semester. Experiments which are switched to active before creating the new semester will be created in the new semester without assistants. It is important to check the assistants of all experiments after creating a new semester.", + default=True, + ) + + form = CreateForm + can_edit = False can_delete = False can_view_details = True - column_list = ["label", "number", "parts"] - column_details_list = column_list + ["active_users", "groups"] - form_columns = ["label", "year", "transfer_parts", "transfer_assistants"] - - form_extra_fields = { - "label": RadioField("Semester", choices=["WS", "SS"], validators=[DataRequired()]), - "year": TextField("Year", validators=[DataRequired()]), - "transfer_parts": BooleanField( - "Transfer parts", - description="This option transfers the parts you have in your current active semester. Make sure that your semester is the last semester before creating a new one (recommended)!", - default=True, - ), - "transfer_assistants": BooleanField( - "Transfer Assistants", - description="This option transfers assistants of your active semester to active experiments in the new semester. Make sure that your semester is the last semester before creating a new one (recommended)! Active experiments are transfered anyway. If you do not want an experiment to be transfered, set it to inactive before creating the new semester. Experiments which are switched to active before creating the new semester will be created in the new semester without assistants. It is important to check the assistants of all experiments after creating a new semester.", - default=True, - ), - } + column_list = ["label", "year", "parts"] + column_details_list = column_list + ["semester_experiments", "active_users", "groups"] + column_searchable_list = ["label", "year"] def create_model(self, form): try: @@ -155,7 +156,9 @@ class SemesterView(SecureModelView): class PartView(SecureModelView): can_view_details = True - column_details_list = ["program", "number", "semester", "part_students"] + column_sortable_list = [] + column_list = ["program", "number", "semester"] + column_details_list = column_list + ["part_students"] form_columns = ["program", "number", "semester"] def queryFilter(self):