forked from ScoDoc/DocScoDoc
Fix minimal pour #304
This commit is contained in:
parent
9e69dcd05e
commit
0383b82597
@ -68,17 +68,17 @@ des tuples (name, value, formsemestre_id).
|
||||
Si formsemestre_id est NULL, la valeur concerne tous les semestres,
|
||||
sinon, elle ne concerne que le semestre indiqué.
|
||||
|
||||
* Utilisation dans ScoDoc8
|
||||
* Utilisation dans ScoDoc 9
|
||||
- lire une valeur:
|
||||
get_preference(name, formsemestre_id)
|
||||
nb: les valeurs sont des chaines, sauf:
|
||||
. si le type est spécfié (float ou int)
|
||||
. si le type est spécifié (float ou int)
|
||||
. les boolcheckbox qui sont des entiers 0 ou 1
|
||||
- avoir un mapping (read only) de toutes les valeurs:
|
||||
sco_preferences.SemPreferences(formsemestre_id)
|
||||
- editer les preferences globales:
|
||||
- éditer les preferences globales:
|
||||
sco_preferences.get_base_preferences(self).edit()
|
||||
- editer les preferences d'un semestre:
|
||||
- éditer les preferences d'un semestre:
|
||||
SemPreferences(formsemestre_id).edit()
|
||||
|
||||
* Implémentation: sco_preferences.py
|
||||
@ -123,22 +123,22 @@ from app.scodoc.TrivialFormulator import TrivialFormulator
|
||||
import app.scodoc.notesdb as ndb
|
||||
import app.scodoc.sco_utils as scu
|
||||
|
||||
_SCO_BASE_PREFERENCES = {} # { dept_acronym: BasePreferences instance }
|
||||
|
||||
|
||||
def clear_base_preferences():
|
||||
"""Clear cached preferences"""
|
||||
# usefull only for tests, where the same process may run
|
||||
# successively on several databases
|
||||
_SCO_BASE_PREFERENCES.clear()
|
||||
g._SCO_BASE_PREFERENCES = {} # { dept_id: BasePreferences instance }
|
||||
|
||||
|
||||
def get_base_preferences():
|
||||
"""Return global preferences for the current department"""
|
||||
dept_acronym = g.scodoc_dept
|
||||
if not dept_acronym in _SCO_BASE_PREFERENCES:
|
||||
_SCO_BASE_PREFERENCES[dept_acronym] = BasePreferences(dept_acronym)
|
||||
return _SCO_BASE_PREFERENCES[dept_acronym]
|
||||
dept_id = g.scodoc_dept_id
|
||||
if not hasattr(g, "_SCO_BASE_PREFERENCES"):
|
||||
g._SCO_BASE_PREFERENCES = {}
|
||||
if not dept_id in g._SCO_BASE_PREFERENCES:
|
||||
g._SCO_BASE_PREFERENCES[dept_id] = BasePreferences(dept_id)
|
||||
return g._SCO_BASE_PREFERENCES[dept_id]
|
||||
|
||||
|
||||
def get_preference(name, formsemestre_id=None):
|
||||
@ -263,10 +263,10 @@ class BasePreferences(object):
|
||||
filter_nulls=False,
|
||||
)
|
||||
|
||||
def __init__(self, dept_acronym: str):
|
||||
dept = Departement.query.filter_by(acronym=dept_acronym).first()
|
||||
def __init__(self, dept_id: int):
|
||||
dept = Departement.query.get(dept_id)
|
||||
if not dept:
|
||||
raise ScoValueError(f"Invalid departement: {dept_acronym}")
|
||||
raise ScoValueError(f"Invalid departement: {dept_id}")
|
||||
self.dept_id = dept.id
|
||||
self.init()
|
||||
self.load()
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
SCOVERSION = "9.1.54"
|
||||
SCOVERSION = "9.2a-54"
|
||||
|
||||
SCONAME = "ScoDoc"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user