mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Apply link formatters
This commit is contained in:
parent
50c03b9df2
commit
8c439ab530
1 changed files with 100 additions and 178 deletions
|
@ -9,7 +9,6 @@ from flask_admin.contrib.sqla.fields import QuerySelectField, QuerySelectMultipl
|
||||||
from flask_admin.contrib.sqla.filters import BooleanEqualFilter, FilterEqual
|
from flask_admin.contrib.sqla.filters import BooleanEqualFilter, FilterEqual
|
||||||
from flask_admin.helpers import get_form_data
|
from flask_admin.helpers import get_form_data
|
||||||
from flask_admin.menu import MenuLink
|
from flask_admin.menu import MenuLink
|
||||||
from flask_admin.model.template import EndpointLinkRowAction
|
|
||||||
from flask_security import admin_change_password, current_user, hash_password
|
from flask_security import admin_change_password, current_user, hash_password
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from flask_wtf.file import FileAllowed, FileField, FileRequired
|
from flask_wtf.file import FileAllowed, FileField, FileRequired
|
||||||
|
@ -30,12 +29,27 @@ from wtforms.validators import URL, DataRequired, Email, NumberRange, Optional
|
||||||
from wtforms.widgets import NumberInput
|
from wtforms.widgets import NumberInput
|
||||||
|
|
||||||
from . import adminSpace, app, assistantSpace, db, user_datastore
|
from . import adminSpace, app, assistantSpace, db, user_datastore
|
||||||
from .advlabdb_independent_funs import flashRandomPassword
|
from .admin_link_formatters import (
|
||||||
from .customClasses import (
|
admin_formatter,
|
||||||
CustomIdEndpointLinkRowAction,
|
appointment_date_formatter,
|
||||||
SecureAdminBaseView,
|
appointment_formatter,
|
||||||
SecureAdminModelView,
|
assistant_formatter,
|
||||||
|
experiment_formatter,
|
||||||
|
experiment_mark_formatter,
|
||||||
|
group_experiment_formatter,
|
||||||
|
group_formatter,
|
||||||
|
part_formatter,
|
||||||
|
part_student_formatter,
|
||||||
|
part_with_semester_formatter,
|
||||||
|
program_formatter,
|
||||||
|
semester_experiment_formatter,
|
||||||
|
semester_experiment_with_semester_formatter,
|
||||||
|
semester_formatter,
|
||||||
|
student_formatter,
|
||||||
|
user_formatter,
|
||||||
)
|
)
|
||||||
|
from .advlabdb_independent_funs import email_formatter, flashRandomPassword
|
||||||
|
from .customClasses import SecureAdminBaseView, SecureAdminModelView
|
||||||
from .database_import import importFromFile
|
from .database_import import importFromFile
|
||||||
from .exceptions import DataBaseException, ModelViewException
|
from .exceptions import DataBaseException, ModelViewException
|
||||||
from .model_dependent_funs import (
|
from .model_dependent_funs import (
|
||||||
|
@ -143,8 +157,6 @@ class UserView(SecureAdminModelView):
|
||||||
|
|
||||||
generate_new_password = generate_new_password_field()
|
generate_new_password = generate_new_password_field()
|
||||||
|
|
||||||
can_view_details = True
|
|
||||||
|
|
||||||
column_list = [
|
column_list = [
|
||||||
"first_name",
|
"first_name",
|
||||||
"last_name",
|
"last_name",
|
||||||
|
@ -178,6 +190,11 @@ class UserView(SecureAdminModelView):
|
||||||
"active",
|
"active",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
column_formatters = {
|
||||||
|
"email": email_formatter,
|
||||||
|
"active_semester": semester_formatter,
|
||||||
|
}
|
||||||
|
|
||||||
_skip_session_addition_on_model_creation = True
|
_skip_session_addition_on_model_creation = True
|
||||||
|
|
||||||
def customCreateModel(self, form):
|
def customCreateModel(self, form):
|
||||||
|
@ -286,7 +303,6 @@ class SemesterView(SecureAdminModelView):
|
||||||
|
|
||||||
can_edit = False
|
can_edit = False
|
||||||
can_delete = False
|
can_delete = False
|
||||||
can_view_details = True
|
|
||||||
column_display_all_relations = True
|
column_display_all_relations = True
|
||||||
|
|
||||||
column_list = [
|
column_list = [
|
||||||
|
@ -303,6 +319,13 @@ class SemesterView(SecureAdminModelView):
|
||||||
("label", True),
|
("label", True),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
column_formatters = {
|
||||||
|
"parts": part_formatter,
|
||||||
|
"semester_experiments": semester_experiment_formatter,
|
||||||
|
"active_users": user_formatter,
|
||||||
|
"groups": group_formatter,
|
||||||
|
}
|
||||||
|
|
||||||
def customCreateModel(self, form):
|
def customCreateModel(self, form):
|
||||||
return Semester.initFromOldSemester(
|
return Semester.initFromOldSemester(
|
||||||
label=form.label.data,
|
label=form.label.data,
|
||||||
|
@ -337,7 +360,6 @@ def programQueryFactory():
|
||||||
|
|
||||||
|
|
||||||
class PartView(SecureAdminModelView):
|
class PartView(SecureAdminModelView):
|
||||||
can_view_details = True
|
|
||||||
column_display_all_relations = True
|
column_display_all_relations = True
|
||||||
|
|
||||||
column_sortable_list = []
|
column_sortable_list = []
|
||||||
|
@ -345,9 +367,6 @@ class PartView(SecureAdminModelView):
|
||||||
"program",
|
"program",
|
||||||
"number",
|
"number",
|
||||||
]
|
]
|
||||||
column_details_exclude_list = [
|
|
||||||
"semester",
|
|
||||||
]
|
|
||||||
form_columns = column_list
|
form_columns = column_list
|
||||||
|
|
||||||
form_extra_fields = {
|
form_extra_fields = {
|
||||||
|
@ -363,10 +382,11 @@ class PartView(SecureAdminModelView):
|
||||||
"number": {"widget": NumberInput(min=1)},
|
"number": {"widget": NumberInput(min=1)},
|
||||||
}
|
}
|
||||||
|
|
||||||
column_searchable_list = [
|
column_formatters = {
|
||||||
"program.label",
|
"program": program_formatter,
|
||||||
"number",
|
"semester": semester_formatter,
|
||||||
]
|
"part_students": part_student_formatter,
|
||||||
|
}
|
||||||
|
|
||||||
def query_modifier(self, query):
|
def query_modifier(self, query):
|
||||||
return query.where(Part.semester == current_user.active_semester)
|
return query.where(Part.semester == current_user.active_semester)
|
||||||
|
@ -376,7 +396,6 @@ class PartView(SecureAdminModelView):
|
||||||
|
|
||||||
|
|
||||||
class StudentView(SecureAdminModelView):
|
class StudentView(SecureAdminModelView):
|
||||||
can_view_details = True
|
|
||||||
column_display_all_relations = True
|
column_display_all_relations = True
|
||||||
|
|
||||||
column_list = [
|
column_list = [
|
||||||
|
@ -401,6 +420,12 @@ class StudentView(SecureAdminModelView):
|
||||||
"contact_email",
|
"contact_email",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
column_formatters = {
|
||||||
|
"uni_email": email_formatter,
|
||||||
|
"contact_email": email_formatter,
|
||||||
|
"part_students": part_student_formatter,
|
||||||
|
}
|
||||||
|
|
||||||
form_excluded_columns = [
|
form_excluded_columns = [
|
||||||
"part_students",
|
"part_students",
|
||||||
]
|
]
|
||||||
|
@ -411,15 +436,6 @@ class StudentView(SecureAdminModelView):
|
||||||
"contact_email": {"validators": [Email()]},
|
"contact_email": {"validators": [Email()]},
|
||||||
}
|
}
|
||||||
|
|
||||||
column_extra_row_actions = [
|
|
||||||
EndpointLinkRowAction(
|
|
||||||
icon_class="fa fa-history",
|
|
||||||
endpoint="admin_experiment_mark.index_view",
|
|
||||||
id_arg="flt1_0",
|
|
||||||
title="Experiments history",
|
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def partQueryFactory():
|
def partQueryFactory():
|
||||||
return Part.query.where(Part.semester == current_user.active_semester)
|
return Part.query.where(Part.semester == current_user.active_semester)
|
||||||
|
@ -443,18 +459,6 @@ class PartStudentView(SecureAdminModelView):
|
||||||
def apply(self, query, value, alias=None):
|
def apply(self, query, value, alias=None):
|
||||||
return query.where(PartStudent.part_id == int(value))
|
return query.where(PartStudent.part_id == int(value))
|
||||||
|
|
||||||
class StudentEndpointLinkRowAction(CustomIdEndpointLinkRowAction):
|
|
||||||
def customId(self, row):
|
|
||||||
return row.student_id
|
|
||||||
|
|
||||||
class GroupEndpointLinkRowAction(CustomIdEndpointLinkRowAction):
|
|
||||||
def customId(self, row):
|
|
||||||
return row.group_id
|
|
||||||
|
|
||||||
class PartEndpointLinkRowAction(CustomIdEndpointLinkRowAction):
|
|
||||||
def customId(self, row):
|
|
||||||
return row.part_id
|
|
||||||
|
|
||||||
class CreateForm(FlaskForm):
|
class CreateForm(FlaskForm):
|
||||||
def studentQueryFactory():
|
def studentQueryFactory():
|
||||||
return Student.query
|
return Student.query
|
||||||
|
@ -496,23 +500,12 @@ class PartStudentView(SecureAdminModelView):
|
||||||
)
|
)
|
||||||
refreshFiltersCache = True
|
refreshFiltersCache = True
|
||||||
|
|
||||||
column_extra_row_actions = [
|
column_formatters = {
|
||||||
StudentEndpointLinkRowAction(
|
"student": student_formatter,
|
||||||
icon_class="fa fa-user",
|
"group": group_formatter,
|
||||||
endpoint="admin_student.details_view",
|
"part": part_formatter,
|
||||||
title="Student",
|
"experiment_marks": experiment_mark_formatter,
|
||||||
),
|
}
|
||||||
GroupEndpointLinkRowAction(
|
|
||||||
icon_class="fa fa-users",
|
|
||||||
endpoint="admin_group.details_view",
|
|
||||||
title="Group",
|
|
||||||
),
|
|
||||||
PartEndpointLinkRowAction(
|
|
||||||
icon_class="fa fa-puzzle-piece",
|
|
||||||
endpoint="admin_part.details_view",
|
|
||||||
title="Part",
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
def query_modifier(self, query):
|
def query_modifier(self, query):
|
||||||
return query.join(Part).where(Part.semester == current_user.active_semester)
|
return query.join(Part).where(Part.semester == current_user.active_semester)
|
||||||
|
@ -565,8 +558,6 @@ class GroupView(SecureAdminModelView):
|
||||||
|
|
||||||
return CustomForm
|
return CustomForm
|
||||||
|
|
||||||
can_view_details = True
|
|
||||||
|
|
||||||
column_display_all_relations = True
|
column_display_all_relations = True
|
||||||
|
|
||||||
column_exclude_list = [
|
column_exclude_list = [
|
||||||
|
@ -579,6 +570,12 @@ class GroupView(SecureAdminModelView):
|
||||||
)
|
)
|
||||||
refreshFiltersCache = True
|
refreshFiltersCache = True
|
||||||
|
|
||||||
|
column_formatters = {
|
||||||
|
"program": program_formatter,
|
||||||
|
"part_students": part_student_formatter,
|
||||||
|
"group_experiments": group_experiment_formatter,
|
||||||
|
}
|
||||||
|
|
||||||
def query_modifier(self, query):
|
def query_modifier(self, query):
|
||||||
return query.where(Group.semester == current_user.active_semester)
|
return query.where(Group.semester == current_user.active_semester)
|
||||||
|
|
||||||
|
@ -599,7 +596,6 @@ class ExperimentView(SecureAdminModelView):
|
||||||
def apply(self, query, value, alias=None):
|
def apply(self, query, value, alias=None):
|
||||||
return query.where(Experiment.program_id == int(value))
|
return query.where(Experiment.program_id == int(value))
|
||||||
|
|
||||||
can_view_details = True
|
|
||||||
column_display_all_relations = True
|
column_display_all_relations = True
|
||||||
|
|
||||||
column_filters = (
|
column_filters = (
|
||||||
|
@ -650,6 +646,11 @@ class ExperimentView(SecureAdminModelView):
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
column_formatters = {
|
||||||
|
"program": program_formatter,
|
||||||
|
"semester_experiments": semester_experiment_with_semester_formatter,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def assistantQueryFactory():
|
def assistantQueryFactory():
|
||||||
return Assistant.query.join(User).where(User.active == True)
|
return Assistant.query.join(User).where(User.active == True)
|
||||||
|
@ -671,10 +672,6 @@ class SemesterExperimentView(SecureAdminModelView):
|
||||||
def apply(self, query, value, alias=None):
|
def apply(self, query, value, alias=None):
|
||||||
return query.join(Experiment).where(Experiment.program_id == int(value))
|
return query.join(Experiment).where(Experiment.program_id == int(value))
|
||||||
|
|
||||||
class ExperimentEndpointLinkRowAction(CustomIdEndpointLinkRowAction):
|
|
||||||
def customId(self, row):
|
|
||||||
return row.experiment_id
|
|
||||||
|
|
||||||
class CreateForm(FlaskForm):
|
class CreateForm(FlaskForm):
|
||||||
def experimentQueryFactory():
|
def experimentQueryFactory():
|
||||||
return Experiment.query.where(Experiment.active == True)
|
return Experiment.query.where(Experiment.active == True)
|
||||||
|
@ -699,16 +696,12 @@ class SemesterExperimentView(SecureAdminModelView):
|
||||||
class EditForm(CreateForm):
|
class EditForm(CreateForm):
|
||||||
experiment = None
|
experiment = None
|
||||||
|
|
||||||
can_view_details = True
|
|
||||||
column_display_all_relations = True
|
column_display_all_relations = True
|
||||||
|
|
||||||
column_list = [
|
column_list = [
|
||||||
"experiment",
|
"experiment",
|
||||||
"assistants",
|
"assistants",
|
||||||
]
|
]
|
||||||
column_details_exclude_list = [
|
|
||||||
"semester",
|
|
||||||
]
|
|
||||||
|
|
||||||
column_filters = (ProgramFilter(SemesterExperiment, "Program"),)
|
column_filters = (ProgramFilter(SemesterExperiment, "Program"),)
|
||||||
refreshFiltersCache = True
|
refreshFiltersCache = True
|
||||||
|
@ -718,13 +711,12 @@ class SemesterExperimentView(SecureAdminModelView):
|
||||||
"experiment.title",
|
"experiment.title",
|
||||||
]
|
]
|
||||||
|
|
||||||
column_extra_row_actions = [
|
column_formatters = {
|
||||||
ExperimentEndpointLinkRowAction(
|
"experiment": experiment_formatter,
|
||||||
icon_class="fa fa-flask",
|
"semester": semester_formatter,
|
||||||
endpoint="admin_experiment.details_view",
|
"assistants": assistant_formatter,
|
||||||
title="Experiment",
|
"group_experiments": group_experiment_formatter,
|
||||||
),
|
}
|
||||||
]
|
|
||||||
|
|
||||||
def query_modifier(self, query):
|
def query_modifier(self, query):
|
||||||
return query.where(SemesterExperiment.semester == current_user.active_semester)
|
return query.where(SemesterExperiment.semester == current_user.active_semester)
|
||||||
|
@ -771,31 +763,18 @@ def userHasRoleFilterFactory(column, role_name):
|
||||||
|
|
||||||
|
|
||||||
class AssistantView(SecureAdminModelView):
|
class AssistantView(SecureAdminModelView):
|
||||||
class UserEndpointLinkRowAction(CustomIdEndpointLinkRowAction):
|
|
||||||
def customId(self, row):
|
|
||||||
return row.user_id
|
|
||||||
|
|
||||||
def assistantUserQueryFactory():
|
def assistantUserQueryFactory():
|
||||||
return User.query.join(User.roles).where(Role.name == "assistant")
|
return User.query.join(User.roles).where(Role.name == "assistant")
|
||||||
|
|
||||||
can_view_details = True
|
column_display_all_relations = True
|
||||||
|
|
||||||
column_list = [
|
column_list = [
|
||||||
"user",
|
"user",
|
||||||
"semester_experiments",
|
"semester_experiments",
|
||||||
]
|
]
|
||||||
column_details_list = column_list + [
|
|
||||||
"user.phone_number",
|
|
||||||
"user.mobile_phone_number",
|
|
||||||
"user.building",
|
|
||||||
"user.room",
|
|
||||||
"appointments",
|
|
||||||
"experiment_marks",
|
|
||||||
]
|
|
||||||
column_searchable_list = [
|
column_searchable_list = [
|
||||||
"user.first_name",
|
"user.first_name",
|
||||||
"user.last_name",
|
"user.last_name",
|
||||||
"user.email",
|
|
||||||
]
|
]
|
||||||
column_filters = (
|
column_filters = (
|
||||||
userHasRoleFilterFactory(Assistant, "assistant"),
|
userHasRoleFilterFactory(Assistant, "assistant"),
|
||||||
|
@ -822,20 +801,15 @@ class AssistantView(SecureAdminModelView):
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
column_extra_row_actions = [
|
column_formatters = {
|
||||||
UserEndpointLinkRowAction(
|
"user": user_formatter,
|
||||||
icon_class="fa fa-user",
|
"semester_experiments": semester_experiment_with_semester_formatter,
|
||||||
endpoint="admin_user.details_view",
|
"appointments": appointment_formatter,
|
||||||
title="User",
|
"experiment_marks": experiment_mark_formatter,
|
||||||
),
|
}
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class AdminView(SecureAdminModelView):
|
class AdminView(SecureAdminModelView):
|
||||||
class UserEndpointLinkRowAction(CustomIdEndpointLinkRowAction):
|
|
||||||
def customId(self, row):
|
|
||||||
return row.user_id
|
|
||||||
|
|
||||||
can_export = False
|
can_export = False
|
||||||
can_set_page_size = False
|
can_set_page_size = False
|
||||||
can_create = False
|
can_create = False
|
||||||
|
@ -850,13 +824,9 @@ class AdminView(SecureAdminModelView):
|
||||||
"user.active",
|
"user.active",
|
||||||
)
|
)
|
||||||
|
|
||||||
column_extra_row_actions = [
|
column_formatters = {
|
||||||
UserEndpointLinkRowAction(
|
"user": user_formatter,
|
||||||
icon_class="fa fa-user",
|
}
|
||||||
endpoint="admin_user.details_view",
|
|
||||||
title="User",
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class ExperimentRowFilter(FilterEqual):
|
class ExperimentRowFilter(FilterEqual):
|
||||||
|
@ -935,14 +905,6 @@ class GroupExperimentView(SecureAdminModelView):
|
||||||
.where(Experiment.program_id == programId, Experiment.number == experimentNumber)
|
.where(Experiment.program_id == programId, Experiment.number == experimentNumber)
|
||||||
)
|
)
|
||||||
|
|
||||||
class GroupEndpointLinkRowAction(CustomIdEndpointLinkRowAction):
|
|
||||||
def customId(self, row):
|
|
||||||
return row.group_id
|
|
||||||
|
|
||||||
class SemesterExperimentEndpointLinkRowAction(CustomIdEndpointLinkRowAction):
|
|
||||||
def customId(self, row):
|
|
||||||
return row.semester_experiment_id
|
|
||||||
|
|
||||||
class EditForm(FlaskForm):
|
class EditForm(FlaskForm):
|
||||||
note = group_experiment_note_field()
|
note = group_experiment_note_field()
|
||||||
|
|
||||||
|
@ -967,8 +929,6 @@ class GroupExperimentView(SecureAdminModelView):
|
||||||
|
|
||||||
note = group_experiment_note_field()
|
note = group_experiment_note_field()
|
||||||
|
|
||||||
can_view_details = True
|
|
||||||
|
|
||||||
column_display_all_relations = True
|
column_display_all_relations = True
|
||||||
|
|
||||||
column_filters = (
|
column_filters = (
|
||||||
|
@ -979,18 +939,12 @@ class GroupExperimentView(SecureAdminModelView):
|
||||||
)
|
)
|
||||||
refreshFiltersCache = True
|
refreshFiltersCache = True
|
||||||
|
|
||||||
column_extra_row_actions = [
|
column_formatters = {
|
||||||
GroupEndpointLinkRowAction(
|
"semester_experiment": semester_experiment_formatter,
|
||||||
icon_class="fa fa-users",
|
"group": group_formatter,
|
||||||
endpoint="admin_group.details_view",
|
"appointments": appointment_date_formatter,
|
||||||
title="Group",
|
"experiment_marks": experiment_mark_formatter,
|
||||||
),
|
}
|
||||||
SemesterExperimentEndpointLinkRowAction(
|
|
||||||
icon_class="fa fa-flask",
|
|
||||||
endpoint="admin_semester_experiment.details_view",
|
|
||||||
title="SemesterExperiment",
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
def query_modifier(self, query):
|
def query_modifier(self, query):
|
||||||
return query.join(Group).where(Group.semester == current_user.active_semester)
|
return query.join(Group).where(Group.semester == current_user.active_semester)
|
||||||
|
@ -1046,14 +1000,6 @@ class AppointmentView(SecureAdminModelView):
|
||||||
def apply(self, query, value, alias=None):
|
def apply(self, query, value, alias=None):
|
||||||
return query.where(Appointment.assistant_id == int(value))
|
return query.where(Appointment.assistant_id == int(value))
|
||||||
|
|
||||||
class GroupExperimentEndpointLinkRowAction(CustomIdEndpointLinkRowAction):
|
|
||||||
def customId(self, row):
|
|
||||||
return row.group_experiment_id
|
|
||||||
|
|
||||||
class AssistantEndpointLinkRowAction(CustomIdEndpointLinkRowAction):
|
|
||||||
def customId(self, row):
|
|
||||||
return row.assistant_id
|
|
||||||
|
|
||||||
class CreateAndEditForm(FlaskForm):
|
class CreateAndEditForm(FlaskForm):
|
||||||
group_experiment = QuerySelectField(
|
group_experiment = QuerySelectField(
|
||||||
"Group Experiment",
|
"Group Experiment",
|
||||||
|
@ -1081,18 +1027,10 @@ class AppointmentView(SecureAdminModelView):
|
||||||
"special",
|
"special",
|
||||||
]
|
]
|
||||||
|
|
||||||
column_extra_row_actions = [
|
column_formatters = {
|
||||||
GroupExperimentEndpointLinkRowAction(
|
"group_experiment": group_experiment_formatter,
|
||||||
icon_class="fa fa-flask",
|
"assistant": assistant_formatter,
|
||||||
endpoint="admin_group_experiment.details_view",
|
}
|
||||||
title="GroupExperiment",
|
|
||||||
),
|
|
||||||
AssistantEndpointLinkRowAction(
|
|
||||||
icon_class="fa fa-user-secret",
|
|
||||||
endpoint="admin_assistant.details_view",
|
|
||||||
title="Assistant",
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
def query_modifier(self, query):
|
def query_modifier(self, query):
|
||||||
return (
|
return (
|
||||||
|
@ -1177,18 +1115,6 @@ class ExperimentMarkView(SecureAdminModelView):
|
||||||
query.join(GroupExperiment).join(SemesterExperiment).where(SemesterExperiment.semester_id == int(value))
|
query.join(GroupExperiment).join(SemesterExperiment).where(SemesterExperiment.semester_id == int(value))
|
||||||
)
|
)
|
||||||
|
|
||||||
class PartStudentEndpointLinkRowAction(CustomIdEndpointLinkRowAction):
|
|
||||||
def customId(self, row):
|
|
||||||
return row.part_student_id
|
|
||||||
|
|
||||||
class GroupExperimentEndpointLinkRowAction(CustomIdEndpointLinkRowAction):
|
|
||||||
def customId(self, row):
|
|
||||||
return row.group_experiment_id
|
|
||||||
|
|
||||||
class AssistantEndpointLinkRowAction(CustomIdEndpointLinkRowAction):
|
|
||||||
def customId(self, row):
|
|
||||||
return row.assistant_id
|
|
||||||
|
|
||||||
class CreateForm(FlaskForm):
|
class CreateForm(FlaskForm):
|
||||||
part_student = QuerySelectField(
|
part_student = QuerySelectField(
|
||||||
"Part Student",
|
"Part Student",
|
||||||
|
@ -1234,23 +1160,12 @@ class ExperimentMarkView(SecureAdminModelView):
|
||||||
|
|
||||||
column_default_sort = [("oral_mark", False), ("protocol_mark", False)]
|
column_default_sort = [("oral_mark", False), ("protocol_mark", False)]
|
||||||
|
|
||||||
column_extra_row_actions = [
|
column_formatters = {
|
||||||
PartStudentEndpointLinkRowAction(
|
"part_student": part_student_formatter,
|
||||||
icon_class="fa fa-user",
|
"group_experiment": group_experiment_formatter,
|
||||||
endpoint="admin_part_student.details_view",
|
"assistant": assistant_formatter,
|
||||||
title="PartStudent",
|
"admin": admin_formatter,
|
||||||
),
|
}
|
||||||
GroupExperimentEndpointLinkRowAction(
|
|
||||||
icon_class="fa fa-flask",
|
|
||||||
endpoint="admin_group_experiment.details_view",
|
|
||||||
title="GroupExperiment",
|
|
||||||
),
|
|
||||||
AssistantEndpointLinkRowAction(
|
|
||||||
icon_class="fa fa-user-secret",
|
|
||||||
endpoint="admin_assistant.details_view",
|
|
||||||
title="Assistant",
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
# TODO: Find solution
|
# TODO: Find solution
|
||||||
"""
|
"""
|
||||||
|
@ -1285,12 +1200,14 @@ class ExperimentMarkView(SecureAdminModelView):
|
||||||
class ProgramView(SecureAdminModelView):
|
class ProgramView(SecureAdminModelView):
|
||||||
can_export = False
|
can_export = False
|
||||||
can_set_page_size = False
|
can_set_page_size = False
|
||||||
can_view_details = True
|
|
||||||
column_display_all_relations = True
|
column_display_all_relations = True
|
||||||
|
|
||||||
column_list = [
|
column_list = [
|
||||||
"label",
|
"label",
|
||||||
]
|
]
|
||||||
|
column_details_exclude_list = [
|
||||||
|
"groups",
|
||||||
|
]
|
||||||
column_sortable_list = []
|
column_sortable_list = []
|
||||||
form_excluded_columns = [
|
form_excluded_columns = [
|
||||||
"parts",
|
"parts",
|
||||||
|
@ -1298,6 +1215,11 @@ class ProgramView(SecureAdminModelView):
|
||||||
"groups",
|
"groups",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
column_formatters = {
|
||||||
|
"parts": part_with_semester_formatter,
|
||||||
|
"experiments": experiment_formatter,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class ImportView(SecureAdminBaseView):
|
class ImportView(SecureAdminBaseView):
|
||||||
class FileForm(FlaskForm):
|
class FileForm(FlaskForm):
|
||||||
|
|
Loading…
Reference in a new issue