mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-09-17 18:31:15 +00:00
Try to set last semester as active if current semester is done
This commit is contained in:
parent
c35e2507e1
commit
ce3de0f6de
1 changed files with 17 additions and 10 deletions
|
@ -42,17 +42,24 @@ assistantSpace = FlaskAdmin(
|
|||
|
||||
class AssistantGroupExperimentView(SecureAssistantModelView):
|
||||
def is_accessible(self):
|
||||
active_semester = current_user.active_semester
|
||||
if active_semester.done:
|
||||
flash(
|
||||
Markup(
|
||||
f"Active semester {active_semester} is marked as done. Therefore, you are not allowed to view or edit any marks in this semester. You should change your active semester in <a href='{ user_settings_url() }'>user settings</a>."
|
||||
),
|
||||
"danger",
|
||||
)
|
||||
if not super().is_accessible():
|
||||
return False
|
||||
|
||||
return super().is_accessible()
|
||||
active_semester = current_user.active_semester
|
||||
|
||||
if active_semester.done:
|
||||
semester_changed = current_user.set_last_semester_as_active()
|
||||
|
||||
if not semester_changed:
|
||||
flash(
|
||||
Markup(
|
||||
f"Active semester {active_semester} is marked as done. Therefore, you are not allowed to view or edit any marks in this semester. You should change your active semester in <a href='{ user_settings_url() }'>user settings</a> if possible."
|
||||
),
|
||||
"danger",
|
||||
)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
column_display_actions = True
|
||||
|
||||
|
@ -211,7 +218,7 @@ class AssistantUserView(SecureAssistantModelView):
|
|||
query_factory=semesterQueryFactory,
|
||||
validators=[DataRequired()],
|
||||
default=Semester.lastSemester,
|
||||
description="You should change the active semester to the last semester. Do not forget to click save!",
|
||||
description="You should change the active semester to the last semester. Do not forget to click save! Only last two semesters are shown that are not marked as done.",
|
||||
)
|
||||
|
||||
phone_number, mobile_phone_number, building, room = user_info_fields()
|
||||
|
|
Loading…
Reference in a new issue