ajout page offres expirées

This commit is contained in:
Arthur ZHU 2022-01-24 19:02:16 +01:00
parent 6d1744dacd
commit 0220607caa
3 changed files with 45 additions and 0 deletions

View File

@ -188,6 +188,36 @@ def offres():
) )
@bp.route("/fiche_entreprise/<int:id>/offres_expirees")
def offres_expirees(id):
entreprise = Entreprise.query.filter_by(id=id).first_or_404()
offres = entreprise.offres
offres_expirees_with_files = []
for offre in offres:
if date.today() > offre.expiration_date:
files = []
path = os.path.join(
Config.SCODOC_VAR_DIR,
"entreprises",
f"{offre.entreprise_id}",
f"{offre.id}",
)
if os.path.exists(path):
for dir in glob.glob(
f"{path}/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9]"
):
for file in glob.glob(f"{dir}/*"):
file = [os.path.basename(dir), os.path.basename(file)]
files.append(file)
offres_expirees_with_files.append([offre, files])
return render_template(
"entreprises/offres_expirees.html",
title=("Offres expirées"),
entreprise=entreprise,
offres_expirees=offres_expirees_with_files,
)
@bp.route("/add_entreprise", methods=["GET", "POST"]) @bp.route("/add_entreprise", methods=["GET", "POST"])
def add_entreprise(): def add_entreprise():
""" """

View File

@ -71,6 +71,7 @@
<a class="btn btn-primary" href="{{ url_for('entreprises.add_contact', id=entreprise.id) }}">Ajouter contact</a> <a class="btn btn-primary" href="{{ url_for('entreprises.add_contact', id=entreprise.id) }}">Ajouter contact</a>
<a class="btn btn-primary" href="{{ url_for('entreprises.add_historique', id=entreprise.id) }}">Ajouter <a class="btn btn-primary" href="{{ url_for('entreprises.add_historique', id=entreprise.id) }}">Ajouter
historique</a> historique</a>
<a class="btn btn-primary" href="{{ url_for('entreprises.offres_expirees', id=entreprise.id) }}">Voir les offres expirées</a>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -0,0 +1,14 @@
{# -*- mode: jinja-html -*- #}
{% extends 'base.html' %}
{% block app_content %}
<div class="container">
<h1>Offres expirées de {{ entreprise.nom }}</h1>
{% if offres_expirees %}
{% for offre in offres_expirees%}
Offre {{loop.index}} (ajouté le {{offre[0].date_ajout.strftime('%d/%m/%Y') }})
{% include 'entreprises/_offre.html' %}
{% endfor %}
{% endif %}
</div>
{% endblock %}