mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Change year to IntegerField
This commit is contained in:
parent
8ab38f11e2
commit
f5d6e29664
1 changed files with 18 additions and 14 deletions
|
@ -49,7 +49,9 @@ from advlabdb.exceptions import DataBaseException, ModelViewException
|
|||
from advlabdb.independent_funs import randomPassword
|
||||
from advlabdb.models import (
|
||||
MAX_MARK,
|
||||
MAX_YEAR,
|
||||
MIN_MARK,
|
||||
MIN_YEAR,
|
||||
Admin,
|
||||
Appointment,
|
||||
Assistant,
|
||||
|
@ -98,15 +100,12 @@ class UserView(SecureAdminModelView):
|
|||
def semesterQueryFactory():
|
||||
return Semester.query
|
||||
|
||||
def activeSemesterDefault():
|
||||
return userActiveSemester()
|
||||
|
||||
email = StringField("Email", validators=[DataRequired(), Email()])
|
||||
roles = QuerySelectMultipleField(
|
||||
"Roles",
|
||||
query_factory=roleQueryFactory,
|
||||
validators=[DataRequired()],
|
||||
default=[Role.query.filter(Role.name == "assistant").first()],
|
||||
default=[user_datastore.find_role("assistant")],
|
||||
)
|
||||
|
||||
first_name = StringField("First Name", validators=[DataRequired()])
|
||||
|
@ -130,7 +129,7 @@ class UserView(SecureAdminModelView):
|
|||
query_factory=semesterQueryFactory,
|
||||
allow_blank=True,
|
||||
blank_text="-",
|
||||
default=activeSemesterDefault,
|
||||
default=userActiveSemester,
|
||||
description="Not fixed and users (including assistants) can change it.",
|
||||
)
|
||||
|
||||
|
@ -266,21 +265,26 @@ class RoleView(SecureAdminModelView):
|
|||
|
||||
class SemesterView(SecureAdminModelView):
|
||||
class CreateForm(Form):
|
||||
def labelDefault():
|
||||
def defaultFormLabel():
|
||||
if userActiveSemester().label == "WS":
|
||||
return "SS"
|
||||
else:
|
||||
return "WS"
|
||||
|
||||
def yearDefault():
|
||||
def defaultFormYear():
|
||||
activeSemester = userActiveSemester()
|
||||
if activeSemester.label == "WS":
|
||||
return activeSemester.year + 1
|
||||
else:
|
||||
return activeSemester.year
|
||||
|
||||
label = RadioField("Semester", choices=["WS", "SS"], validators=[DataRequired()], default=labelDefault)
|
||||
year = StringField("Year", validators=[DataRequired()], default=yearDefault)
|
||||
label = RadioField("Semester", choices=["WS", "SS"], validators=[DataRequired()], default=defaultFormLabel)
|
||||
year = IntegerField(
|
||||
"Year",
|
||||
validators=[DataRequired(), NumberRange(MIN_YEAR, MAX_YEAR)],
|
||||
default=defaultFormYear,
|
||||
description=f"Between {MIN_YEAR} and {MAX_YEAR}",
|
||||
)
|
||||
transfer_parts = BooleanField(
|
||||
"Transfer parts",
|
||||
description="This option transfers the parts you have in your current active semester. Make sure that your semester is the last semester before creating a new one (recommended)!",
|
||||
|
@ -713,7 +717,7 @@ class SemesterExperimentView(SecureAdminModelView):
|
|||
|
||||
oral_weighting = DecimalField(
|
||||
"Oral weighting",
|
||||
validators=[DataRequired(), NumberRange(min=0, max=1)],
|
||||
validators=[DataRequired(), NumberRange(0, 1)],
|
||||
default=0.5,
|
||||
description="Between 0 and 1",
|
||||
places=2,
|
||||
|
@ -721,7 +725,7 @@ class SemesterExperimentView(SecureAdminModelView):
|
|||
)
|
||||
protocol_weighting = DecimalField(
|
||||
"Protocol weighting",
|
||||
validators=[DataRequired(), NumberRange(min=0, max=1)],
|
||||
validators=[DataRequired(), NumberRange(0, 1)],
|
||||
default=0.5,
|
||||
description="Between 0 and 1. Oral and protocol weightings have to add to 1! Both are rounded to 2 decimal digits.",
|
||||
places=2,
|
||||
|
@ -729,7 +733,7 @@ class SemesterExperimentView(SecureAdminModelView):
|
|||
)
|
||||
final_weighting = DecimalField(
|
||||
"Final weighting",
|
||||
validators=[DataRequired(), NumberRange(min=0, max=1)],
|
||||
validators=[DataRequired(), NumberRange(0, 1)],
|
||||
default=1.0,
|
||||
description="Between 0 and 1",
|
||||
places=2,
|
||||
|
@ -1277,12 +1281,12 @@ class ExperimentMarkView(SecureAdminModelView):
|
|||
class EditForm(Form):
|
||||
oral_mark = IntegerField(
|
||||
"Oral Mark",
|
||||
validators=[NumberRange(min=MIN_MARK, max=MAX_MARK), Optional()],
|
||||
validators=[Optional(), NumberRange(MIN_MARK, MAX_MARK)],
|
||||
description=f"Between {MIN_MARK} and {MAX_MARK}",
|
||||
)
|
||||
protocol_mark = IntegerField(
|
||||
"Protocol Mark",
|
||||
validators=[NumberRange(min=MIN_MARK, max=MAX_MARK), Optional()],
|
||||
validators=[Optional(), NumberRange(MIN_MARK, MAX_MARK)],
|
||||
description=f"Between {MIN_MARK} and {MAX_MARK}",
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue