mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Add experiment marks missing formatter
This commit is contained in:
parent
e92c7fe127
commit
38d61afb7f
1 changed files with 30 additions and 19 deletions
|
@ -3,6 +3,7 @@ from flask_admin import expose
|
||||||
from flask_admin.model.template import EndpointLinkRowAction
|
from flask_admin.model.template import EndpointLinkRowAction
|
||||||
from flask_security import admin_change_password, current_user
|
from flask_security import admin_change_password, current_user
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
|
from markupsafe import Markup
|
||||||
from wtforms.fields import TextAreaField
|
from wtforms.fields import TextAreaField
|
||||||
from wtforms.validators import Optional
|
from wtforms.validators import Optional
|
||||||
|
|
||||||
|
@ -54,25 +55,7 @@ class AssistantGroupExperimentView(SecureAssistantModelView):
|
||||||
"group.part_students": "Students",
|
"group.part_students": "Students",
|
||||||
}
|
}
|
||||||
|
|
||||||
def part_students_formatter(view, context, model, name):
|
column_default_sort = ("experiment_marks_missing", True)
|
||||||
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 = {
|
|
||||||
"semester_experiment.experiment": str_formatter,
|
|
||||||
"group.part_students": part_students_formatter,
|
|
||||||
"appointments": appointments_formatter,
|
|
||||||
}
|
|
||||||
|
|
||||||
column_extra_row_actions = [
|
column_extra_row_actions = [
|
||||||
EndpointLinkRowAction(
|
EndpointLinkRowAction(
|
||||||
|
@ -82,6 +65,34 @@ class AssistantGroupExperimentView(SecureAssistantModelView):
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
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 ""
|
||||||
|
|
||||||
|
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 ""
|
||||||
|
|
||||||
|
def experiment_marks_missing_formatter(view, context, model, name):
|
||||||
|
experiment_marks_missing = getattr(model, name)
|
||||||
|
if experiment_marks_missing is True:
|
||||||
|
return Markup("<span style='color: red;'>Yes</span>")
|
||||||
|
|
||||||
|
return "No"
|
||||||
|
|
||||||
|
column_formatters = {
|
||||||
|
"semester_experiment.experiment": str_formatter,
|
||||||
|
"group.part_students": part_students_formatter,
|
||||||
|
"appointments": appointments_formatter,
|
||||||
|
"experiment_marks_missing": experiment_marks_missing_formatter,
|
||||||
|
}
|
||||||
|
|
||||||
def query_modifier(self, query):
|
def query_modifier(self, query):
|
||||||
return (
|
return (
|
||||||
query.join(SemesterExperiment)
|
query.join(SemesterExperiment)
|
||||||
|
|
Loading…
Reference in a new issue