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

Adjust GroupExperiment view

This commit is contained in:
Mo 2022-06-27 22:12:52 +02:00
parent 1142cd99b5
commit c0bcdc4da5

View file

@ -50,14 +50,35 @@ class AssistantGroupExperimentView(SecureAssistantModelView):
column_list = [ column_list = [
"semester_experiment.experiment", "semester_experiment.experiment",
"group.number", "group.number",
"group.part_students",
"appointments",
# TODO: "final_experiment_marks_set",
"note", "note",
] ]
column_labels = { column_labels = {
"semester_experiment.experiment": "Experiment", "semester_experiment.experiment": "Experiment",
"group.number": "Group number", "group.number": "Group number",
"group.part_students": "Students",
} }
def part_students_formatter(view, context, model, name):
part_students = deep_getattr(model, name)
if part_students is not None:
return ", ".join([str(part_student.student) for part_student in part_students])
return attr
def appointments_formatter(view, context, model, name):
appointments = deep_getattr(model, name)
if appointments is not None:
return ", ".join([str(appointment.date) for appointment in appointments])
return attr
column_formatters = { column_formatters = {
"semester_experiment.experiment": str_formatter, "semester_experiment.experiment": str_formatter,
"group.part_students": part_students_formatter,
"appointments": appointments_formatter,
} }
def query_modifier(self, query): def query_modifier(self, query):
@ -121,6 +142,8 @@ class AssistantGroupExperimentView(SecureAssistantModelView):
db.session.rollback() db.session.rollback()
final_experiment_marks = [experiment_mark.final_experiment_mark for experiment_mark in experiment_marks]
return self.render( return self.render(
"assistant_group_experiment_form.html", "assistant_group_experiment_form.html",
form=form, form=form,
@ -128,7 +151,10 @@ class AssistantGroupExperimentView(SecureAssistantModelView):
group_number=group_experiment.group.number, group_number=group_experiment.group.number,
appointment_fields=appointment_fields, appointment_fields=appointment_fields,
experiment_mark_zip=zip( experiment_mark_zip=zip(
experiment_mark_students, oral_experiment_mark_fields, protocol_experiment_mark_fields experiment_mark_students,
oral_experiment_mark_fields,
protocol_experiment_mark_fields,
final_experiment_marks,
), ),
) )