mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Replace all .filter()
This commit is contained in:
parent
91826cc98d
commit
7759a144b2
2 changed files with 13 additions and 13 deletions
|
@ -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):
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue