diff --git a/advlabdb/assistantModelViews.py b/advlabdb/assistantModelViews.py index 4b59d3e..cd9f26e 100644 --- a/advlabdb/assistantModelViews.py +++ b/advlabdb/assistantModelViews.py @@ -29,14 +29,6 @@ from advlabdb.utils import initActiveSemesterMenuLinks, userActiveSemester class AssistantAppointmentView(SecureAssistantModelView): - can_export = False - can_set_page_size = False - - can_create = False - can_delete = False - can_edit = False - column_display_actions = False - column_list = [ "date", "special", @@ -50,7 +42,9 @@ class AssistantAppointmentView(SecureAssistantModelView): "group_experiment.group.part_students": "Students", } - column_editable_list = ["date"] + column_editable_list = [ + "date", + ] def queryFilter(self): return and_( @@ -62,14 +56,6 @@ class AssistantAppointmentView(SecureAssistantModelView): class AssistantExperimentMarkView(SecureAssistantModelView): - can_export = False - can_set_page_size = False - - can_create = False - can_delete = False - can_edit = False - column_display_actions = False - column_list = [ "oral_mark", "protocol_mark", @@ -102,7 +88,10 @@ class AssistantExperimentMarkView(SecureAssistantModelView): "edited_by_admin": "If the mark was edited by an admin", } - column_editable_list = ["oral_mark", "protocol_mark"] + column_editable_list = [ + "oral_mark", + "protocol_mark", + ] form_args = { "oral_mark": {"validators": [NumberRange(0, 15)]}, "protocol_mark": {"validators": [NumberRange(0, 15)]}, @@ -136,11 +125,38 @@ class AssistantExperimentMarkView(SecureAssistantModelView): return True +class AssistantUserView(SecureAssistantModelView): + column_sortable_list = [] + + column_list = [ + "email", + "phone_number", + "mobile_phone_number", + "room", + "building", + "assistant.semester_experiments", + ] + column_labels = { + "assistant.semester_experiments": "Semester Experiments", + } + + column_editable_list = [ + "phone_number", + "mobile_phone_number", + "room", + "building", + ] + + def queryFilter(self): + return User.id == current_user.id + + assistantSpace.add_view( AssistantAppointmentView(Appointment, db.session, endpoint="assistant_appointment", url="appointment") ) assistantSpace.add_view( AssistantExperimentMarkView(ExperimentMark, db.session, endpoint="assistant_experimentmark", url="experimentmark") ) +assistantSpace.add_view(AssistantUserView(User, db.session, endpoint="assistant_user", url="user")) initActiveSemesterMenuLinks(assistantSpace)