2021-05-29 18:22:51 +02:00
|
|
|
# -*- coding: UTF-8 -*
|
|
|
|
"""ScoDoc Flask views
|
|
|
|
"""
|
|
|
|
from flask import Blueprint
|
2021-07-20 17:32:04 +02:00
|
|
|
from flask import g
|
|
|
|
from app.scodoc import notesdb as ndb
|
2021-05-29 18:22:51 +02:00
|
|
|
|
2021-07-04 12:32:13 +02:00
|
|
|
scodoc_bp = Blueprint("scodoc", __name__)
|
2021-05-31 00:14:15 +02:00
|
|
|
scolar_bp = Blueprint("scolar", __name__)
|
2021-05-29 18:22:51 +02:00
|
|
|
notes_bp = Blueprint("notes", __name__)
|
2021-06-26 21:57:54 +02:00
|
|
|
users_bp = Blueprint("users", __name__)
|
2021-05-31 00:14:15 +02:00
|
|
|
absences_bp = Blueprint("absences", __name__)
|
|
|
|
essais_bp = Blueprint("essais", __name__)
|
2021-05-29 18:22:51 +02:00
|
|
|
|
2021-06-16 16:59:31 +02:00
|
|
|
|
2021-07-20 17:32:04 +02:00
|
|
|
@scodoc_bp.before_app_request
|
|
|
|
def open_dept_db_connection():
|
|
|
|
# current_app.logger.info("open_dept_db_connection")
|
|
|
|
if hasattr(g, "scodoc_dept") and not hasattr(g, "db_conn") and g.scodoc_dept:
|
|
|
|
g.db_conn = ndb.open_dept_connection()
|
|
|
|
|
|
|
|
|
|
|
|
@scodoc_bp.teardown_app_request
|
|
|
|
def close_dept_db_connection(arg):
|
|
|
|
# current_app.logger.info("close_dept_db_connection")
|
|
|
|
if hasattr(g, "db_conn"):
|
|
|
|
ndb.close_dept_connection()
|
|
|
|
|
|
|
|
|
|
|
|
from app.views import scodoc, notes, scolar, absences, users, essais
|