forked from ScoDoc/ScoDoc
offres affichées selon departement, divers
This commit is contained in:
parent
0cef1089b3
commit
82b7791309
@ -45,6 +45,7 @@ import app.scodoc.sco_utils as scu
|
||||
|
||||
from app import db
|
||||
from sqlalchemy import text
|
||||
from app.models.departements import Departement
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
|
||||
@ -120,6 +121,21 @@ def contacts():
|
||||
)
|
||||
|
||||
|
||||
# temp
|
||||
def get_dept_id(acronym):
|
||||
dept = Departement.query.filter_by(acronym=acronym).first()
|
||||
if dept is not None:
|
||||
return dept.id
|
||||
return None
|
||||
|
||||
|
||||
def check_offre_dept(depts, offre_depts):
|
||||
for offre_dept in offre_depts:
|
||||
if offre_dept.dept_id in depts:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@bp.route("/fiche_entreprise/<int:id>", methods=["GET"])
|
||||
@permission_required(Permission.RelationsEntreprisesView)
|
||||
def fiche_entreprise(id):
|
||||
@ -131,8 +147,17 @@ def fiche_entreprise(id):
|
||||
"""
|
||||
entreprise = Entreprise.query.filter_by(id=id, visible=True).first_or_404()
|
||||
offres_with_files = []
|
||||
depts = []
|
||||
for role in current_user.user_roles:
|
||||
dept_id = get_dept_id(role.dept)
|
||||
if dept_id is not None:
|
||||
depts.append(dept_id)
|
||||
for offre in entreprise.offres:
|
||||
if date.today() < offre.expiration_date:
|
||||
offre_depts = EntrepriseOffreDepartement.query.filter_by(
|
||||
offre_id=offre.id
|
||||
).all()
|
||||
if not offre_depts or check_offre_dept(depts, offre_depts):
|
||||
files = []
|
||||
path = os.path.join(
|
||||
Config.SCODOC_VAR_DIR,
|
||||
@ -147,9 +172,6 @@ def fiche_entreprise(id):
|
||||
for file in glob.glob(f"{dir}/*"):
|
||||
file = [os.path.basename(dir), os.path.basename(file)]
|
||||
files.append(file)
|
||||
offre_depts = EntrepriseOffreDepartement.query.filter_by(
|
||||
offre_id=offre.id
|
||||
).all()
|
||||
offres_with_files.append([offre, files, offre_depts])
|
||||
contacts = entreprise.contacts[:]
|
||||
logs = (
|
||||
@ -465,6 +487,26 @@ def validate_entreprise(id):
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/delete_validation_entreprise/<int:id>", methods=["GET", "POST"])
|
||||
@permission_required(Permission.RelationsEntreprisesValidate)
|
||||
def delete_validation_entreprise(id):
|
||||
"""
|
||||
Permet de supprimer une entreprise en attente de validation avec une formulaire de validation
|
||||
"""
|
||||
entreprise = Entreprise.query.filter_by(id=id, visible=False).first_or_404()
|
||||
form = SuppressionConfirmationForm()
|
||||
if form.validate_on_submit():
|
||||
db.session.delete(entreprise)
|
||||
db.session.commit()
|
||||
flash("L'entreprise a été supprimé de la liste des entreprise à valider.")
|
||||
return redirect(url_for("entreprises.validation"))
|
||||
return render_template(
|
||||
"entreprises/delete_confirmation.html",
|
||||
title="Supression entreprise",
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/add_offre/<int:id>", methods=["GET", "POST"])
|
||||
@permission_required(Permission.RelationsEntreprisesChange)
|
||||
def add_offre(id):
|
||||
@ -598,6 +640,17 @@ def delete_offre(id):
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/delete_offre_recue/<int:id>", methods=["GET", "POST"])
|
||||
@permission_required(Permission.RelationsEntreprisesView)
|
||||
def delete_offre_recue(id):
|
||||
offre_recue = EntrepriseEnvoiOffre.query.filter_by(
|
||||
id=id, receiver_id=current_user.id
|
||||
).first_or_404()
|
||||
db.session.delete(offre_recue)
|
||||
db.session.commit()
|
||||
return redirect(url_for("entreprises.offres_recues"))
|
||||
|
||||
|
||||
@bp.route("/add_contact/<int:id>", methods=["GET", "POST"])
|
||||
@permission_required(Permission.RelationsEntreprisesChange)
|
||||
def add_contact(id):
|
||||
@ -954,6 +1007,11 @@ def import_entreprises():
|
||||
if len(entreprises_import) > 0:
|
||||
for entreprise in entreprises_import:
|
||||
db.session.add(entreprise)
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
text=f"Importation de {len(entreprises_import)} entreprise(s)",
|
||||
)
|
||||
db.session.add(log)
|
||||
db.session.commit()
|
||||
flash(f"Importation réussie de {len(entreprises_import)} entreprise(s)")
|
||||
return render_template(
|
||||
@ -1113,6 +1171,11 @@ def import_contacts():
|
||||
if len(contacts_import) > 0:
|
||||
for contact in contacts_import:
|
||||
db.session.add(contact)
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
text=f"Importation de {len(contacts_import)} contact(s)",
|
||||
)
|
||||
db.session.add(log)
|
||||
db.session.commit()
|
||||
flash(f"Importation réussie de {len(contacts_import)} contact(s)")
|
||||
return render_template(
|
||||
|
@ -75,9 +75,14 @@
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.offre_depts {
|
||||
.offre-depts {
|
||||
display: inline-block;
|
||||
border: black solid 2px;
|
||||
border-radius: 5px;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.offre-recue {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
Missions : {{ offre[0].missions }}<br>
|
||||
Durée : {{ offre[0].duree }}<br>
|
||||
{% if offre[2] %}
|
||||
Département(s) : {% for offre_dept in offre[2] %} <div class="offre_depts">{{ offre_dept.dept_id|get_dept_acronym }}</div> {% endfor %}<br>
|
||||
Département(s) : {% for offre_dept in offre[2] %} <div class="offre-depts">{{ offre_dept.dept_id|get_dept_acronym }}</div> {% endfor %}<br>
|
||||
{% endif %}
|
||||
{% for fichier in offre[1] %}
|
||||
<a href="{{ url_for('entreprises.get_offre_file', entreprise_id=entreprise.id, offre_id=offre[0].id, filedir=fichier[0], filename=fichier[1] )}}">{{ fichier[1] }}</a>
|
||||
|
@ -44,6 +44,7 @@
|
||||
|
||||
<div>
|
||||
<a class="btn btn-success" href="{{ url_for('entreprises.validate_entreprise', id=entreprise.id) }}">Valider</a>
|
||||
<a class="btn btn-danger" href="{{ url_for('entreprises.delete_validation_entreprise', id=entreprise.id) }}">Supprimer</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -8,7 +8,7 @@
|
||||
<h1>Offres reçues</h1>
|
||||
{% if offres_recues %}
|
||||
{% for offre in offres_recues %}
|
||||
<div class="offre">
|
||||
<div class="offre offre-recue">
|
||||
<div>
|
||||
Envoyé le {{ offre[0].date_envoi.strftime('%d %B %Y à %H:%M') }} par {{ offre[0].sender_id|get_nomcomplet_by_id }}<br>
|
||||
Intitulé : {{ offre[1].intitule }}<br>
|
||||
@ -18,9 +18,12 @@
|
||||
Durée : {{ offre[1].duree }}<br>
|
||||
|
||||
{% for fichier in offre[2] %}
|
||||
<a href="{{ url_for('entreprises.get_offre_file', entreprise_id=offre[1].entreprise_id, offre_id=offre[1].id, filedir=fichier[0], filename=fichier[1] )}}">{{ fichier[1] }}</a><br>
|
||||
<a href="{{ url_for('entreprises.get_offre_file', entreprise_id=offre[1].entreprise_id, offre_id=offre[1].id, filedir=fichier[0], filename=fichier[1]) }}">{{ fichier[1] }}</a><br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div>
|
||||
<a href="{{ url_for('entreprises.delete_offre_recue', id=offre[0].id) }}" style="margin-left: 5px;"><img title="Supprimer fichier" alt="supprimer" width="16" height="16" border="0" src="/ScoDoc/static/icons/delete_small_img.png" /></a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
|
Loading…
Reference in New Issue
Block a user