1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-20 23:41:20 +00:00

Added active to Experiment and transfer active

This commit is contained in:
Mo 2021-07-01 23:17:09 +02:00
parent f28f9b64fb
commit 9247a5aa54
3 changed files with 23 additions and 19 deletions

File diff suppressed because one or more lines are too long

View file

@ -105,12 +105,13 @@ class RoleView(SecureModelView):
class SemesterView(SecureModelView):
can_edit = False
can_delete = False
column_display_actions = False
column_list = ["label", "parts"]
form_columns = ["semester_label", "year", "transfer_parts", "transfer_semester_experiments", "transfer_assistants"]
form_columns = ["semester_label", "year", "transfer_parts", "transfer_assistants"]
semesterLabels = ["WS", "SS"]
transferDesciption = "Will be trasfered from your current semester."
form_extra_fields = {
"semester_label": RadioField(
"Semester", choices=list(zip(semesterLabels, semesterLabels)), validators=[DataRequired()]
@ -118,15 +119,12 @@ class SemesterView(SecureModelView):
"year": TextField("Year", validators=[DataRequired()]),
"transfer_parts": BooleanField(
"Transfer parts",
description=transferDesciption,
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_semester_experiments": BooleanField(
"Transfer Semester Experiemnts", description=transferDesciption, default=True
),
"transfer_assistants": BooleanField(
"Transfer Assistants",
description=transferDesciption + " This option has no effect if Semester Experiments are not transfered.",
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 don't 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,
),
}
@ -163,13 +161,18 @@ class SemesterView(SecureModelView):
if form.transfer_parts.data:
model.transferPartsFrom(oldSemester)
if form.transfer_semester_experiments.data:
for semesterExperiment in oldSemester.semester_experiments:
newSemesterExperiment = SemesterExperiment(
experiment=semesterExperiment.experiment, semester=userActiveSemester()
)
oldSemesterExperiments = [
semesterExperiment.experiment for semesterExperiment in oldSemester.semester_experiments
]
for experiment in Experiment.query.filter(Experiment.active == True):
newSemesterExperiment = SemesterExperiment(experiment=experiment, semester=model)
if form.transfer_assistants.data:
newSemesterExperiment.assistants = semesterExperiment.assistants
for oldSemesterExperiment in oldSemester.semester_experiments:
if oldSemesterExperiment.experiment == experiment:
newSemesterExperiment.assistants = oldSemesterExperiment.assistants
self.session.add(newSemesterExperiment)
self.session.commit()
@ -348,8 +351,9 @@ class GroupView(SecureModelView):
class ExperimentView(SecureModelView):
can_view_details = True
column_filters = ["deprecated"]
column_list = ["number", "name", "deprecated"]
column_filters = ["active"]
column_list = ["number", "name", "active"]
column_editable_list = ["active"]
class SemesterExperimentView(SecureModelView):

View file

@ -107,7 +107,7 @@ class Experiment(db.Model):
building = db.Column(db.String(100), nullable=False)
responsibility = db.Column(db.String(200), nullable=True)
duration_in_days = db.Column(db.Integer, nullable=False)
deprecated = db.Column(db.Boolean, nullable=False, default=False) # To not be deleted!
active = db.Column(db.Boolean, nullable=False, default=True)
oral_weighting = db.Column(db.Float, nullable=False)
protocol_weighting = db.Column(db.Float, nullable=False)
final_weighting = db.Column(db.Float, nullable=False)