mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2025-04-10 20:48:36 +00:00
Add column_formatters_export
This commit is contained in:
parent
966d51f94c
commit
8b2e3da73e
1 changed files with 41 additions and 6 deletions
|
@ -50,9 +50,11 @@ from .admin_link_formatters import (
|
|||
user_formatter,
|
||||
)
|
||||
from .advlabdb_independent_funs import (
|
||||
deep_getattr,
|
||||
email_formatter,
|
||||
experiment_marks_missing_formatter,
|
||||
flashRandomPassword,
|
||||
str_without_semester_formatter,
|
||||
)
|
||||
from .customClasses import SecureAdminBaseView, SecureAdminModelView
|
||||
from .database_import import importFromFile
|
||||
|
@ -330,6 +332,11 @@ class SemesterView(SecureAdminModelView):
|
|||
"active_users": user_formatter,
|
||||
"groups": group_formatter,
|
||||
}
|
||||
column_formatters_export = {
|
||||
"parts": str_without_semester_formatter,
|
||||
"semester_experiments": str_without_semester_formatter,
|
||||
"groups": str_without_semester_formatter,
|
||||
}
|
||||
|
||||
def customCreateModel(self, form):
|
||||
return Semester.initFromOldSemester(
|
||||
|
@ -425,12 +432,6 @@ class StudentView(SecureAdminModelView):
|
|||
"contact_email",
|
||||
]
|
||||
|
||||
column_formatters = {
|
||||
"uni_email": email_formatter,
|
||||
"contact_email": email_formatter,
|
||||
"part_students": part_student_part_formatter,
|
||||
}
|
||||
|
||||
form_excluded_columns = [
|
||||
"part_students",
|
||||
]
|
||||
|
@ -441,6 +442,23 @@ class StudentView(SecureAdminModelView):
|
|||
"contact_email": {"validators": [Email()]},
|
||||
}
|
||||
|
||||
column_formatters = {
|
||||
"uni_email": email_formatter,
|
||||
"contact_email": email_formatter,
|
||||
"part_students": part_student_part_formatter,
|
||||
}
|
||||
|
||||
def part_students_export_formatter(view, context, model, name):
|
||||
part_students = deep_getattr(model, name)
|
||||
if part_students is None:
|
||||
return ""
|
||||
|
||||
return ", ".join([str(part_student.part) for part_student in part_students])
|
||||
|
||||
column_formatters_export = {
|
||||
"part_students": part_students_export_formatter,
|
||||
}
|
||||
|
||||
|
||||
def partQueryFactory():
|
||||
return Part.query.where(Part.semester == current_user.active_semester)
|
||||
|
@ -511,6 +529,10 @@ class PartStudentView(SecureAdminModelView):
|
|||
"part": part_formatter,
|
||||
"experiment_marks": experiment_mark_formatter,
|
||||
}
|
||||
column_formatters_export = {
|
||||
"group": str_without_semester_formatter,
|
||||
"part": str_without_semester_formatter,
|
||||
}
|
||||
|
||||
def query_modifier(self, query):
|
||||
return query.join(Part).where(Part.semester == current_user.active_semester)
|
||||
|
@ -954,6 +976,19 @@ class GroupExperimentView(SecureAdminModelView):
|
|||
"experiment_marks_missing": experiment_marks_missing_formatter,
|
||||
}
|
||||
|
||||
def appointments_export_formatter(view, context, model, name):
|
||||
appointments = deep_getattr(model, name)
|
||||
if appointments is None:
|
||||
return ""
|
||||
|
||||
return ", ".join([str(appointment.date) for appointment in appointments])
|
||||
|
||||
column_formatters_export = {
|
||||
"semester_experiment": str_without_semester_formatter,
|
||||
"group": str_without_semester_formatter,
|
||||
"appointments": appointments_export_formatter,
|
||||
}
|
||||
|
||||
def query_modifier(self, query):
|
||||
return query.join(Group).where(Group.semester == current_user.active_semester)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue