1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-20 23:41:20 +00:00

Further filter and sort

This commit is contained in:
Mo 2022-03-02 18:59:14 +01:00
parent 298eb1cc8f
commit 820bde2541
2 changed files with 37 additions and 7 deletions

View file

@ -281,6 +281,10 @@ class SemesterView(SecureAdminModelView):
"label", "label",
"year", "year",
] ]
column_default_sort = [
("year", True),
("label", True),
]
def customCreateModel(self, form): def customCreateModel(self, form):
return Semester.customInitFromOldSemester( return Semester.customInitFromOldSemester(
@ -553,9 +557,20 @@ class GroupView(SecureAdminModelView):
class ExperimentView(SecureAdminModelView): class ExperimentView(SecureAdminModelView):
class ProgramFilter(FilterEqual):
def get_options(self, view):
programs = Program.query
return tuple((program.id, program.repr()) for program in programs)
def apply(self, query, value, alias=None):
return query.filter(self.column.program_id == int(value))
can_view_details = True can_view_details = True
column_filters = ("active",) column_filters = (
ProgramFilter(Experiment, "Program"),
"active",
)
column_list = [ column_list = [
"number", "number",
"program", "program",
@ -574,6 +589,10 @@ class ExperimentView(SecureAdminModelView):
"duration_in_days", "duration_in_days",
"semester_experiments", "semester_experiments",
] ]
column_searchable_list = [
"number",
"title",
]
form_columns = column_details_list.copy() form_columns = column_details_list.copy()
form_columns.remove("semester_experiments") form_columns.remove("semester_experiments")
@ -597,6 +616,14 @@ def assistantQueryFactory():
class SemesterExperimentView(SecureAdminModelView): class SemesterExperimentView(SecureAdminModelView):
class ProgramFilter(FilterEqual):
def get_options(self, view):
programs = Program.query
return tuple((program.id, program.repr()) for program in programs)
def apply(self, query, value, alias=None):
return query.filter(self.column.experiment.has(Experiment.program_id == int(value)))
class CreateForm(Form): class CreateForm(Form):
def experimentQueryFactory(): def experimentQueryFactory():
return Experiment.query.filter(Experiment.active == True) return Experiment.query.filter(Experiment.active == True)
@ -640,7 +667,6 @@ class SemesterExperimentView(SecureAdminModelView):
column_list = [ column_list = [
"experiment", "experiment",
"assistants", "assistants",
"semester",
] ]
column_details_list = column_list + [ column_details_list = column_list + [
"oral_weighting", "oral_weighting",
@ -648,7 +674,11 @@ class SemesterExperimentView(SecureAdminModelView):
"final_weighting", "final_weighting",
"group_experiments", "group_experiments",
] ]
column_filters = ("experiment",) column_filters = (ProgramFilter(SemesterExperiment, "Program"),)
column_searchable_list = [
"experiment.number",
"experiment.title",
]
def queryFilter(self): def queryFilter(self):
return SemesterExperiment.semester == userActiveSemester() return SemesterExperiment.semester == userActiveSemester()

8
poetry.lock generated
View file

@ -146,7 +146,7 @@ Flask = "*"
[[package]] [[package]]
name = "flask-security-too" name = "flask-security-too"
version = "4.1.2" version = "4.1.3"
description = "Simple security for Flask apps." description = "Simple security for Flask apps."
category = "main" category = "main"
optional = false optional = false
@ -164,7 +164,7 @@ passlib = ">=1.7.2"
[package.extras] [package.extras]
babel = ["babel (>=2.7.0)", "flask-babel (>=2.0.0)"] babel = ["babel (>=2.7.0)", "flask-babel (>=2.0.0)"]
common = ["bcrypt (>=3.1.5)", "flask-mail (>=0.9.1)"] common = ["bcrypt (>=3.1.5)", "flask-mail (>=0.9.1)", "bleach (>=3.3.1)"]
fsqla = ["flask-sqlalchemy (>=2.4.4)", "sqlalchemy (>=1.3.6)", "sqlalchemy-utils (>=0.34.1)"] fsqla = ["flask-sqlalchemy (>=2.4.4)", "sqlalchemy (>=1.3.6)", "sqlalchemy-utils (>=0.34.1)"]
mfa = ["cryptography (>=3.0.0)", "pyqrcode (>=1.2)", "phonenumberslite (>=8.11.1)"] mfa = ["cryptography (>=3.0.0)", "pyqrcode (>=1.2)", "phonenumberslite (>=8.11.1)"]
@ -470,8 +470,8 @@ flask-principal = [
{file = "Flask-Principal-0.4.0.tar.gz", hash = "sha256:f5d6134b5caebfdbb86f32d56d18ee44b080876a27269560a96ea35f75c99453"}, {file = "Flask-Principal-0.4.0.tar.gz", hash = "sha256:f5d6134b5caebfdbb86f32d56d18ee44b080876a27269560a96ea35f75c99453"},
] ]
flask-security-too = [ flask-security-too = [
{file = "Flask-Security-Too-4.1.2.tar.gz", hash = "sha256:88c3d4cfa415ef4dd6f71052ef7a806a5079d8ee33d3e384d2fcd48d802d9a9b"}, {file = "Flask-Security-Too-4.1.3.tar.gz", hash = "sha256:996d8d286789a72478462ee6f8a1371254a0dc4f8feea6f33534c2a3772c91cf"},
{file = "Flask_Security_Too-4.1.2-py2.py3-none-any.whl", hash = "sha256:ad33186feb9e03bf299e9bb6577c8425a38da0246e14e06fd4c28660a1acc099"}, {file = "Flask_Security_Too-4.1.3-py2.py3-none-any.whl", hash = "sha256:d417b5fccef96bad852944ffcfae9267baa2f353699ff4a6f77b4a8286a93d37"},
] ]
flask-sqlalchemy = [ flask-sqlalchemy = [
{file = "Flask-SQLAlchemy-2.5.1.tar.gz", hash = "sha256:2bda44b43e7cacb15d4e05ff3cc1f8bc97936cc464623424102bfc2c35e95912"}, {file = "Flask-SQLAlchemy-2.5.1.tar.gz", hash = "sha256:2bda44b43e7cacb15d4e05ff3cc1f8bc97936cc464623424102bfc2c35e95912"},