mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Replace editables with form for assistants' marks
This commit is contained in:
parent
9f055d7a7e
commit
3412657ca7
1 changed files with 20 additions and 12 deletions
|
@ -1,11 +1,12 @@
|
||||||
from flask import flash
|
from flask import flash
|
||||||
from flask_admin import expose
|
from flask_admin import expose
|
||||||
from flask_security import admin_change_password, current_user
|
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 wtforms.validators import NumberRange, Optional
|
||||||
|
|
||||||
from . import assistantSpace, db
|
from . import assistantSpace, db
|
||||||
from .advlabdb_independent_funs import flashRandomPassword
|
from .advlabdb_independent_funs import flashRandomPassword, missing_formatter
|
||||||
from .customClasses import SecureAssistantBaseView, SecureAssistantModelView
|
from .customClasses import SecureAssistantBaseView, SecureAssistantModelView
|
||||||
from .exceptions import DataBaseException, ModelViewException
|
from .exceptions import DataBaseException, ModelViewException
|
||||||
from .model_dependent_funs import initActiveSemesterMenuLinks
|
from .model_dependent_funs import initActiveSemesterMenuLinks
|
||||||
|
@ -58,7 +59,20 @@ class AssistantAppointmentView(SecureAssistantModelView):
|
||||||
|
|
||||||
|
|
||||||
class AssistantExperimentMarkView(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
|
can_edit = True
|
||||||
|
column_display_actions = True
|
||||||
|
|
||||||
column_list = [
|
column_list = [
|
||||||
"oral_mark",
|
"oral_mark",
|
||||||
|
@ -99,16 +113,10 @@ class AssistantExperimentMarkView(SecureAssistantModelView):
|
||||||
"part_student.student.contact_email",
|
"part_student.student.contact_email",
|
||||||
]
|
]
|
||||||
|
|
||||||
column_editable_list = [
|
column_formatters = dict(
|
||||||
"oral_mark",
|
oral_mark=missing_formatter,
|
||||||
"protocol_mark",
|
protocol_mark=missing_formatter,
|
||||||
]
|
)
|
||||||
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_default_sort = [("oral_mark", False), ("protocol_mark", False)]
|
column_default_sort = [("oral_mark", False), ("protocol_mark", False)]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue