From 5a3125d1d1a8e80eac319b71490586ccef8a8612 Mon Sep 17 00:00:00 2001 From: Mo8it Date: Sat, 21 May 2022 21:12:15 +0200 Subject: [PATCH] Fix calling execute --- advlabdb/adminModelViews.py | 8 ++++---- advlabdb/models.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/advlabdb/adminModelViews.py b/advlabdb/adminModelViews.py index 9c6abab..904b5aa 100644 --- a/advlabdb/adminModelViews.py +++ b/advlabdb/adminModelViews.py @@ -474,7 +474,7 @@ class PartRowFilter(FilterEqual): if not has_request_context(): return tuple() - parts = db.execute(select(Part).where(Part.semester == current_user.active_semester)).scalars() + parts = db.session.execute(select(Part).where(Part.semester == current_user.active_semester)).scalars() return tuple((part.id, f"{part.program.repr()}{part.number}") for part in parts) @@ -576,7 +576,7 @@ class ProgramRowFilter(FilterEqual): if not has_request_context(): return tuple() - programs = db.execute(select(Program)).scalars() + programs = db.session.execute(select(Program)).scalars() return tuple((program.id, program.repr()) for program in programs) @@ -931,7 +931,7 @@ class ExperimentRowFilter(FilterEqual): if not has_request_context(): return tuple() - activeExperiments = db.execute(select(Experiment).where(Experiment.active == True)).scalars() + activeExperiments = db.session.execute(select(Experiment).where(Experiment.active == True)).scalars() return tuple( ( f"{activeExperiment.number},{activeExperiment.program_id}", @@ -1211,7 +1211,7 @@ class ExperimentMarkView(SecureAdminModelView): if not has_request_context(): return tuple() - admins = db.execute(select(Admin).join(User).where(User.active == True)).scalars() + admins = db.session.execute(select(Admin).join(User).where(User.active == True)).scalars() return tuple((admin.id, admin.repr()) for admin in admins) def apply(self, query, value, alias=None): diff --git a/advlabdb/models.py b/advlabdb/models.py index 8f755a0..11c57b8 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 db.execute(select(Experiment).where(Experiment.active == True)).scalars(): + for experiment in db.session.execute(select(Experiment).where(Experiment.active == True)).scalars(): newSemesterExperiment = SemesterExperiment(experiment=experiment, semester=semester) if transferAssistants: