mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Fixed markChoices and queryFilter
This commit is contained in:
parent
64165218ca
commit
3024d2661e
1 changed files with 46 additions and 20 deletions
|
@ -186,7 +186,7 @@ class PartView(SecureModelView):
|
||||||
form_columns = ["label", "semester"]
|
form_columns = ["label", "semester"]
|
||||||
|
|
||||||
def queryFilter(self):
|
def queryFilter(self):
|
||||||
return Part.id.in_([part.id for part in userActiveSemester().parts])
|
return Part.semester == userActiveSemester()
|
||||||
|
|
||||||
|
|
||||||
class StudentView(SecureModelView):
|
class StudentView(SecureModelView):
|
||||||
|
@ -223,24 +223,39 @@ def groupQueryFactory():
|
||||||
return Group.query.filter(Group.part_id.in_([part.id for part in userActiveSemester().parts]))
|
return Group.query.filter(Group.part_id.in_([part.id for part in userActiveSemester().parts]))
|
||||||
|
|
||||||
|
|
||||||
|
markChoices = [(-1, "-")] + list(zip(range(16)[::-1], range(16)[::-1]))
|
||||||
|
|
||||||
|
|
||||||
class PartStudentView(SecureModelView):
|
class PartStudentView(SecureModelView):
|
||||||
class CreateForm(Form):
|
class CreateForm(Form):
|
||||||
def studentQueryFactory():
|
def studentQueryFactory():
|
||||||
return Student.query
|
return Student.query
|
||||||
|
|
||||||
student = QuerySelectField(
|
student = QuerySelectField(
|
||||||
"Student", query_factory=studentQueryFactory, validators=[DataRequired()], allow_blank=True, blank_text="-"
|
"Student",
|
||||||
|
query_factory=studentQueryFactory,
|
||||||
|
validators=[DataRequired()],
|
||||||
|
allow_blank=True,
|
||||||
|
blank_text="-",
|
||||||
)
|
)
|
||||||
part = QuerySelectField(
|
part = QuerySelectField(
|
||||||
"Part", query_factory=partQueryFactory, validators=[DataRequired()], allow_blank=True, blank_text="-"
|
"Part",
|
||||||
|
query_factory=partQueryFactory,
|
||||||
|
validators=[DataRequired()],
|
||||||
|
allow_blank=True,
|
||||||
|
blank_text="-",
|
||||||
|
)
|
||||||
|
group = QuerySelectField(
|
||||||
|
"Group",
|
||||||
|
query_factory=groupQueryFactory,
|
||||||
|
allow_blank=True,
|
||||||
|
blank_text="-",
|
||||||
)
|
)
|
||||||
group = QuerySelectField("Group", query_factory=groupQueryFactory, allow_blank=True, blank_text="-")
|
|
||||||
|
|
||||||
class EditForm(CreateForm):
|
class EditForm(CreateForm):
|
||||||
student = None
|
student = None
|
||||||
part = None
|
part = None
|
||||||
marks = range(16)[::-1]
|
final_part_mark = SelectField("Final Part Mark", choices=markChoices, coerce=int)
|
||||||
final_part_mark = SelectField("Final Part Mark", choices=[(-1, "-")] + list(zip(marks, marks)), coerce=int)
|
|
||||||
|
|
||||||
form = EditForm
|
form = EditForm
|
||||||
|
|
||||||
|
@ -272,13 +287,18 @@ class PartStudentView(SecureModelView):
|
||||||
return super().update_model(form, model)
|
return super().update_model(form, model)
|
||||||
|
|
||||||
|
|
||||||
class GroupView(SecureModelView):
|
|
||||||
class CreateForm(Form):
|
|
||||||
def partStudentsQueryFactory():
|
def partStudentsQueryFactory():
|
||||||
return PartStudent.query.filter(PartStudent.part_id.in_([part.id for part in userActiveSemester().parts]))
|
return PartStudent.query.filter(PartStudent.part_id.in_([part.id for part in userActiveSemester().parts]))
|
||||||
|
|
||||||
|
|
||||||
|
class GroupView(SecureModelView):
|
||||||
|
class CreateForm(Form):
|
||||||
part = QuerySelectField(
|
part = QuerySelectField(
|
||||||
"Part", query_factory=partQueryFactory, validators=[DataRequired()], allow_blank=True, blank_text="-"
|
"Part",
|
||||||
|
query_factory=partQueryFactory,
|
||||||
|
validators=[DataRequired()],
|
||||||
|
allow_blank=True,
|
||||||
|
blank_text="-",
|
||||||
)
|
)
|
||||||
part_students = QuerySelectMultipleField("Part Students", query_factory=partStudentsQueryFactory)
|
part_students = QuerySelectMultipleField("Part Students", query_factory=partStudentsQueryFactory)
|
||||||
|
|
||||||
|
@ -380,7 +400,11 @@ class GroupExperimentView(SecureModelView):
|
||||||
return SemesterExperiment.query.filter(SemesterExperiment.semester == userActiveSemester())
|
return SemesterExperiment.query.filter(SemesterExperiment.semester == userActiveSemester())
|
||||||
|
|
||||||
group = QuerySelectField(
|
group = QuerySelectField(
|
||||||
"Group", query_factory=groupQueryFactory, validators=[DataRequired()], allow_blank=True, blank_text="-"
|
"Group",
|
||||||
|
query_factory=groupQueryFactory,
|
||||||
|
validators=[DataRequired()],
|
||||||
|
allow_blank=True,
|
||||||
|
blank_text="-",
|
||||||
)
|
)
|
||||||
semester_experiment = QuerySelectField(
|
semester_experiment = QuerySelectField(
|
||||||
"Semester Experiment",
|
"Semester Experiment",
|
||||||
|
@ -416,7 +440,10 @@ class GroupExperimentView(SecureModelView):
|
||||||
|
|
||||||
def queryFilter(self):
|
def queryFilter(self):
|
||||||
return GroupExperiment.group_id.in_(
|
return GroupExperiment.group_id.in_(
|
||||||
[g.id for g in Group.query.filter(Group.part_id.in_([part.id for part in userActiveSemester().parts]))]
|
[
|
||||||
|
group.id
|
||||||
|
for group in Group.query.filter(Group.part_id.in_([part.id for part in userActiveSemester().parts]))
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
def create_model(self, form):
|
def create_model(self, form):
|
||||||
|
@ -465,7 +492,11 @@ def groupExperimentQueryFactory():
|
||||||
class AppointmentView(SecureModelView):
|
class AppointmentView(SecureModelView):
|
||||||
class CreateForm(Form):
|
class CreateForm(Form):
|
||||||
group_experiment = QuerySelectField(
|
group_experiment = QuerySelectField(
|
||||||
"Group Experiment", query_factory=groupExperimentQueryFactory, validators=[DataRequired()]
|
"Group Experiment",
|
||||||
|
query_factory=groupExperimentQueryFactory,
|
||||||
|
validators=[DataRequired()],
|
||||||
|
allow_blank=True,
|
||||||
|
blank_text="-",
|
||||||
)
|
)
|
||||||
date = DateField("Date", validators=[DataRequired()])
|
date = DateField("Date", validators=[DataRequired()])
|
||||||
special = BooleanField("Special", default=False)
|
special = BooleanField("Special", default=False)
|
||||||
|
@ -565,13 +596,8 @@ class ExperimentMarkView(SecureModelView):
|
||||||
]
|
]
|
||||||
|
|
||||||
def queryFilter(self=None):
|
def queryFilter(self=None):
|
||||||
return GroupExperiment.semester_experiment_id.in_(
|
return ExperimentMark.group_experiment_id.in_(
|
||||||
[
|
groupExperiment.id for groupExperiment in groupExperimentQueryFactory()
|
||||||
semesterExperiment.id
|
|
||||||
for semesterExperiment in SemesterExperiment.query.filter(
|
|
||||||
SemesterExperiment.semester == userActiveSemester()
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def checkForm(form):
|
def checkForm(form):
|
||||||
|
|
Loading…
Reference in a new issue