mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +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.independent_funs import randomPassword
|
||||||
from advlabdb.models import (
|
from advlabdb.models import (
|
||||||
MAX_MARK,
|
MAX_MARK,
|
||||||
|
MAX_YEAR,
|
||||||
MIN_MARK,
|
MIN_MARK,
|
||||||
|
MIN_YEAR,
|
||||||
Admin,
|
Admin,
|
||||||
Appointment,
|
Appointment,
|
||||||
Assistant,
|
Assistant,
|
||||||
|
@ -98,15 +100,12 @@ class UserView(SecureAdminModelView):
|
||||||
def semesterQueryFactory():
|
def semesterQueryFactory():
|
||||||
return Semester.query
|
return Semester.query
|
||||||
|
|
||||||
def activeSemesterDefault():
|
|
||||||
return userActiveSemester()
|
|
||||||
|
|
||||||
email = StringField("Email", validators=[DataRequired(), Email()])
|
email = StringField("Email", validators=[DataRequired(), Email()])
|
||||||
roles = QuerySelectMultipleField(
|
roles = QuerySelectMultipleField(
|
||||||
"Roles",
|
"Roles",
|
||||||
query_factory=roleQueryFactory,
|
query_factory=roleQueryFactory,
|
||||||
validators=[DataRequired()],
|
validators=[DataRequired()],
|
||||||
default=[Role.query.filter(Role.name == "assistant").first()],
|
default=[user_datastore.find_role("assistant")],
|
||||||
)
|
)
|
||||||
|
|
||||||
first_name = StringField("First Name", validators=[DataRequired()])
|
first_name = StringField("First Name", validators=[DataRequired()])
|
||||||
|
@ -130,7 +129,7 @@ class UserView(SecureAdminModelView):
|
||||||
query_factory=semesterQueryFactory,
|
query_factory=semesterQueryFactory,
|
||||||
allow_blank=True,
|
allow_blank=True,
|
||||||
blank_text="-",
|
blank_text="-",
|
||||||
default=activeSemesterDefault,
|
default=userActiveSemester,
|
||||||
description="Not fixed and users (including assistants) can change it.",
|
description="Not fixed and users (including assistants) can change it.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -266,21 +265,26 @@ class RoleView(SecureAdminModelView):
|
||||||
|
|
||||||
class SemesterView(SecureAdminModelView):
|
class SemesterView(SecureAdminModelView):
|
||||||
class CreateForm(Form):
|
class CreateForm(Form):
|
||||||
def labelDefault():
|
def defaultFormLabel():
|
||||||
if userActiveSemester().label == "WS":
|
if userActiveSemester().label == "WS":
|
||||||
return "SS"
|
return "SS"
|
||||||
else:
|
else:
|
||||||
return "WS"
|
return "WS"
|
||||||
|
|
||||||
def yearDefault():
|
def defaultFormYear():
|
||||||
activeSemester = userActiveSemester()
|
activeSemester = userActiveSemester()
|
||||||
if activeSemester.label == "WS":
|
if activeSemester.label == "WS":
|
||||||
return activeSemester.year + 1
|
return activeSemester.year + 1
|
||||||
else:
|
else:
|
||||||
return activeSemester.year
|
return activeSemester.year
|
||||||
|
|
||||||
label = RadioField("Semester", choices=["WS", "SS"], validators=[DataRequired()], default=labelDefault)
|
label = RadioField("Semester", choices=["WS", "SS"], validators=[DataRequired()], default=defaultFormLabel)
|
||||||
year = StringField("Year", validators=[DataRequired()], default=yearDefault)
|
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 = BooleanField(
|
||||||
"Transfer parts",
|
"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)!",
|
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 = DecimalField(
|
||||||
"Oral weighting",
|
"Oral weighting",
|
||||||
validators=[DataRequired(), NumberRange(min=0, max=1)],
|
validators=[DataRequired(), NumberRange(0, 1)],
|
||||||
default=0.5,
|
default=0.5,
|
||||||
description="Between 0 and 1",
|
description="Between 0 and 1",
|
||||||
places=2,
|
places=2,
|
||||||
|
@ -721,7 +725,7 @@ class SemesterExperimentView(SecureAdminModelView):
|
||||||
)
|
)
|
||||||
protocol_weighting = DecimalField(
|
protocol_weighting = DecimalField(
|
||||||
"Protocol weighting",
|
"Protocol weighting",
|
||||||
validators=[DataRequired(), NumberRange(min=0, max=1)],
|
validators=[DataRequired(), NumberRange(0, 1)],
|
||||||
default=0.5,
|
default=0.5,
|
||||||
description="Between 0 and 1. Oral and protocol weightings have to add to 1! Both are rounded to 2 decimal digits.",
|
description="Between 0 and 1. Oral and protocol weightings have to add to 1! Both are rounded to 2 decimal digits.",
|
||||||
places=2,
|
places=2,
|
||||||
|
@ -729,7 +733,7 @@ class SemesterExperimentView(SecureAdminModelView):
|
||||||
)
|
)
|
||||||
final_weighting = DecimalField(
|
final_weighting = DecimalField(
|
||||||
"Final weighting",
|
"Final weighting",
|
||||||
validators=[DataRequired(), NumberRange(min=0, max=1)],
|
validators=[DataRequired(), NumberRange(0, 1)],
|
||||||
default=1.0,
|
default=1.0,
|
||||||
description="Between 0 and 1",
|
description="Between 0 and 1",
|
||||||
places=2,
|
places=2,
|
||||||
|
@ -1277,12 +1281,12 @@ class ExperimentMarkView(SecureAdminModelView):
|
||||||
class EditForm(Form):
|
class EditForm(Form):
|
||||||
oral_mark = IntegerField(
|
oral_mark = IntegerField(
|
||||||
"Oral Mark",
|
"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}",
|
description=f"Between {MIN_MARK} and {MAX_MARK}",
|
||||||
)
|
)
|
||||||
protocol_mark = IntegerField(
|
protocol_mark = IntegerField(
|
||||||
"Protocol Mark",
|
"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}",
|
description=f"Between {MIN_MARK} and {MAX_MARK}",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue