DocScoDoc/app/entreprises/__init__.py

51 lines
967 B
Python

"""entreprises.__init__
"""
from flask import Blueprint
from app.scodoc import sco_etud
from app.auth.models import User
from app.models import Departement
bp = Blueprint("entreprises", __name__)
LOGS_LEN = 5
@bp.app_template_filter()
def format_prenom(s):
return sco_etud.format_prenom(s)
@bp.app_template_filter()
def format_nom(s):
return sco_etud.format_nom(s)
@bp.app_template_filter()
def get_nomcomplet_by_username(s):
user = User.query.filter_by(user_name=s).first()
return user.get_nomcomplet()
@bp.app_template_filter()
def get_nomcomplet_by_id(id):
user = User.query.filter_by(id=id).first()
return user.get_nomcomplet()
@bp.app_template_filter()
def get_dept_acronym(id):
dept = Departement.query.filter_by(id=id).first()
return dept.acronym
@bp.app_template_filter()
def get_civilité(civ):
if civ == "H":
return "Monsieur"
else:
return "Madame"
from app.entreprises import routes