mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Add GroupExperiment.note to adminSpace
This commit is contained in:
parent
41a329512a
commit
8c34cb71f7
2 changed files with 21 additions and 8 deletions
|
@ -25,6 +25,7 @@ from wtforms.fields import (
|
|||
RadioField,
|
||||
StringField,
|
||||
SubmitField,
|
||||
TextAreaField,
|
||||
)
|
||||
from wtforms.validators import URL, DataRequired, Email, NumberRange, Optional
|
||||
from wtforms.widgets import NumberInput
|
||||
|
@ -132,7 +133,7 @@ class UserView(SecureAdminModelView):
|
|||
query_factory=semesterExperimentQueryFactory,
|
||||
allow_blank=True,
|
||||
blank_text="-",
|
||||
description="Only needed if the user has the assistant role",
|
||||
description="Only needed if the user has the assistant role.",
|
||||
)
|
||||
|
||||
active = BooleanField(
|
||||
|
@ -283,7 +284,7 @@ class SemesterView(SecureAdminModelView):
|
|||
"Year",
|
||||
validators=[DataRequired(), NumberRange(MIN_YEAR, MAX_YEAR)],
|
||||
default=defaultFormYear,
|
||||
description=f"Between {MIN_YEAR} and {MAX_YEAR}",
|
||||
description=f"Between {MIN_YEAR} and {MAX_YEAR}.",
|
||||
)
|
||||
transfer_parts = BooleanField(
|
||||
"Transfer parts",
|
||||
|
@ -690,7 +691,7 @@ class SemesterExperimentView(SecureAdminModelView):
|
|||
"Oral weighting",
|
||||
validators=[DataRequired(), NumberRange(0, 1)],
|
||||
default=0.5,
|
||||
description="Between 0 and 1",
|
||||
description="Between 0 and 1.",
|
||||
places=2,
|
||||
widget=NumberInput(step=0.01),
|
||||
)
|
||||
|
@ -706,7 +707,7 @@ class SemesterExperimentView(SecureAdminModelView):
|
|||
"Final weighting",
|
||||
validators=[DataRequired(), NumberRange(0, 1)],
|
||||
default=1.0,
|
||||
description="Between 0 and 1",
|
||||
description="Between 0 and 1.",
|
||||
places=2,
|
||||
widget=NumberInput(step=0.01),
|
||||
)
|
||||
|
@ -904,6 +905,14 @@ class ExperimentRowFilter(FilterEqual):
|
|||
return (experimentNumber, programId)
|
||||
|
||||
|
||||
def group_experiment_note_field():
|
||||
return TextAreaField(
|
||||
"Note",
|
||||
validators=[Optional()],
|
||||
description="This note can be seen and edited by assistants that are responsible for this semester experiment.",
|
||||
)
|
||||
|
||||
|
||||
class GroupExperimentView(SecureAdminModelView):
|
||||
class ExperimentFilter(ExperimentRowFilter):
|
||||
def apply(self, query, value, alias=None):
|
||||
|
@ -923,6 +932,9 @@ class GroupExperimentView(SecureAdminModelView):
|
|||
def customId(self, row):
|
||||
return row.semester_experiment_id
|
||||
|
||||
class EditForm(Form):
|
||||
note = group_experiment_note_field()
|
||||
|
||||
class CreateForm(Form):
|
||||
group = QuerySelectField(
|
||||
"Group",
|
||||
|
@ -970,8 +982,8 @@ class GroupExperimentView(SecureAdminModelView):
|
|||
allow_blank=True,
|
||||
blank_text=assistantBlankText,
|
||||
)
|
||||
note = group_experiment_note_field()
|
||||
|
||||
can_edit = False
|
||||
column_display_all_relations = True
|
||||
|
||||
column_filters = (
|
||||
|
@ -1072,7 +1084,7 @@ class AppointmentView(SecureAdminModelView):
|
|||
special = BooleanField(
|
||||
"Special",
|
||||
default=False,
|
||||
description="A special appointment should take place in the semester break",
|
||||
description="A special appointment should take place in the semester break.",
|
||||
)
|
||||
assistant = QuerySelectField(
|
||||
"Assistant",
|
||||
|
@ -1226,12 +1238,12 @@ class ExperimentMarkView(SecureAdminModelView):
|
|||
oral_mark = IntegerField(
|
||||
"Oral Mark",
|
||||
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",
|
||||
validators=[Optional(), NumberRange(MIN_MARK, MAX_MARK)],
|
||||
description=f"Between {MIN_MARK} and {MAX_MARK}",
|
||||
description=f"Between {MIN_MARK} and {MAX_MARK}.",
|
||||
)
|
||||
|
||||
column_descriptions = {
|
||||
|
|
|
@ -202,6 +202,7 @@ class Group(db.Model):
|
|||
class GroupExperiment(db.Model):
|
||||
# An experiment specified to a group
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
note = db.Column(db.Text, nullable=True)
|
||||
|
||||
semester_experiment_id = db.Column(db.Integer, db.ForeignKey("semester_experiment.id"), nullable=False)
|
||||
semester_experiment = db.relationship("SemesterExperiment", back_populates="group_experiments")
|
||||
|
|
Loading…
Reference in a new issue