mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
SelectField for final_part_mark
This commit is contained in:
parent
5b62f9e78e
commit
3b6f92efd9
3 changed files with 12 additions and 8 deletions
|
@ -57,7 +57,7 @@ This URL leads to the home page where you can login with this testing admin acco
|
|||
- Homepage text changeable
|
||||
- Email integration?
|
||||
- 2FA?
|
||||
- Students code for getting information?
|
||||
- Students code for getting information and giving feedback
|
||||
- Database scripts
|
||||
- Logging
|
||||
- Documentation with Sphinx
|
||||
|
|
|
@ -4,7 +4,7 @@ from flask_admin.menu import MenuLink
|
|||
from flask_admin.model.template import EndpointLinkRowAction
|
||||
from flask_security import current_user, hash_password
|
||||
from sqlalchemy import func
|
||||
from wtforms import Form, BooleanField, SelectField, TextField, RadioField, IntegerField
|
||||
from wtforms import Form, BooleanField, SelectField, TextField, RadioField
|
||||
from wtforms.validators import DataRequired, Email, Optional
|
||||
from flask_admin.contrib.sqla.fields import QuerySelectMultipleField, QuerySelectField
|
||||
from flask_admin.helpers import get_form_data
|
||||
|
@ -112,11 +112,8 @@ class SemesterView(SecureModelView):
|
|||
column_details_list = column_list + ["active_users"]
|
||||
form_columns = ["semester_label", "year", "transfer_parts", "transfer_assistants"]
|
||||
|
||||
semesterLabels = ["WS", "SS"]
|
||||
form_extra_fields = {
|
||||
"semester_label": RadioField(
|
||||
"Semester", choices=list(zip(semesterLabels, semesterLabels)), validators=[DataRequired()]
|
||||
),
|
||||
"semester_label": RadioField("Semester", choices=["WS", "SS"], validators=[DataRequired()]),
|
||||
"year": TextField("Year", validators=[DataRequired()]),
|
||||
"transfer_parts": BooleanField(
|
||||
"Transfer parts",
|
||||
|
@ -242,7 +239,8 @@ class PartStudentView(SecureModelView):
|
|||
class EditForm(CreateForm):
|
||||
student = None
|
||||
part = None
|
||||
final_part_mark = IntegerField("Final Part Mark", validators=[Optional()])
|
||||
marks = range(16)[::-1]
|
||||
final_part_mark = SelectField("Final Part Mark", choices=[(-1, "-")] + list(zip(marks, marks)), coerce=int)
|
||||
|
||||
form = EditForm
|
||||
|
||||
|
@ -267,6 +265,12 @@ class PartStudentView(SecureModelView):
|
|||
else:
|
||||
return super().handle_view_exception(exc)
|
||||
|
||||
def update_model(self, form, model):
|
||||
if form.final_part_mark.data == -1:
|
||||
form.final_part_mark.data = None
|
||||
|
||||
return super().update_model(form, model)
|
||||
|
||||
|
||||
class GroupView(SecureModelView):
|
||||
class CreateForm(Form):
|
||||
|
|
|
@ -293,7 +293,7 @@ class ExperimentMark(db.Model):
|
|||
__table_args__ = (db.UniqueConstraint(part_student_id, group_experiment_id),)
|
||||
|
||||
def repr(self):
|
||||
return f"Oral {round(self.oral_mark, 1)}; Prot {round(self.protocol_mark, 1)}"
|
||||
return f"Oral {self.oral_mark}; Prot {self.protocol_mark}"
|
||||
|
||||
def __repr__(self):
|
||||
return f"<EXPMARL {self.repr()}>"
|
||||
|
|
Loading…
Reference in a new issue