ScoDoc-Lille/app/entreprises/__init__.py

61 lines
1.2 KiB
Python
Raw Permalink Normal View History

2021-12-23 19:28:25 +01:00
"""entreprises.__init__
"""
2022-05-04 18:59:29 +02:00
from datetime import datetime
2021-12-23 19:28:25 +01:00
from flask import Blueprint
from app.scodoc import sco_etud
from app.auth.models import User
2022-02-04 17:12:56 +01:00
from app.models import Departement
2021-12-23 19:28:25 +01:00
bp = Blueprint("entreprises", __name__)
2022-01-31 18:22:54 +01:00
LOGS_LEN = 5
SIRET_PROVISOIRE_START = "xx"
2021-12-23 19:28:25 +01:00
2021-12-23 19:28:25 +01:00
@bp.app_template_filter()
def format_prenom(s):
return sco_etud.format_prenom(s)
2021-12-23 19:28:25 +01:00
@bp.app_template_filter()
def format_nom(s):
return sco_etud.format_nom(s)
2021-12-23 19:28:25 +01:00
@bp.app_template_filter()
2022-02-10 21:17:22 +01:00
def get_nomcomplet_by_username(s):
2021-12-23 19:28:25 +01:00
user = User.query.filter_by(user_name=s).first()
return user.get_nomcomplet()
2021-12-23 19:28:25 +01:00
2022-02-01 18:35:48 +01:00
@bp.app_template_filter()
2022-02-04 17:12:56 +01:00
def get_nomcomplet_by_id(id):
user = User.query.filter_by(id=id).first()
2022-02-01 18:35:48 +01:00
return user.get_nomcomplet()
2022-02-04 17:12:56 +01:00
@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"
2022-05-04 18:59:29 +02:00
@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