mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Format and make one default callable
This commit is contained in:
parent
f89059f4ac
commit
06a782ef66
1 changed files with 75 additions and 19 deletions
|
@ -92,20 +92,40 @@ class UserView(SecureAdminModelView):
|
||||||
def semesterQueryFactory():
|
def semesterQueryFactory():
|
||||||
return Semester.query
|
return Semester.query
|
||||||
|
|
||||||
email = StringField("Email", validators=[DataRequired(), Email()])
|
def default_roles():
|
||||||
|
return [user_datastore.find_role("assistant")]
|
||||||
|
|
||||||
|
email = StringField(
|
||||||
|
"Email",
|
||||||
|
validators=[DataRequired(), Email()],
|
||||||
|
)
|
||||||
roles = QuerySelectMultipleField(
|
roles = QuerySelectMultipleField(
|
||||||
"Roles",
|
"Roles",
|
||||||
query_factory=roleQueryFactory,
|
query_factory=roleQueryFactory,
|
||||||
validators=[DataRequired()],
|
validators=[DataRequired()],
|
||||||
default=[user_datastore.find_role("assistant")],
|
default=default_roles,
|
||||||
)
|
)
|
||||||
|
|
||||||
first_name = StringField("First Name", validators=[DataRequired()])
|
first_name = StringField(
|
||||||
last_name = StringField("Last Name", validators=[DataRequired()])
|
"First Name",
|
||||||
phone_number = StringField("Phone Number")
|
validators=[DataRequired()],
|
||||||
mobile_phone_number = StringField("Mobile Phone Number")
|
)
|
||||||
building = StringField("Building")
|
last_name = StringField(
|
||||||
room = StringField("Room")
|
"Last Name",
|
||||||
|
validators=[DataRequired()],
|
||||||
|
)
|
||||||
|
phone_number = StringField(
|
||||||
|
"Phone Number",
|
||||||
|
)
|
||||||
|
mobile_phone_number = StringField(
|
||||||
|
"Mobile Phone Number",
|
||||||
|
)
|
||||||
|
building = StringField(
|
||||||
|
"Building",
|
||||||
|
)
|
||||||
|
room = StringField(
|
||||||
|
"Room",
|
||||||
|
)
|
||||||
|
|
||||||
semester_experiments = QuerySelectMultipleField(
|
semester_experiments = QuerySelectMultipleField(
|
||||||
"Semester Experiments",
|
"Semester Experiments",
|
||||||
|
@ -115,7 +135,10 @@ class UserView(SecureAdminModelView):
|
||||||
description="Only needed if the user has the assistant role",
|
description="Only needed if the user has the assistant role",
|
||||||
)
|
)
|
||||||
|
|
||||||
active = BooleanField("Active", default=True)
|
active = BooleanField(
|
||||||
|
"Active",
|
||||||
|
default=True,
|
||||||
|
)
|
||||||
active_semester = QuerySelectField(
|
active_semester = QuerySelectField(
|
||||||
"Active Semester",
|
"Active Semester",
|
||||||
query_factory=semesterQueryFactory,
|
query_factory=semesterQueryFactory,
|
||||||
|
@ -128,7 +151,10 @@ class UserView(SecureAdminModelView):
|
||||||
class EditForm(CreateForm):
|
class EditForm(CreateForm):
|
||||||
semester_experiments = None
|
semester_experiments = None
|
||||||
|
|
||||||
generate_new_password = BooleanField("Generate new random password", default=False)
|
generate_new_password = BooleanField(
|
||||||
|
"Generate new random password",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
can_view_details = True
|
can_view_details = True
|
||||||
|
|
||||||
|
@ -267,7 +293,12 @@ class SemesterView(SecureAdminModelView):
|
||||||
else:
|
else:
|
||||||
return activeSemester.year
|
return activeSemester.year
|
||||||
|
|
||||||
label = RadioField("Semester", choices=["WS", "SS"], validators=[DataRequired()], default=defaultFormLabel)
|
label = RadioField(
|
||||||
|
"Semester",
|
||||||
|
choices=["WS", "SS"],
|
||||||
|
validators=[DataRequired()],
|
||||||
|
default=defaultFormLabel,
|
||||||
|
)
|
||||||
year = IntegerField(
|
year = IntegerField(
|
||||||
"Year",
|
"Year",
|
||||||
validators=[DataRequired(), NumberRange(MIN_YEAR, MAX_YEAR)],
|
validators=[DataRequired(), NumberRange(MIN_YEAR, MAX_YEAR)],
|
||||||
|
@ -359,7 +390,11 @@ class PartView(SecureAdminModelView):
|
||||||
|
|
||||||
form_extra_fields = {
|
form_extra_fields = {
|
||||||
"program": QuerySelectField(
|
"program": QuerySelectField(
|
||||||
"Program", query_factory=programQueryFactory, validators=[DataRequired()], allow_blank=True, blank_text="-"
|
"Program",
|
||||||
|
query_factory=programQueryFactory,
|
||||||
|
validators=[DataRequired()],
|
||||||
|
allow_blank=True,
|
||||||
|
blank_text="-",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
form_args = {
|
form_args = {
|
||||||
|
@ -651,7 +686,11 @@ class ExperimentView(SecureAdminModelView):
|
||||||
}
|
}
|
||||||
form_extra_fields = {
|
form_extra_fields = {
|
||||||
"program": QuerySelectField(
|
"program": QuerySelectField(
|
||||||
"Program", query_factory=programQueryFactory, validators=[DataRequired()], allow_blank=True, blank_text="-"
|
"Program",
|
||||||
|
query_factory=programQueryFactory,
|
||||||
|
validators=[DataRequired()],
|
||||||
|
allow_blank=True,
|
||||||
|
blank_text="-",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,7 +745,10 @@ class SemesterExperimentView(SecureAdminModelView):
|
||||||
widget=NumberInput(step=0.01),
|
widget=NumberInput(step=0.01),
|
||||||
)
|
)
|
||||||
|
|
||||||
assistants = QuerySelectMultipleField("Assistants", query_factory=assistantQueryFactory)
|
assistants = QuerySelectMultipleField(
|
||||||
|
"Assistants",
|
||||||
|
query_factory=assistantQueryFactory,
|
||||||
|
)
|
||||||
|
|
||||||
class EditForm(CreateForm):
|
class EditForm(CreateForm):
|
||||||
experiment = None
|
experiment = None
|
||||||
|
@ -917,7 +959,10 @@ class GroupExperimentView(SecureAdminModelView):
|
||||||
validators=[Optional()],
|
validators=[Optional()],
|
||||||
description="Set if you already want to add an appointment. Otherwise, leave it blank and you can do it later under the Appointment tab.",
|
description="Set if you already want to add an appointment. Otherwise, leave it blank and you can do it later under the Appointment tab.",
|
||||||
)
|
)
|
||||||
appointment1_special = BooleanField("Appointment-1 Special", default=False)
|
appointment1_special = BooleanField(
|
||||||
|
"Appointment-1 Special",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
appointment1_assistant = QuerySelectField(
|
appointment1_assistant = QuerySelectField(
|
||||||
"Appointment-1 Assistant",
|
"Appointment-1 Assistant",
|
||||||
query_factory=assistantQueryFactory,
|
query_factory=assistantQueryFactory,
|
||||||
|
@ -926,9 +971,14 @@ class GroupExperimentView(SecureAdminModelView):
|
||||||
)
|
)
|
||||||
|
|
||||||
appointment2_date = DateField(
|
appointment2_date = DateField(
|
||||||
"Appointment-2 Date", validators=[Optional()], description="Add a second appointment (see above)."
|
"Appointment-2 Date",
|
||||||
|
validators=[Optional()],
|
||||||
|
description="Add a second appointment (see above).",
|
||||||
|
)
|
||||||
|
appointment2_special = BooleanField(
|
||||||
|
"Appointment-2 Special",
|
||||||
|
default=False,
|
||||||
)
|
)
|
||||||
appointment2_special = BooleanField("Appointment-2 Special", default=False)
|
|
||||||
appointment2_assistant = QuerySelectField(
|
appointment2_assistant = QuerySelectField(
|
||||||
"Appointment-2 Assistant",
|
"Appointment-2 Assistant",
|
||||||
query_factory=assistantQueryFactory,
|
query_factory=assistantQueryFactory,
|
||||||
|
@ -1046,8 +1096,14 @@ class AppointmentView(SecureAdminModelView):
|
||||||
allow_blank=True,
|
allow_blank=True,
|
||||||
blank_text="-",
|
blank_text="-",
|
||||||
)
|
)
|
||||||
date = DateField("Date", validators=[DataRequired()])
|
date = DateField(
|
||||||
special = BooleanField("Special", default=False)
|
"Date",
|
||||||
|
validators=[DataRequired()],
|
||||||
|
)
|
||||||
|
special = BooleanField(
|
||||||
|
"Special",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
assistant = QuerySelectField(
|
assistant = QuerySelectField(
|
||||||
"Assistant",
|
"Assistant",
|
||||||
query_factory=assistantQueryFactory,
|
query_factory=assistantQueryFactory,
|
||||||
|
|
Loading…
Reference in a new issue