mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Added experiments history
This commit is contained in:
parent
d30945461b
commit
515c389610
2 changed files with 50 additions and 12 deletions
|
@ -51,7 +51,6 @@ This URL leads to the home page where you can login with this testing admin acco
|
||||||
|
|
||||||
# To-Do:
|
# To-Do:
|
||||||
- Rest of admin model views
|
- Rest of admin model views
|
||||||
- Experiments history for students
|
|
||||||
- Assistants space
|
- Assistants space
|
||||||
- Homepage text changeable
|
- Homepage text changeable
|
||||||
- Email integration?
|
- Email integration?
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from flask import flash, request, url_for
|
from flask import flash, request, url_for
|
||||||
from flask_admin.contrib.sqla.filters import BaseSQLAFilter
|
from flask_admin.contrib.sqla.filters import BaseSQLAFilter
|
||||||
from flask_admin.menu import MenuLink
|
from flask_admin.menu import MenuLink
|
||||||
|
from flask_admin.model.template import EndpointLinkRowAction
|
||||||
from flask_security import current_user, hash_password
|
from flask_security import current_user, hash_password
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from wtforms import Form, BooleanField, SelectField, TextField, RadioField, FloatField
|
from wtforms import Form, BooleanField, SelectField, TextField, RadioField, FloatField
|
||||||
|
@ -109,19 +110,25 @@ class SemesterView(SecureModelView):
|
||||||
form_columns = ["semester_label", "year", "transfer_parts", "transfer_semester_experiments", "transfer_assistants"]
|
form_columns = ["semester_label", "year", "transfer_parts", "transfer_semester_experiments", "transfer_assistants"]
|
||||||
|
|
||||||
semesterLabels = ["WS", "SS"]
|
semesterLabels = ["WS", "SS"]
|
||||||
|
transferDesciption = "Will be trasfered from your current semester."
|
||||||
form_extra_fields = {
|
form_extra_fields = {
|
||||||
"semester_label": RadioField(
|
"semester_label": RadioField(
|
||||||
"Semester", choices=list(zip(semesterLabels, semesterLabels)), validators=[DataRequired()]
|
"Semester", choices=list(zip(semesterLabels, semesterLabels)), validators=[DataRequired()]
|
||||||
),
|
),
|
||||||
"year": TextField("Year", validators=[DataRequired()]),
|
"year": TextField("Year", validators=[DataRequired()]),
|
||||||
"transfer_parts": BooleanField(
|
"transfer_parts": BooleanField(
|
||||||
"Transfer parts from your current semester",
|
"Transfer parts",
|
||||||
|
description=transferDesciption,
|
||||||
default=True,
|
default=True,
|
||||||
),
|
),
|
||||||
"transfer_semester_experiments": BooleanField(
|
"transfer_semester_experiments": BooleanField(
|
||||||
"Transfer Semester Experiemnts from your current semester", default=True
|
"Transfer Semester Experiemnts", description=transferDesciption, default=True
|
||||||
|
),
|
||||||
|
"transfer_assistants": BooleanField(
|
||||||
|
"Transfer Assistants",
|
||||||
|
description=transferDesciption + " This option has no effect if Semester Experiments are not transfered.",
|
||||||
|
default=True,
|
||||||
),
|
),
|
||||||
"transfer_assistants": BooleanField("Transfer Assistants from your current active semester", default=True),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def create_model(self, form):
|
def create_model(self, form):
|
||||||
|
@ -203,6 +210,15 @@ class StudentView(SecureModelView):
|
||||||
"contact_email": {"validators": [Email()]},
|
"contact_email": {"validators": [Email()]},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
column_extra_row_actions = [
|
||||||
|
EndpointLinkRowAction(
|
||||||
|
"glyphicon glyphicon-time",
|
||||||
|
id_arg="flt1_0",
|
||||||
|
title="Experiments history",
|
||||||
|
endpoint="experimentmark.index_view",
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def partQueryFactory():
|
def partQueryFactory():
|
||||||
return Part.query.filter(Part.id.in_([part.id for part in userActiveSemester().parts]))
|
return Part.query.filter(Part.id.in_([part.id for part in userActiveSemester().parts]))
|
||||||
|
@ -387,19 +403,19 @@ class GroupExperimentView(SecureModelView):
|
||||||
|
|
||||||
assistantBlankText = "Auto assign if experiment has only one assistant"
|
assistantBlankText = "Auto assign if experiment has only one assistant"
|
||||||
|
|
||||||
appointment1 = DateField("Appointment 1")
|
appointment1 = DateField("Appointment-1")
|
||||||
appointment1_special = BooleanField("Appointment 1 special", default=False)
|
appointment1_special = BooleanField("Appointment-1 special", default=False)
|
||||||
appointment1_assistant = QuerySelectField(
|
appointment1_assistant = QuerySelectField(
|
||||||
"Appointment 1 Assistant",
|
"Appointment-1 Assistant",
|
||||||
query_factory=assistantQueryFactory,
|
query_factory=assistantQueryFactory,
|
||||||
allow_blank=True,
|
allow_blank=True,
|
||||||
blank_text=assistantBlankText,
|
blank_text=assistantBlankText,
|
||||||
)
|
)
|
||||||
|
|
||||||
appointment2 = DateField("Appointment 2")
|
appointment2 = DateField("Appointment-2")
|
||||||
appointment2_special = BooleanField("Appointment 2 special", default=False)
|
appointment2_special = BooleanField("Appointment-2 special", default=False)
|
||||||
appointment2_assistant = QuerySelectField(
|
appointment2_assistant = QuerySelectField(
|
||||||
"Appointment 2 Assistant",
|
"Appointment-2 Assistant",
|
||||||
query_factory=assistantQueryFactory,
|
query_factory=assistantQueryFactory,
|
||||||
allow_blank=True,
|
allow_blank=True,
|
||||||
blank_text=assistantBlankText,
|
blank_text=assistantBlankText,
|
||||||
|
@ -407,6 +423,7 @@ class GroupExperimentView(SecureModelView):
|
||||||
|
|
||||||
form = CreateForm
|
form = CreateForm
|
||||||
|
|
||||||
|
can_edit = False
|
||||||
column_list = ["group", "semester_experiment", "appointments", "experiment_marks"]
|
column_list = ["group", "semester_experiment", "appointments", "experiment_marks"]
|
||||||
column_filters = ["group", "semester_experiment.experiment", "appointments"]
|
column_filters = ["group", "semester_experiment.experiment", "appointments"]
|
||||||
|
|
||||||
|
@ -443,17 +460,39 @@ class AppointmentView(SecureModelView):
|
||||||
column_list = ["date", "special", "group_experiment", "assistant"]
|
column_list = ["date", "special", "group_experiment", "assistant"]
|
||||||
|
|
||||||
|
|
||||||
|
class ExperimentMarkView(SecureModelView):
|
||||||
|
class StudentIdFilter(BaseSQLAFilter):
|
||||||
|
def apply(self, query, value, alias=None):
|
||||||
|
return query.filter(self.column == value)
|
||||||
|
|
||||||
|
def operation(self):
|
||||||
|
return "equals"
|
||||||
|
|
||||||
|
def validate(self, value):
|
||||||
|
if Student.query.get(value):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
column_filters = [
|
||||||
|
StudentIdFilter(PartStudent.id, "Student / ID"),
|
||||||
|
"part_student.student",
|
||||||
|
"group_experiment.semester_experiment.semester",
|
||||||
|
"group_experiment.semester_experiment.experiment",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
admin.add_view(StudentView(Student, db.session))
|
admin.add_view(StudentView(Student, db.session))
|
||||||
admin.add_view(PartStudentView(PartStudent, db.session))
|
admin.add_view(PartStudentView(PartStudent, db.session))
|
||||||
admin.add_view(GroupView(Group, db.session))
|
admin.add_view(GroupView(Group, db.session))
|
||||||
admin.add_view(GroupExperimentView(GroupExperiment, db.session))
|
admin.add_view(GroupExperimentView(GroupExperiment, db.session))
|
||||||
|
admin.add_view(AppointmentView(Appointment, db.session))
|
||||||
|
admin.add_view(ExperimentMarkView(ExperimentMark, db.session))
|
||||||
admin.add_view(ExperimentView(Experiment, db.session))
|
admin.add_view(ExperimentView(Experiment, db.session))
|
||||||
admin.add_view(SemesterExperimentView(SemesterExperiment, db.session))
|
admin.add_view(SemesterExperimentView(SemesterExperiment, db.session))
|
||||||
admin.add_view(AssistantView(Assistant, db.session))
|
admin.add_view(AssistantView(Assistant, db.session))
|
||||||
admin.add_view(AppointmentView(Appointment, db.session))
|
|
||||||
admin.add_view(PartView(Part, db.session))
|
admin.add_view(PartView(Part, db.session))
|
||||||
admin.add_view(SemesterView(Semester, db.session))
|
admin.add_view(SemesterView(Semester, db.session))
|
||||||
admin.add_view(SecureModelView(ExperimentMark, db.session))
|
|
||||||
admin.add_view(UserView(User, db.session))
|
admin.add_view(UserView(User, db.session))
|
||||||
admin.add_view(RoleView(Role, db.session))
|
admin.add_view(RoleView(Role, db.session))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue