mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Added active to Experiment and transfer active
This commit is contained in:
parent
f28f9b64fb
commit
9247a5aa54
3 changed files with 23 additions and 19 deletions
File diff suppressed because one or more lines are too long
|
@ -105,12 +105,13 @@ class RoleView(SecureModelView):
|
||||||
|
|
||||||
class SemesterView(SecureModelView):
|
class SemesterView(SecureModelView):
|
||||||
can_edit = False
|
can_edit = False
|
||||||
|
can_delete = False
|
||||||
|
column_display_actions = False
|
||||||
|
|
||||||
column_list = ["label", "parts"]
|
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"]
|
semesterLabels = ["WS", "SS"]
|
||||||
transferDesciption = "Will be trasfered from your current semester."
|
|
||||||
form_extra_fields = {
|
form_extra_fields = {
|
||||||
"semester_label": RadioField(
|
"semester_label": RadioField(
|
||||||
"Semester", choices=list(zip(semesterLabels, semesterLabels)), validators=[DataRequired()]
|
"Semester", choices=list(zip(semesterLabels, semesterLabels)), validators=[DataRequired()]
|
||||||
|
@ -118,15 +119,12 @@ class SemesterView(SecureModelView):
|
||||||
"year": TextField("Year", validators=[DataRequired()]),
|
"year": TextField("Year", validators=[DataRequired()]),
|
||||||
"transfer_parts": BooleanField(
|
"transfer_parts": BooleanField(
|
||||||
"Transfer parts",
|
"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,
|
default=True,
|
||||||
),
|
),
|
||||||
"transfer_semester_experiments": BooleanField(
|
|
||||||
"Transfer Semester Experiemnts", description=transferDesciption, default=True
|
|
||||||
),
|
|
||||||
"transfer_assistants": BooleanField(
|
"transfer_assistants": BooleanField(
|
||||||
"Transfer Assistants",
|
"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,
|
default=True,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -163,14 +161,19 @@ class SemesterView(SecureModelView):
|
||||||
if form.transfer_parts.data:
|
if form.transfer_parts.data:
|
||||||
model.transferPartsFrom(oldSemester)
|
model.transferPartsFrom(oldSemester)
|
||||||
|
|
||||||
if form.transfer_semester_experiments.data:
|
oldSemesterExperiments = [
|
||||||
for semesterExperiment in oldSemester.semester_experiments:
|
semesterExperiment.experiment for semesterExperiment in oldSemester.semester_experiments
|
||||||
newSemesterExperiment = SemesterExperiment(
|
]
|
||||||
experiment=semesterExperiment.experiment, semester=userActiveSemester()
|
|
||||||
)
|
for experiment in Experiment.query.filter(Experiment.active == True):
|
||||||
if form.transfer_assistants.data:
|
newSemesterExperiment = SemesterExperiment(experiment=experiment, semester=model)
|
||||||
newSemesterExperiment.assistants = semesterExperiment.assistants
|
|
||||||
self.session.add(newSemesterExperiment)
|
if form.transfer_assistants.data:
|
||||||
|
for oldSemesterExperiment in oldSemester.semester_experiments:
|
||||||
|
if oldSemesterExperiment.experiment == experiment:
|
||||||
|
newSemesterExperiment.assistants = oldSemesterExperiment.assistants
|
||||||
|
|
||||||
|
self.session.add(newSemesterExperiment)
|
||||||
|
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
@ -348,8 +351,9 @@ class GroupView(SecureModelView):
|
||||||
|
|
||||||
class ExperimentView(SecureModelView):
|
class ExperimentView(SecureModelView):
|
||||||
can_view_details = True
|
can_view_details = True
|
||||||
column_filters = ["deprecated"]
|
column_filters = ["active"]
|
||||||
column_list = ["number", "name", "deprecated"]
|
column_list = ["number", "name", "active"]
|
||||||
|
column_editable_list = ["active"]
|
||||||
|
|
||||||
|
|
||||||
class SemesterExperimentView(SecureModelView):
|
class SemesterExperimentView(SecureModelView):
|
||||||
|
|
|
@ -107,7 +107,7 @@ class Experiment(db.Model):
|
||||||
building = db.Column(db.String(100), nullable=False)
|
building = db.Column(db.String(100), nullable=False)
|
||||||
responsibility = db.Column(db.String(200), nullable=True)
|
responsibility = db.Column(db.String(200), nullable=True)
|
||||||
duration_in_days = db.Column(db.Integer, nullable=False)
|
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)
|
oral_weighting = db.Column(db.Float, nullable=False)
|
||||||
protocol_weighting = db.Column(db.Float, nullable=False)
|
protocol_weighting = db.Column(db.Float, nullable=False)
|
||||||
final_weighting = db.Column(db.Float, nullable=False)
|
final_weighting = db.Column(db.Float, nullable=False)
|
||||||
|
|
Loading…
Reference in a new issue