diff --git a/advlabdb/adminModelViews.py b/advlabdb/adminModelViews.py index 32a4f84..9c6abab 100644 --- a/advlabdb/adminModelViews.py +++ b/advlabdb/adminModelViews.py @@ -70,7 +70,7 @@ from .models import ( def semesterExperimentQueryFactory(): - return SemesterExperiment.query.filter(SemesterExperiment.semester == current_user.active_semester) + return SemesterExperiment.query.where(SemesterExperiment.semester == current_user.active_semester) class SemesterRowFilter(FilterEqual): @@ -85,7 +85,7 @@ class SemesterRowFilter(FilterEqual): class UserView(SecureAdminModelView): class SemesterFilter(SemesterRowFilter): def apply(self, query, value, alias=None): - return query.filter(self.column.active_semester_id == int(value)) + return query.where(self.column.active_semester_id == int(value)) class CreateForm(Form): def roleQueryFactory(): @@ -462,11 +462,11 @@ class StudentView(SecureAdminModelView): def partQueryFactory(): - return Part.query.filter(Part.semester == current_user.active_semester) + return Part.query.where(Part.semester == current_user.active_semester) def groupQueryFactory(): - return Group.query.filter(Group.semester == current_user.active_semester) + return Group.query.where(Group.semester == current_user.active_semester) class PartRowFilter(FilterEqual): @@ -481,7 +481,7 @@ class PartRowFilter(FilterEqual): class PartStudentView(SecureAdminModelView): class PartFilter(PartRowFilter): def apply(self, query, value, alias=None): - return query.filter(self.column.part_id == int(value)) + return query.where(self.column.part_id == int(value)) class StudentEndpointLinkRowAction(CustomIdEndpointLinkRowAction): def customId(self, row): @@ -583,7 +583,7 @@ class ProgramRowFilter(FilterEqual): class GroupView(SecureAdminModelView): class ProgramFilter(ProgramRowFilter): def apply(self, query, value, alias=None): - return query.filter(self.column.program_id == int(value)) + return query.where(self.column.program_id == int(value)) def formFactory(is_created, group): if is_created: @@ -645,7 +645,7 @@ class GroupView(SecureAdminModelView): class ExperimentView(SecureAdminModelView): class ProgramFilter(ProgramRowFilter): def apply(self, query, value, alias=None): - return query.filter(self.column.program_id == int(value)) + return query.where(self.column.program_id == int(value)) can_view_details = True @@ -716,7 +716,7 @@ class SemesterExperimentView(SecureAdminModelView): class CreateForm(Form): def experimentQueryFactory(): - return Experiment.query.filter(Experiment.active == True) + return Experiment.query.where(Experiment.active == True) experiment = QuerySelectField( "Experiment", @@ -838,7 +838,7 @@ class AssistantView(SecureAdminModelView): return row.user_id def assistantUserQueryFactory(): - return User.query.filter(User.roles.any(Role.name == "assistant")) + return User.query.join(User.roles).where(Role.name == "assistant") can_view_details = True @@ -1099,7 +1099,7 @@ class AppointmentView(SecureAdminModelView): class AssistantFilter(AssistantRowFilter): def apply(self, query, value, alias=None): - return query.filter(self.column.assistant_id == int(value)) + return query.where(self.column.assistant_id == int(value)) class GroupExperimentEndpointLinkRowAction(CustomIdEndpointLinkRowAction): def customId(self, row): @@ -1204,7 +1204,7 @@ class ExperimentMarkView(SecureAdminModelView): class AssistantFilter(AssistantRowFilter): def apply(self, query, value, alias=None): - return query.filter(self.column.assistant_id == int(value)) + return query.where(self.column.assistant_id == int(value)) class AdminFilter(FilterEqual): def get_options(self, view): @@ -1215,7 +1215,7 @@ class ExperimentMarkView(SecureAdminModelView): return tuple((admin.id, admin.repr()) for admin in admins) def apply(self, query, value, alias=None): - return query.filter(self.column.admin_id == int(value)) + return query.where(self.column.admin_id == int(value)) class ExperimentFilter(ExperimentRowFilter): def apply(self, query, value, alias=None): diff --git a/advlabdb/models.py b/advlabdb/models.py index 5c32e92..8f755a0 100644 --- a/advlabdb/models.py +++ b/advlabdb/models.py @@ -464,7 +464,7 @@ class Semester(db.Model): if transferParts: semester.transferPartsFrom(oldSemester) - for experiment in Experiment.query.filter(Experiment.active == True): + for experiment in db.execute(select(Experiment).where(Experiment.active == True)).scalars(): newSemesterExperiment = SemesterExperiment(experiment=experiment, semester=semester) if transferAssistants: