mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-12 21:40:41 +00:00
Use FlaskForm
This commit is contained in:
parent
22954a1adb
commit
39a66727ee
1 changed files with 13 additions and 14 deletions
|
@ -16,7 +16,6 @@ from flask_wtf.file import FileAllowed, FileField, FileRequired
|
||||||
from matplotlib.figure import Figure
|
from matplotlib.figure import Figure
|
||||||
from sqlalchemy import and_, not_, or_, select
|
from sqlalchemy import and_, not_, or_, select
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
from wtforms import Form
|
|
||||||
from wtforms.fields import (
|
from wtforms.fields import (
|
||||||
BooleanField,
|
BooleanField,
|
||||||
DateField,
|
DateField,
|
||||||
|
@ -87,7 +86,7 @@ class UserView(SecureAdminModelView):
|
||||||
def apply(self, query, value, alias=None):
|
def apply(self, query, value, alias=None):
|
||||||
return query.where(User.active_semester_id == int(value))
|
return query.where(User.active_semester_id == int(value))
|
||||||
|
|
||||||
class CreateForm(Form):
|
class CreateForm(FlaskForm):
|
||||||
def roleQueryFactory():
|
def roleQueryFactory():
|
||||||
return Role.query
|
return Role.query
|
||||||
|
|
||||||
|
@ -247,7 +246,7 @@ class UserView(SecureAdminModelView):
|
||||||
|
|
||||||
|
|
||||||
class SemesterView(SecureAdminModelView):
|
class SemesterView(SecureAdminModelView):
|
||||||
class CreateForm(Form):
|
class CreateForm(FlaskForm):
|
||||||
def defaultFormLabel():
|
def defaultFormLabel():
|
||||||
last_semester = Semester.lastSemester()
|
last_semester = Semester.lastSemester()
|
||||||
if last_semester.label == "WS":
|
if last_semester.label == "WS":
|
||||||
|
@ -456,7 +455,7 @@ class PartStudentView(SecureAdminModelView):
|
||||||
def customId(self, row):
|
def customId(self, row):
|
||||||
return row.part_id
|
return row.part_id
|
||||||
|
|
||||||
class CreateForm(Form):
|
class CreateForm(FlaskForm):
|
||||||
def studentQueryFactory():
|
def studentQueryFactory():
|
||||||
return Student.query
|
return Student.query
|
||||||
|
|
||||||
|
@ -556,7 +555,7 @@ class GroupView(SecureAdminModelView):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
class CustomForm(Form):
|
class CustomForm(FlaskForm):
|
||||||
part_students = QuerySelectMultipleField(
|
part_students = QuerySelectMultipleField(
|
||||||
"Part Students",
|
"Part Students",
|
||||||
query_factory=query_factory,
|
query_factory=query_factory,
|
||||||
|
@ -674,7 +673,7 @@ class SemesterExperimentView(SecureAdminModelView):
|
||||||
def customId(self, row):
|
def customId(self, row):
|
||||||
return row.experiment_id
|
return row.experiment_id
|
||||||
|
|
||||||
class CreateForm(Form):
|
class CreateForm(FlaskForm):
|
||||||
def experimentQueryFactory():
|
def experimentQueryFactory():
|
||||||
return Experiment.query.where(Experiment.active == True)
|
return Experiment.query.where(Experiment.active == True)
|
||||||
|
|
||||||
|
@ -942,10 +941,10 @@ class GroupExperimentView(SecureAdminModelView):
|
||||||
def customId(self, row):
|
def customId(self, row):
|
||||||
return row.semester_experiment_id
|
return row.semester_experiment_id
|
||||||
|
|
||||||
class EditForm(Form):
|
class EditForm(FlaskForm):
|
||||||
note = group_experiment_note_field()
|
note = group_experiment_note_field()
|
||||||
|
|
||||||
class CreateForm(Form):
|
class CreateForm(FlaskForm):
|
||||||
group = QuerySelectField(
|
group = QuerySelectField(
|
||||||
"Group",
|
"Group",
|
||||||
query_factory=groupQueryFactory,
|
query_factory=groupQueryFactory,
|
||||||
|
@ -1051,7 +1050,7 @@ class AppointmentView(SecureAdminModelView):
|
||||||
def customId(self, row):
|
def customId(self, row):
|
||||||
return row.assistant_id
|
return row.assistant_id
|
||||||
|
|
||||||
class CreateAndEditForm(Form):
|
class CreateAndEditForm(FlaskForm):
|
||||||
group_experiment = QuerySelectField(
|
group_experiment = QuerySelectField(
|
||||||
"Group Experiment",
|
"Group Experiment",
|
||||||
query_factory=groupExperimentQueryFactory,
|
query_factory=groupExperimentQueryFactory,
|
||||||
|
@ -1186,7 +1185,7 @@ class ExperimentMarkView(SecureAdminModelView):
|
||||||
def customId(self, row):
|
def customId(self, row):
|
||||||
return row.assistant_id
|
return row.assistant_id
|
||||||
|
|
||||||
class CreateForm(Form):
|
class CreateForm(FlaskForm):
|
||||||
part_student = QuerySelectField(
|
part_student = QuerySelectField(
|
||||||
"Part Student",
|
"Part Student",
|
||||||
query_factory=partStudentQueryFactory,
|
query_factory=partStudentQueryFactory,
|
||||||
|
@ -1202,7 +1201,7 @@ class ExperimentMarkView(SecureAdminModelView):
|
||||||
blank_text="-",
|
blank_text="-",
|
||||||
)
|
)
|
||||||
|
|
||||||
class EditForm(Form):
|
class EditForm(FlaskForm):
|
||||||
oral_mark = mark_field("Oral")
|
oral_mark = mark_field("Oral")
|
||||||
protocol_mark = mark_field("Protocol")
|
protocol_mark = mark_field("Protocol")
|
||||||
|
|
||||||
|
@ -1307,7 +1306,7 @@ class ImportView(SecureAdminBaseView):
|
||||||
label="Upload and import",
|
label="Upload and import",
|
||||||
)
|
)
|
||||||
|
|
||||||
@expose(methods=("GET", "POST"))
|
@expose("/", methods=("GET", "POST"))
|
||||||
def index(self):
|
def index(self):
|
||||||
form = ImportView.FileForm()
|
form = ImportView.FileForm()
|
||||||
|
|
||||||
|
@ -1337,7 +1336,7 @@ class ActionsView(SecureAdminBaseView):
|
||||||
label="Manually update final experiment and part marks",
|
label="Manually update final experiment and part marks",
|
||||||
)
|
)
|
||||||
|
|
||||||
@expose(methods=("GET", "POST"))
|
@expose("/", methods=("GET", "POST"))
|
||||||
def index(self):
|
def index(self):
|
||||||
form = ActionsView.ActionsForm()
|
form = ActionsView.ActionsForm()
|
||||||
|
|
||||||
|
@ -1433,7 +1432,7 @@ class AnalysisView(SecureAdminBaseView):
|
||||||
|
|
||||||
return np.array(data)
|
return np.array(data)
|
||||||
|
|
||||||
@expose(methods=("GET", "POST"))
|
@expose("/", methods=("GET", "POST"))
|
||||||
def index(self):
|
def index(self):
|
||||||
form = AnalysisView.AnalysisForm()
|
form = AnalysisView.AnalysisForm()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue