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

Explicit expose

This commit is contained in:
Mo 2022-03-04 03:49:02 +01:00
parent 3c7b578352
commit 027851b398
3 changed files with 12 additions and 8 deletions

View file

@ -1,6 +1,6 @@
from pathlib import Path from pathlib import Path
from flask import flash, redirect, request, url_for, has_request_context from flask import flash, has_request_context, redirect, request, url_for
from flask_admin import expose from flask_admin import expose
from flask_admin.contrib.sqla.fields import QuerySelectField, QuerySelectMultipleField from flask_admin.contrib.sqla.fields import QuerySelectField, QuerySelectMultipleField
from flask_admin.contrib.sqla.filters import FilterEqual from flask_admin.contrib.sqla.filters import FilterEqual
@ -26,10 +26,15 @@ from wtforms.validators import URL, DataRequired, Email, NumberRange, Optional
from advlabdb import adminSpace, app, assistantSpace, db, user_datastore from advlabdb import adminSpace, app, assistantSpace, db, user_datastore
from advlabdb.configUtils import getConfig from advlabdb.configUtils import getConfig
from advlabdb.customClasses import SecureAdminBaseView, SecureAdminModelView, CustomIdEndpointLinkRowAction from advlabdb.customClasses import (
CustomIdEndpointLinkRowAction,
SecureAdminBaseView,
SecureAdminModelView,
)
from advlabdb.database_import import importFromFile from advlabdb.database_import import importFromFile
from advlabdb.exceptions import DataBaseException, ModelViewException from advlabdb.exceptions import DataBaseException, ModelViewException
from advlabdb.models import ( from advlabdb.models import (
Admin,
Appointment, Appointment,
Assistant, Assistant,
Experiment, Experiment,
@ -44,7 +49,6 @@ from advlabdb.models import (
SemesterExperiment, SemesterExperiment,
Student, Student,
User, User,
Admin,
) )
from advlabdb.utils import ( from advlabdb.utils import (
flashRandomPassword, flashRandomPassword,
@ -1368,7 +1372,7 @@ class ImportView(SecureAdminBaseView):
class DocsView(SecureAdminBaseView): class DocsView(SecureAdminBaseView):
@expose() @expose("/")
def index(self): def index(self):
return self.render("docs/admin.html") return self.render("docs/admin.html")

View file

@ -179,7 +179,7 @@ class AssistantUserView(SecureAssistantModelView):
class AssistantDocsView(SecureAssistantBaseView): class AssistantDocsView(SecureAssistantBaseView):
@expose() @expose("/")
def index(self): def index(self):
return self.render("docs/assistant.html") return self.render("docs/assistant.html")

View file

@ -1,6 +1,7 @@
from flask import flash, redirect, request, url_for from flask import flash, redirect, request, url_for
from flask_admin import AdminIndexView, BaseView, expose from flask_admin import AdminIndexView, BaseView, expose
from flask_admin.contrib.sqla import ModelView from flask_admin.contrib.sqla import ModelView
from flask_admin.model.template import EndpointLinkRowAction
from flask_security import current_user from flask_security import current_user
from sqlalchemy import and_ from sqlalchemy import and_
@ -14,7 +15,6 @@ from advlabdb.models import (
SemesterExperiment, SemesterExperiment,
) )
from advlabdb.utils import reportBadAttempt, userActiveSemester from advlabdb.utils import reportBadAttempt, userActiveSemester
from flask_admin.model.template import EndpointLinkRowAction
def adminViewIsAccessible(): def adminViewIsAccessible():
@ -35,7 +35,7 @@ class SecureAdminIndexView(CustomIndexView):
def is_accessible(self): def is_accessible(self):
return adminViewIsAccessible() return adminViewIsAccessible()
@expose() @expose("/")
def index(self): def index(self):
active_semester_experiment_marks_query = ExperimentMark.query.filter( active_semester_experiment_marks_query = ExperimentMark.query.filter(
ExperimentMark.part_student.has(PartStudent.part.has(Part.semester == userActiveSemester())) ExperimentMark.part_student.has(PartStudent.part.has(Part.semester == userActiveSemester()))
@ -58,7 +58,7 @@ class SecureAssistantIndexView(CustomIndexView):
def is_accessible(self): def is_accessible(self):
return assistantViewIsAccessible() return assistantViewIsAccessible()
@expose() @expose("/")
def index(self): def index(self):
active_semester_experiment_marks_query = ExperimentMark.query.filter( active_semester_experiment_marks_query = ExperimentMark.query.filter(
ExperimentMark.group_experiment.has( ExperimentMark.group_experiment.has(