forked from ScoDoc/ScoDoc
60 lines
1.1 KiB
Python
60 lines
1.1 KiB
Python
"""entreprises.__init__
|
|
"""
|
|
|
|
from datetime import datetime
|
|
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"
|
|
|
|
|
|
@bp.app_template_filter()
|
|
def check_taxe_now(taxes):
|
|
for taxe in taxes:
|
|
if taxe.annee == int(datetime.now().strftime("%Y")):
|
|
return True
|
|
return False
|
|
|
|
|
|
from app.entreprises import routes
|