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

Use FlaskForm

This commit is contained in:
Mo 2022-06-20 00:39:31 +02:00
parent 22954a1adb
commit 39a66727ee

View file

@ -16,7 +16,6 @@ from flask_wtf.file import FileAllowed, FileField, FileRequired
from matplotlib.figure import Figure
from sqlalchemy import and_, not_, or_, select
from werkzeug.utils import secure_filename
from wtforms import Form
from wtforms.fields import (
BooleanField,
DateField,
@ -87,7 +86,7 @@ class UserView(SecureAdminModelView):
def apply(self, query, value, alias=None):
return query.where(User.active_semester_id == int(value))
class CreateForm(Form):
class CreateForm(FlaskForm):
def roleQueryFactory():
return Role.query
@ -247,7 +246,7 @@ class UserView(SecureAdminModelView):
class SemesterView(SecureAdminModelView):
class CreateForm(Form):
class CreateForm(FlaskForm):
def defaultFormLabel():
last_semester = Semester.lastSemester()
if last_semester.label == "WS":
@ -456,7 +455,7 @@ class PartStudentView(SecureAdminModelView):
def customId(self, row):
return row.part_id
class CreateForm(Form):
class CreateForm(FlaskForm):
def studentQueryFactory():
return Student.query
@ -556,7 +555,7 @@ class GroupView(SecureAdminModelView):
)
)
class CustomForm(Form):
class CustomForm(FlaskForm):
part_students = QuerySelectMultipleField(
"Part Students",
query_factory=query_factory,
@ -674,7 +673,7 @@ class SemesterExperimentView(SecureAdminModelView):
def customId(self, row):
return row.experiment_id
class CreateForm(Form):
class CreateForm(FlaskForm):
def experimentQueryFactory():
return Experiment.query.where(Experiment.active == True)
@ -942,10 +941,10 @@ class GroupExperimentView(SecureAdminModelView):
def customId(self, row):
return row.semester_experiment_id
class EditForm(Form):
class EditForm(FlaskForm):
note = group_experiment_note_field()
class CreateForm(Form):
class CreateForm(FlaskForm):
group = QuerySelectField(
"Group",
query_factory=groupQueryFactory,
@ -1051,7 +1050,7 @@ class AppointmentView(SecureAdminModelView):
def customId(self, row):
return row.assistant_id
class CreateAndEditForm(Form):
class CreateAndEditForm(FlaskForm):
group_experiment = QuerySelectField(
"Group Experiment",
query_factory=groupExperimentQueryFactory,
@ -1186,7 +1185,7 @@ class ExperimentMarkView(SecureAdminModelView):
def customId(self, row):
return row.assistant_id
class CreateForm(Form):
class CreateForm(FlaskForm):
part_student = QuerySelectField(
"Part Student",
query_factory=partStudentQueryFactory,
@ -1202,7 +1201,7 @@ class ExperimentMarkView(SecureAdminModelView):
blank_text="-",
)
class EditForm(Form):
class EditForm(FlaskForm):
oral_mark = mark_field("Oral")
protocol_mark = mark_field("Protocol")
@ -1307,7 +1306,7 @@ class ImportView(SecureAdminBaseView):
label="Upload and import",
)
@expose(methods=("GET", "POST"))
@expose("/", methods=("GET", "POST"))
def index(self):
form = ImportView.FileForm()
@ -1337,7 +1336,7 @@ class ActionsView(SecureAdminBaseView):
label="Manually update final experiment and part marks",
)
@expose(methods=("GET", "POST"))
@expose("/", methods=("GET", "POST"))
def index(self):
form = ActionsView.ActionsForm()
@ -1433,7 +1432,7 @@ class AnalysisView(SecureAdminBaseView):
return np.array(data)
@expose(methods=("GET", "POST"))
@expose("/", methods=("GET", "POST"))
def index(self):
form = AnalysisView.AnalysisForm()