Preferences vides si pas de département

This commit is contained in:
Emmanuel Viennet 2022-08-01 21:43:04 +02:00
parent 9a2c3b8174
commit 338e2a1c3f

View File

@ -272,7 +272,7 @@ class BasePreferences(object):
def __init__(self, dept_id: int): def __init__(self, dept_id: int):
dept = Departement.query.get(dept_id) dept = Departement.query.get(dept_id)
if not dept: if not dept:
raise ScoValueError(f"Invalid departement: {dept_id}") raise ScoValueError(f"BasePreferences: Invalid departement: {dept_id}")
self.dept_id = dept.id self.dept_id = dept.id
self.init() self.init()
self.load() self.load()
@ -2152,6 +2152,9 @@ class SemPreferences:
def __init__(self, formsemestre_id=None, dept_id=None): def __init__(self, formsemestre_id=None, dept_id=None):
self.formsemestre_id = formsemestre_id self.formsemestre_id = formsemestre_id
if dept_id is None and g.scodoc_dept is None:
self.base_prefs = {}
else:
self.base_prefs = get_base_preferences(dept_id=dept_id) self.base_prefs = get_base_preferences(dept_id=dept_id)
def __getitem__(self, name): def __getitem__(self, name):