From 5002afade17e2784a4624608e3c980166ca3fea0 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 2 Nov 2021 15:49:12 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Acc=C3=A9l=C3=A8re=20acc=C3=A8s=20aux=20pr?= =?UTF-8?q?=C3=A9f=C3=A9rences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_cache.py | 6 +++--- app/scodoc/sco_preferences.py | 18 +++--------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/app/scodoc/sco_cache.py b/app/scodoc/sco_cache.py index 53a26d778..9c20a2135 100644 --- a/app/scodoc/sco_cache.py +++ b/app/scodoc/sco_cache.py @@ -46,9 +46,9 @@ # sco_cache.NotesTableCache.delete_many(formsemestre_id_list) # # Bulletins PDF: -# sco_cache.PDFBulCache.get(formsemestre_id, version) -# sco_cache.PDFBulCache.set(formsemestre_id, version, filename, pdfdoc) -# sco_cache.PDFBulCache.delete(formsemestre_id) suppr. toutes les versions +# sco_cache.SemBulletinsPDFCache.get(formsemestre_id, version) +# sco_cache.SemBulletinsPDFCache.set(formsemestre_id, version, filename, pdfdoc) +# sco_cache.SemBulletinsPDFCache.delete(formsemestre_id) suppr. toutes les versions # Evaluations: # sco_cache.EvaluationCache.get(evaluation_id), set(evaluation_id, value), delete(evaluation_id), diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py index 92b00a67d..d83ca14f7 100644 --- a/app/scodoc/sco_preferences.py +++ b/app/scodoc/sco_preferences.py @@ -1894,21 +1894,9 @@ class BasePreferences(object): """Returns preference value. when no value defined for this semestre, returns global value. """ - params = { - "dept_id": self.dept_id, - "name": name, - "formsemestre_id": formsemestre_id, - } - cnx = ndb.GetDBConnexion() - plist = self._editor.list(cnx, params) - if not plist: - params["formsemestre_id"] = None - plist = self._editor.list(cnx, params) - if not plist: - return self.default[name] - p = plist[0] - _convert_pref_type(p, self.prefs_dict[name]) - return p["value"] + if formsemestre_id in self.prefs: + return self.prefs[formsemestre_id].get(name, self.prefs[None][name]) + return self.prefs[None][name] def __contains__(self, item): return item in self.prefs[None] From ddcc518807058eb3f11da69c97f71dbc7b9de27a Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 2 Nov 2021 23:42:46 +0100 Subject: [PATCH 2/3] Memoize (cache) user_info --- README.md | 2 +- app/scodoc/sco_users.py | 3 ++- sco_version.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e28a92aac..b80ecd5b5 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,7 @@ Sur une machine de DEV, lancer flask profile --host 0.0.0.0 --length 32 --profile-dir /opt/scodoc-data -le fichier `.prof` sera alors écrit dans `/opt/scoidoc-data` (on peut aussi utiliser `/tmp`). +le fichier `.prof` sera alors écrit dans `/opt/scodoc-data` (on peut aussi utiliser `/tmp`). Pour la visualisation, [snakeviz](https://jiffyclub.github.io/snakeviz/) est bien: diff --git a/app/scodoc/sco_users.py b/app/scodoc/sco_users.py index eaf434943..de1548571 100644 --- a/app/scodoc/sco_users.py +++ b/app/scodoc/sco_users.py @@ -46,7 +46,7 @@ from app.scodoc import sco_etud from app.scodoc import sco_excel from app.scodoc import sco_preferences from app.scodoc.gen_tables import GenTable -from app import log +from app import log, cache from app.scodoc.scolog import logdb import app.scodoc.sco_utils as scu @@ -226,6 +226,7 @@ def _user_list(user_name): return None +@cache.memoize(timeout=50) # seconds def user_info(user_name_or_id=None, user=None): """Dict avec infos sur l'utilisateur (qui peut ne pas etre dans notre base). Si user_name est specifie (string ou id), interroge la BD. Sinon, user doit etre une instance diff --git a/sco_version.py b/sco_version.py index 86a35aa75..79b8a736b 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.0.58" +SCOVERSION = "9.0.59" SCONAME = "ScoDoc" From 1c719b5c7ce87cab6cc124ec2b59086e2d4a9211 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 3 Nov 2021 00:27:50 +0100 Subject: [PATCH 3/3] Fix regression: groups_view argument --- app/views/scolar.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/scolar.py b/app/views/scolar.py index a3a913032..79e9d1986 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -306,6 +306,7 @@ sco_publish( @bp.route("/groups_view") @scodoc @permission_required_compat_scodoc7(Permission.ScoView) +# @permission_required(Permission.ScoView) @scodoc7func def groups_view( group_ids=(), @@ -319,7 +320,7 @@ def groups_view( formsemestre_id=None, ): return sco_groups_view.groups_view( - group_ids=(), + group_ids=group_ids, format=format, # Options pour listes: with_codes=with_codes,