forked from ScoDoc/ScoDoc
supprime fichiers lors des suppressions, correctifs
This commit is contained in:
parent
442e1a35c9
commit
6d7a7a7c4b
@ -1,4 +1,5 @@
|
||||
import os
|
||||
from queue import Empty
|
||||
from config import Config
|
||||
from datetime import datetime, date
|
||||
import glob
|
||||
@ -75,7 +76,11 @@ def logs():
|
||||
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).paginate(
|
||||
page=page, per_page=20
|
||||
)
|
||||
return render_template("entreprises/logs.html", title=("Logs"), logs=logs)
|
||||
return render_template(
|
||||
"entreprises/logs.html",
|
||||
title=("Logs"),
|
||||
logs=logs,
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/validation", methods=["GET"])
|
||||
@ -107,7 +112,10 @@ def contacts():
|
||||
)
|
||||
logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).limit(LOGS_LEN).all()
|
||||
return render_template(
|
||||
"entreprises/contacts.html", title=("Contacts"), contacts=contacts, logs=logs
|
||||
"entreprises/contacts.html",
|
||||
title=("Contacts"),
|
||||
contacts=contacts,
|
||||
logs=logs,
|
||||
)
|
||||
|
||||
|
||||
@ -392,7 +400,9 @@ def edit_entreprise(id):
|
||||
form.ville.data = entreprise.ville
|
||||
form.pays.data = entreprise.pays
|
||||
return render_template(
|
||||
"entreprises/form.html", title=("Modification entreprise"), form=form
|
||||
"entreprises/form.html",
|
||||
title=("Modification entreprise"),
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@ -406,6 +416,14 @@ def delete_entreprise(id):
|
||||
form = SuppressionConfirmationForm()
|
||||
if form.validate_on_submit():
|
||||
db.session.delete(entreprise)
|
||||
# supprime les fichiers attachés aux offres
|
||||
path = os.path.join(
|
||||
Config.SCODOC_VAR_DIR,
|
||||
"entreprises",
|
||||
f"{entreprise.id}",
|
||||
)
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=entreprise.id,
|
||||
@ -484,7 +502,11 @@ def add_offre(id):
|
||||
db.session.commit()
|
||||
flash("L'offre a été ajouté à la fiche entreprise.")
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id))
|
||||
return render_template("entreprises/form.html", title=("Ajout offre"), form=form)
|
||||
return render_template(
|
||||
"entreprises/form.html",
|
||||
title=("Ajout offre"),
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/edit_offre/<int:id>", methods=["GET", "POST"])
|
||||
@ -536,7 +558,9 @@ def edit_offre(id):
|
||||
form.expiration_date.data = offre.expiration_date
|
||||
form.depts.data = offre_depts_list
|
||||
return render_template(
|
||||
"entreprises/form.html", title=("Modification offre"), form=form
|
||||
"entreprises/form.html",
|
||||
title=("Modification offre"),
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@ -551,6 +575,14 @@ def delete_offre(id):
|
||||
form = SuppressionConfirmationForm()
|
||||
if form.validate_on_submit():
|
||||
db.session.delete(offre)
|
||||
path = os.path.join(
|
||||
Config.SCODOC_VAR_DIR,
|
||||
"entreprises",
|
||||
f"{entreprise_id}",
|
||||
f"{offre.id}",
|
||||
)
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=offre.entreprise_id,
|
||||
@ -561,7 +593,9 @@ def delete_offre(id):
|
||||
flash("L'offre a été supprimé de la fiche entreprise.")
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise_id))
|
||||
return render_template(
|
||||
"entreprises/delete_confirmation.html", title=("Supression offre"), form=form
|
||||
"entreprises/delete_confirmation.html",
|
||||
title=("Supression offre"),
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@ -593,7 +627,11 @@ def add_contact(id):
|
||||
db.session.commit()
|
||||
flash("Le contact a été ajouté à la fiche entreprise.")
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id))
|
||||
return render_template("entreprises/form.html", title=("Ajout contact"), form=form)
|
||||
return render_template(
|
||||
"entreprises/form.html",
|
||||
title=("Ajout contact"),
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/edit_contact/<int:id>", methods=["GET", "POST"])
|
||||
@ -633,7 +671,9 @@ def edit_contact(id):
|
||||
form.poste.data = contact.poste
|
||||
form.service.data = contact.service
|
||||
return render_template(
|
||||
"entreprises/form.html", title=("Modification contact"), form=form
|
||||
"entreprises/form.html",
|
||||
title=("Modification contact"),
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@ -667,7 +707,9 @@ def delete_contact(id):
|
||||
flash("Le contact a été supprimé de la fiche entreprise.")
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise_id))
|
||||
return render_template(
|
||||
"entreprises/delete_confirmation.html", title=("Supression contact"), form=form
|
||||
"entreprises/delete_confirmation.html",
|
||||
title=("Supression contact"),
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@ -708,7 +750,9 @@ def add_historique(id):
|
||||
flash("L'étudiant a été ajouté sur la fiche entreprise.")
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id))
|
||||
return render_template(
|
||||
"entreprises/ajout_historique.html", title=("Ajout historique"), form=form
|
||||
"entreprises/ajout_historique.html",
|
||||
title=("Ajout historique"),
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@ -738,7 +782,9 @@ def envoyer_offre(id):
|
||||
flash(f"L'offre a été envoyé à {responsable.get_nomplogin()}.")
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=offre.entreprise_id))
|
||||
return render_template(
|
||||
"entreprises/envoi_offre_form.html", title=("Envoyer une offre"), form=form
|
||||
"entreprises/envoi_offre_form.html",
|
||||
title=("Envoyer une offre"),
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@ -840,6 +886,9 @@ def get_import_entreprises_file_sample():
|
||||
@bp.route("/import_entreprises", methods=["GET", "POST"])
|
||||
@permission_required(Permission.RelationsEntreprisesExport)
|
||||
def import_entreprises():
|
||||
"""
|
||||
Permet d'importer des entreprises a l'aide d'un fichier excel (.xlsx)
|
||||
"""
|
||||
form = ImportEntreprisesForm()
|
||||
if form.validate_on_submit():
|
||||
path = os.path.join(Config.SCODOC_VAR_DIR, "tmp")
|
||||
@ -974,7 +1023,9 @@ def add_offre_file(offre_id):
|
||||
flash("Le fichier a été ajouté a l'offre.")
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=offre.entreprise_id))
|
||||
return render_template(
|
||||
"entreprises/form.html", title=("Ajout fichier à une offre"), form=form
|
||||
"entreprises/form.html",
|
||||
title=("Ajout fichier à une offre"),
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
{% import 'bootstrap/wtf.html' as wtf %}
|
||||
|
||||
{% block app_content %}
|
||||
<h1>{{ title }}</h1>
|
||||
<h1>Ajout entreprise avec contact</h1>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
|
@ -9,7 +9,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block app_content %}
|
||||
<h1>{{ title }}</h1>
|
||||
<h1>Ajout historique</h1>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
|
@ -43,10 +43,9 @@
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div>Aucune entreprise à valider</div>
|
||||
<br>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
@ -9,7 +9,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block app_content %}
|
||||
<h1>{{ title }}</h1>
|
||||
<h1>Envoyer une offre</h1>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
|
@ -24,8 +24,12 @@
|
||||
<div class="contact">
|
||||
Nom : {{ contact.nom }}<br>
|
||||
Prénom : {{ contact.prenom }}<br>
|
||||
{% if contact.telephone %}
|
||||
Téléphone : {{ contact.telephone }}<br>
|
||||
{% endif %}
|
||||
{% if contact.mail %}
|
||||
Mail : {{ contact.mail }}<br>
|
||||
{% endif %}
|
||||
{% if contact.poste %}
|
||||
Poste : {{ contact.poste }}<br>
|
||||
{% endif %}
|
||||
|
@ -7,7 +7,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block app_content %}
|
||||
<h1>{{ title }}</h1>
|
||||
<h1>Importation entreprises</h1>
|
||||
<br>
|
||||
<div>
|
||||
<a href="{{ url_for('entreprises.get_import_entreprises_file_sample') }}">Obtenir la feuille excel à remplir</a>
|
||||
|
@ -4,12 +4,12 @@
|
||||
{% block app_content %}
|
||||
<div class="container">
|
||||
<h3>Dernières opérations</h3>
|
||||
{% if logs.items %}
|
||||
<ul>
|
||||
{% for log in logs.items %}
|
||||
<li><span style="margin-right: 10px;">{{ log.date.strftime('%d %b %Hh%M') }}</span><span>{{ log.text|safe }} par {{ log.authenticated_user|get_nomcomplet }}</span></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<a href="{{ url_for('entreprises.logs', page=logs.prev_num) }}" class="btn btn-default {% if logs.page == 1 %}disabled{% endif %}">
|
||||
@ -34,4 +34,10 @@
|
||||
<p class="text-center">
|
||||
Page {{ logs.page }} sur {{ logs.pages }}
|
||||
</p>
|
||||
{% else %}
|
||||
<div>Aucune opération</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
@ -4,12 +4,12 @@
|
||||
{% block app_content %}
|
||||
<div class="container">
|
||||
<h3>Dernières opérations - {{ entreprise.nom }}</h3>
|
||||
{% if logs.items %}
|
||||
<ul>
|
||||
{% for log in logs.items %}
|
||||
<li><span style="margin-right: 10px;">{{ log.date.strftime('%d %b %Hh%M') }}</span><span>{{ log.text|safe }} par {{ log.authenticated_user|get_nomcomplet }}</span></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<a href="{{ url_for('entreprises.logs_entreprise', id=entreprise.id, page=logs.prev_num) }}" class="btn btn-default {% if logs.page == 1 %}disabled{% endif %}">
|
||||
@ -34,4 +34,9 @@
|
||||
<p class="text-center">
|
||||
Page {{ logs.page }} sur {{ logs.pages }}
|
||||
</p>
|
||||
{% else %}
|
||||
<div>Aucune opération</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
@ -5,10 +5,8 @@
|
||||
{% include 'entreprises/nav.html' %}
|
||||
|
||||
<div class="container">
|
||||
<h1>{{ title }}</h1>
|
||||
<h1>Offres reçues</h1>
|
||||
{% if offres_recues %}
|
||||
<div class="table-responsive">
|
||||
<div>
|
||||
{% for offre in offres_recues %}
|
||||
<div class="offre">
|
||||
<div>
|
||||
@ -25,11 +23,8 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<br>
|
||||
{% else %}
|
||||
<div>Aucune offre reçue</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
@ -3,7 +3,7 @@
|
||||
{% import 'bootstrap/wtf.html' as wtf %}
|
||||
|
||||
{% block app_content %}
|
||||
<h1>{{ title }}</h1>
|
||||
<h1>Validation entreprise</h1>
|
||||
<br>
|
||||
<div style="color:green;">Cliquez sur le bouton Valider pour confirmer votre validation</div>
|
||||
<br>
|
||||
|
Loading…
Reference in New Issue
Block a user