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

Further debloat assistantSpace

This commit is contained in:
Mo 2022-06-01 23:57:28 +02:00
parent 227c960653
commit 760cf05f26

View file

@ -6,7 +6,13 @@ from wtforms.fields import BooleanField, IntegerField, StringField
from wtforms.validators import NumberRange, Optional
from . import assistantSpace, db
from .advlabdb_independent_funs import flashRandomPassword, missing_formatter
from .advlabdb_independent_funs import (
deep_getattr,
flashRandomPassword,
missing_formatter,
str_formatter,
str_without_semester_formatter,
)
from .customClasses import SecureAssistantBaseView, SecureAssistantModelView
from .exceptions import DataBaseException, ModelViewException
from .model_dependent_funs import initActiveSemesterMenuLinks
@ -47,6 +53,18 @@ class AssistantAppointmentView(SecureAssistantModelView):
"special": "A special appointment should take place in the semester break",
}
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
column_formatters = {
"group_experiment.semester_experiment.experiment": str_formatter,
"group_experiment.group.part_students": part_students_formatter,
}
def query_modifier(self, query):
return (
query.join(GroupExperiment)
@ -78,7 +96,7 @@ class AssistantExperimentMarkView(SecureAssistantModelView):
"oral_mark",
"protocol_mark",
"final_experiment_mark",
"group_experiment.semester_experiment.experiment",
"group_experiment.semester_experiment.experiment.number",
"part_student.student",
"part_student.group.number",
"part_student.student.uni_email",
@ -88,7 +106,7 @@ class AssistantExperimentMarkView(SecureAssistantModelView):
"admin",
]
column_labels = {
"group_experiment.semester_experiment.experiment": "Experiment",
"group_experiment.semester_experiment.experiment.number": "Experiment number",
"part_student.student": "Student",
"part_student.group.number": "Group number",
"part_student.student.uni_email": "Uni Email",
@ -111,10 +129,11 @@ class AssistantExperimentMarkView(SecureAssistantModelView):
"part_student.student.contact_email",
]
column_formatters = dict(
oral_mark=missing_formatter,
protocol_mark=missing_formatter,
)
column_formatters = {
"oral_mark": missing_formatter,
"protocol_mark": missing_formatter,
"part_student.part": str_without_semester_formatter,
}
column_default_sort = [("oral_mark", False), ("protocol_mark", False)]