1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-11-08 21:21:06 +00:00

Replace editables with form for assistants' marks

This commit is contained in:
Mo 2022-06-01 23:03:41 +02:00
parent 9f055d7a7e
commit 3412657ca7

View file

@ -1,11 +1,12 @@
from flask import flash
from flask_admin import expose
from flask_security import admin_change_password, current_user
from wtforms import BooleanField, Form, StringField
from wtforms import Form
from wtforms.fields import BooleanField, IntegerField, StringField
from wtforms.validators import NumberRange, Optional
from . import assistantSpace, db
from .advlabdb_independent_funs import flashRandomPassword
from .advlabdb_independent_funs import flashRandomPassword, missing_formatter
from .customClasses import SecureAssistantBaseView, SecureAssistantModelView
from .exceptions import DataBaseException, ModelViewException
from .model_dependent_funs import initActiveSemesterMenuLinks
@ -58,7 +59,20 @@ class AssistantAppointmentView(SecureAssistantModelView):
class AssistantExperimentMarkView(SecureAssistantModelView):
class EditForm(Form):
oral_mark = IntegerField(
"Oral Mark",
validators=[Optional(), NumberRange(MIN_MARK, MAX_MARK)],
description=f"Between {MIN_MARK} and {MAX_MARK}",
)
protocol_mark = IntegerField(
"Protocol Mark",
validators=[Optional(), NumberRange(MIN_MARK, MAX_MARK)],
description=f"Between {MIN_MARK} and {MAX_MARK}",
)
can_edit = True
column_display_actions = True
column_list = [
"oral_mark",
@ -99,16 +113,10 @@ class AssistantExperimentMarkView(SecureAssistantModelView):
"part_student.student.contact_email",
]
column_editable_list = [
"oral_mark",
"protocol_mark",
]
form_columns = column_editable_list
form_args = {
"oral_mark": {"validators": [Optional(), NumberRange(MIN_MARK, MAX_MARK)]},
"protocol_mark": {"validators": [Optional(), NumberRange(MIN_MARK, MAX_MARK)]},
}
column_formatters = dict(
oral_mark=missing_formatter,
protocol_mark=missing_formatter,
)
column_default_sort = [("oral_mark", False), ("protocol_mark", False)]