Merge pull request 'initialize DeptName pref while creating with flask' (#101) from jmplace/ScoDoc-Lille:init_dept into master

Reviewed-on: https://scodoc.org/git/viennet/ScoDoc/pulls/101
This commit is contained in:
Emmanuel Viennet 2021-08-18 19:09:52 +02:00
commit b58e088373

View File

@ -22,6 +22,7 @@ from app import clear_scodoc_cache
from app.auth.models import User, Role, UserRole from app.auth.models import User, Role, UserRole
from app import models from app import models
from app.models import ScoPreference
from app.views import notes, scolar, absences from app.views import notes, scolar, absences
import tools import tools
@ -170,6 +171,8 @@ def delete_dept(dept): # delete-dept
def create_dept(dept): # create-dept def create_dept(dept): # create-dept
"Create new departement" "Create new departement"
d = models.Departement(acronym=dept) d = models.Departement(acronym=dept)
p1 = ScoPreference(name="DeptName", value=dept, departement=d)
db.session.add(p1)
db.session.add(d) db.session.add(d)
db.session.commit() db.session.commit()
return 0 return 0