1
0
Fork 0
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:
Mo 2022-05-07 21:05:16 +02:00
parent f89059f4ac
commit 06a782ef66

View file

@ -92,20 +92,40 @@ class UserView(SecureAdminModelView):
def semesterQueryFactory():
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",
query_factory=roleQueryFactory,
validators=[DataRequired()],
default=[user_datastore.find_role("assistant")],
default=default_roles,
)
first_name = StringField("First Name", validators=[DataRequired()])
last_name = StringField("Last Name", validators=[DataRequired()])
phone_number = StringField("Phone Number")
mobile_phone_number = StringField("Mobile Phone Number")
building = StringField("Building")
room = StringField("Room")
first_name = StringField(
"First Name",
validators=[DataRequired()],
)
last_name = StringField(
"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",
@ -115,7 +135,10 @@ class UserView(SecureAdminModelView):
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",
query_factory=semesterQueryFactory,
@ -128,7 +151,10 @@ class UserView(SecureAdminModelView):
class EditForm(CreateForm):
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
@ -267,7 +293,12 @@ class SemesterView(SecureAdminModelView):
else:
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",
validators=[DataRequired(), NumberRange(MIN_YEAR, MAX_YEAR)],
@ -359,7 +390,11 @@ class PartView(SecureAdminModelView):
form_extra_fields = {
"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 = {
@ -651,7 +686,11 @@ class ExperimentView(SecureAdminModelView):
}
form_extra_fields = {
"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),
)
assistants = QuerySelectMultipleField("Assistants", query_factory=assistantQueryFactory)
assistants = QuerySelectMultipleField(
"Assistants",
query_factory=assistantQueryFactory,
)
class EditForm(CreateForm):
experiment = None
@ -917,7 +959,10 @@ class GroupExperimentView(SecureAdminModelView):
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.",
)
appointment1_special = BooleanField("Appointment-1 Special", default=False)
appointment1_special = BooleanField(
"Appointment-1 Special",
default=False,
)
appointment1_assistant = QuerySelectField(
"Appointment-1 Assistant",
query_factory=assistantQueryFactory,
@ -926,9 +971,14 @@ class GroupExperimentView(SecureAdminModelView):
)
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(
"Appointment-2 Assistant",
query_factory=assistantQueryFactory,
@ -1046,8 +1096,14 @@ class AppointmentView(SecureAdminModelView):
allow_blank=True,
blank_text="-",
)
date = DateField("Date", validators=[DataRequired()])
special = BooleanField("Special", default=False)
date = DateField(
"Date",
validators=[DataRequired()],
)
special = BooleanField(
"Special",
default=False,
)
assistant = QuerySelectField(
"Assistant",
query_factory=assistantQueryFactory,