mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Added some editables
This commit is contained in:
parent
85606123a5
commit
c0ffa136f7
1 changed files with 19 additions and 6 deletions
|
@ -8,7 +8,7 @@ from flask_security import admin_change_password, current_user, hash_password
|
||||||
from sqlalchemy import func, or_
|
from sqlalchemy import func, or_
|
||||||
from wtforms import BooleanField, Form, RadioField, SelectField, TextField
|
from wtforms import BooleanField, Form, RadioField, SelectField, TextField
|
||||||
from wtforms.fields.html5 import DateField
|
from wtforms.fields.html5 import DateField
|
||||||
from wtforms.validators import URL, DataRequired, Email, Optional
|
from wtforms.validators import URL, DataRequired, Email, Optional, NumberRange
|
||||||
|
|
||||||
from advlabdb import adminSpace, app, db, user_datastore
|
from advlabdb import adminSpace, app, db, user_datastore
|
||||||
from advlabdb.configUtils import getConfig
|
from advlabdb.configUtils import getConfig
|
||||||
|
@ -559,6 +559,7 @@ class AppointmentView(SecureAdminModelView):
|
||||||
"group_experiment.semester_experiment.experiment",
|
"group_experiment.semester_experiment.experiment",
|
||||||
"assistant",
|
"assistant",
|
||||||
]
|
]
|
||||||
|
column_editable_list = ["date", "special"]
|
||||||
|
|
||||||
def queryFilter(self):
|
def queryFilter(self):
|
||||||
return Appointment.group_experiment.has(
|
return Appointment.group_experiment.has(
|
||||||
|
@ -572,6 +573,11 @@ class AppointmentView(SecureAdminModelView):
|
||||||
|
|
||||||
def update_model(self, form, model):
|
def update_model(self, form, model):
|
||||||
try:
|
try:
|
||||||
|
if not form.date:
|
||||||
|
model.customUpdateSpecial(form.special.data)
|
||||||
|
elif not form.special:
|
||||||
|
model.customUpdateDate(form.date.data)
|
||||||
|
else:
|
||||||
model.customUpdate(form.date.data, form.special.data, form.assistant.data, form.group_experiment.data)
|
model.customUpdate(form.date.data, form.special.data, form.assistant.data, form.group_experiment.data)
|
||||||
|
|
||||||
self.on_model_change(form, model, False)
|
self.on_model_change(form, model, False)
|
||||||
|
@ -580,7 +586,6 @@ class AppointmentView(SecureAdminModelView):
|
||||||
flash(str(ex), "error")
|
flash(str(ex), "error")
|
||||||
|
|
||||||
self.session.rollback()
|
self.session.rollback()
|
||||||
|
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
self.after_model_change(form, model, False)
|
self.after_model_change(form, model, False)
|
||||||
|
@ -622,25 +627,33 @@ class ExperimentMarkView(SecureAdminModelView):
|
||||||
|
|
||||||
form = CreateForm
|
form = CreateForm
|
||||||
|
|
||||||
|
column_editable_list = ["oral_mark", "protocol_mark"]
|
||||||
|
form_args = {
|
||||||
|
"oral_mark": {"validators": [NumberRange(0, 15)]},
|
||||||
|
"protocol_mark": {"validators": [NumberRange(0, 15)]},
|
||||||
|
}
|
||||||
|
|
||||||
column_filters = [
|
column_filters = [
|
||||||
StudentIdFilter(PartStudent.id, "Student / ID"),
|
StudentIdFilter(PartStudent.id, "Student / ID"),
|
||||||
"part_student.student",
|
"part_student.student",
|
||||||
|
"group_experiment.group",
|
||||||
"group_experiment.semester_experiment.semester",
|
"group_experiment.semester_experiment.semester",
|
||||||
"group_experiment.semester_experiment.experiment",
|
"group_experiment.semester_experiment.experiment",
|
||||||
"assistant",
|
"assistant",
|
||||||
"edited_by_admin",
|
"edited_by_admin",
|
||||||
]
|
]
|
||||||
|
column_default_sort = [("oral_mark", False), ("protocol_mark", False)]
|
||||||
|
|
||||||
def queryFilter(self=None):
|
def queryFilter(self):
|
||||||
return ExperimentMark.group_experiment.has(
|
return ExperimentMark.group_experiment.has(
|
||||||
GroupExperiment.semester_experiment.has(SemesterExperiment.semester == userActiveSemester())
|
GroupExperiment.semester_experiment.has(SemesterExperiment.semester == userActiveSemester())
|
||||||
)
|
)
|
||||||
|
|
||||||
def checkForm(form):
|
def checkForm(form):
|
||||||
if form.oral_mark.data == -1:
|
if form.oral_mark and form.oral_mark.data == -1:
|
||||||
form.oral_mark.data = None
|
form.oral_mark.data = None
|
||||||
|
|
||||||
if form.protocol_mark.data == -1:
|
if form.protocol_mark and form.protocol_mark.data == -1:
|
||||||
form.protocol_mark.data = None
|
form.protocol_mark.data = None
|
||||||
|
|
||||||
return form
|
return form
|
||||||
|
|
Loading…
Reference in a new issue