From 338c24a9c1fd9b51ea9ec07e6e49c60ff816ca55 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 2 Feb 2023 07:09:45 -0300 Subject: [PATCH] Archiver: dept variable --- app/scodoc/sco_archives.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/scodoc/sco_archives.py b/app/scodoc/sco_archives.py index 71ff5c466..8439d1df7 100644 --- a/app/scodoc/sco_archives.py +++ b/app/scodoc/sco_archives.py @@ -68,7 +68,7 @@ from app import log from app.but import jury_but_pv from app.comp import res_sem from app.comp.res_compat import NotesTableCompat -from app.models import Departement, FormSemestre +from app.models import FormSemestre from app.scodoc.TrivialFormulator import TrivialFormulator from app.scodoc.sco_exceptions import ( AccessDenied, @@ -89,6 +89,11 @@ class BaseArchiver(object): self.archive_type = archive_type self.initialized = False self.root = None + self.dept_id = getattr(g, "scodoc_dept_id") + + def set_dept_id(self, dept_id: int): + "set dept" + self.dept_id = dept_id def initialize(self): if self.initialized: @@ -117,8 +122,7 @@ class BaseArchiver(object): If directory does not yet exist, create it. """ self.initialize() - dept = Departement.query.filter_by(acronym=g.scodoc_dept).first() - dept_dir = os.path.join(self.root, str(dept.id)) + dept_dir = os.path.join(self.root, str(self.dept_id)) try: scu.GSL.acquire() if not os.path.isdir(dept_dir): @@ -137,8 +141,7 @@ class BaseArchiver(object): :return: list of archive oids """ self.initialize() - dept = Departement.query.filter_by(acronym=g.scodoc_dept).first() - base = os.path.join(self.root, str(dept.id)) + os.path.sep + base = os.path.join(self.root, str(self.dept_id)) + os.path.sep dirs = glob.glob(base + "*") return [os.path.split(x)[1] for x in dirs]