correctifs divers

This commit is contained in:
Arthur ZHU 2022-02-01 18:35:48 +01:00
parent e85149f4a6
commit d32d49ea4d
15 changed files with 118 additions and 62 deletions

View File

@ -26,4 +26,10 @@ def get_nomcomplet(s):
return user.get_nomcomplet()
@bp.app_template_filter()
def get_nomcomplet_by_id(s):
user = User.query.filter_by(id=s).first()
return user.get_nomcomplet()
from app.entreprises import routes

View File

@ -293,3 +293,7 @@ class AjoutFichierForm(FlaskForm):
class SuppressionConfirmationForm(FlaskForm):
submit = SubmitField("Supprimer", render_kw={"style": "margin-bottom: 10px;"})
class ValidationConfirmationForm(FlaskForm):
submit = SubmitField("Valider", render_kw={"style": "margin-bottom: 10px;"})

View File

@ -22,6 +22,7 @@ from app.entreprises.forms import (
HistoriqueCreationForm,
EnvoiOffreForm,
AjoutFichierForm,
ValidationConfirmationForm,
)
from app.entreprises import bp
from app.entreprises.models import (
@ -193,10 +194,27 @@ def offres_recues():
.join(EntrepriseOffre, EntrepriseOffre.id == EntrepriseEnvoiOffre.offre_id)
.all()
)
offres_recues_with_files = []
for offre in offres_recues:
files = []
path = os.path.join(
Config.SCODOC_VAR_DIR,
"entreprises",
f"{offre[1].entreprise_id}",
f"{offre[1].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_recues_with_files.append([offre[0], offre[1], files])
return render_template(
"entreprises/offres_recues.html",
title=("Offres reçues"),
offres_recues=offres_recues,
offres_recues=offres_recues_with_files,
)
@ -376,10 +394,17 @@ def validate_entreprise(id):
"""
Permet de valider une entreprise
"""
form = ValidationConfirmationForm()
entreprise = Entreprise.query.filter_by(id=id, visible=False).first_or_404()
entreprise.visible = True
db.session.commit()
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id))
if form.validate_on_submit():
entreprise.visible = True
db.session.commit()
return redirect(url_for("entreprises.fiche_entreprise", id=entreprise.id))
return render_template(
"entreprises/validate_confirmation.html",
title=("Validation entreprise"),
form=form,
)
@bp.route("/add_offre/<int:id>", methods=["GET", "POST"])

View File

@ -11,11 +11,12 @@
}
.fiche-entreprise .btn {
margin-bottom: 10px;
margin-top: 5px;
margin-bottom: 5px;
}
.parent-btn {
margin-bottom: -10px;
margin-bottom: -5px;
}
.entreprise, .contact, .offre {

View File

@ -1,6 +1,6 @@
{# -*- mode: jinja-html -*- #}
<div class="contact">
<p>
<div>
Nom : {{ contact.nom }}<br>
Prénom : {{ contact.prenom }}<br>
Téléphone : {{ contact.telephone }}<br>
@ -11,7 +11,7 @@
{% if contact.service %}
Service : {{ contact.service }}<br>
{% endif %}
</p>
</div>
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<div class="parent-btn">

View File

@ -1,6 +1,6 @@
{# -*- mode: jinja-html -*- #}
<div class="offre">
<p>
<div>
Intitulé : {{ offre[0].intitule }}<br>
Description : {{ offre[0].description }}<br>
Type de l'offre : {{ offre[0].type_offre }}<br>
@ -9,13 +9,14 @@
{% 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>
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<a href="{{ url_for('entreprises.delete_offre_file', offre_id=offre[0].id, filedir=fichier[0] )}}" style="margin-left: 5px;"><img title="Supprimer fichier" alt="supprimer" width="10" height="9" border="0" src="/ScoDoc/static/icons/delete_small_img.png" /></a><br>
<a href="{{ url_for('entreprises.delete_offre_file', offre_id=offre[0].id, filedir=fichier[0] )}}" style="margin-left: 5px;"><img title="Supprimer fichier" alt="supprimer" width="10" height="9" border="0" src="/ScoDoc/static/icons/delete_small_img.png" /></a>
{% endif %}
<br>
{% endfor %}
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<a href="{{ url_for('entreprises.add_offre_file', offre_id=offre[0].id) }}">Ajoutez un fichier</a>
{% endif %}
</p>
</div>
<div class="parent-btn">
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}

View File

@ -13,6 +13,15 @@
</div>
{% endif %}
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) %}
<div class="container">
{% if contacts %}
<a class="btn btn-default" href="{{ url_for('entreprises.export_contacts') }}">Exporter la liste des contacts</a>
<a class="btn btn-default" href="{{ url_for('entreprises.export_contacts_bis') }}">Exporter la liste des contacts avec leur entreprise</a>
{% endif %}
</div>
{% endif %}
<div class="container">
<h1>Liste des contacts</h1>
{% if contacts %}
@ -67,14 +76,5 @@
<div>Aucun contact présent dans la base</div>
</div>
{% endif %}
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) %}
<div>
{% if contacts %}
<a class="btn btn-default" href="{{ url_for('entreprises.export_contacts') }}">Exporter la liste des contacts</a>
<a class="btn btn-default" href="{{ url_for('entreprises.export_contacts_bis') }}">Exporter la liste des contacts avec leur entreprise</a>
{% endif %}
</div>
{% endif %}
</div>
{% endblock %}

View File

@ -5,7 +5,7 @@
{% block app_content %}
<h1>{{ title }}</h1>
<br>
<div style="color:red">Cliquez sur le bouton supprimer pour confirmer votre supression</div>
<div style="color:red;">Cliquez sur le bouton Supprimer pour confirmer votre supression</div>
<br>
<div class="row">
<div class="col-md-4">

View File

@ -13,6 +13,17 @@
</div>
{% endif %}
<div class="container">
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<a class="btn btn-default" href="{{ url_for('entreprises.add_entreprise') }}">Ajouter une entreprise</a>
{% endif %}
{% if entreprises %}
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) %}
<a class="btn btn-default" href="{{ url_for('entreprises.export_entreprises') }}">Exporter la liste des entreprises</a>
{% endif %}
{% endif %}
</div>
<div class="container">
<h1>Liste des entreprises</h1>
{% if entreprises.items %}
@ -82,16 +93,5 @@
<br>
</div>
{% endif %}
<div style="margin-bottom: 20px;">
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<a class="btn btn-default" href="{{ url_for('entreprises.add_entreprise') }}">Ajouter une entreprise</a>
{% endif %}
{% if entreprises %}
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) %}
<a class="btn btn-default" href="{{ url_for('entreprises.export_entreprises') }}">Exporter la liste des entreprises</a>
{% endif %}
{% endif %}
</div>
</div>
{% endblock %}

View File

@ -36,7 +36,7 @@
<th>{{ entreprise.ville }}</th>
<th>{{ entreprise.pays }}</th>
<th>
<a class="btn btn-primary" href="{{ url_for('entreprises.validate_entreprise', id=entreprise.id) }}">Valider</a>
<a class="btn btn-success" href="{{ url_for('entreprises.validate_entreprise', id=entreprise.id) }}">Valider</a>
</th>
</tr>
{% endfor %}

View File

@ -38,16 +38,29 @@
<h2>Fiche entreprise - {{ entreprise.nom }} ({{ entreprise.siret }})</h2>
<div class="entreprise">
<p>
<div>
SIRET : {{ entreprise.siret }}<br>
Nom : {{ entreprise.nom }}<br>
Adresse : {{ entreprise.adresse }}<br>
Code postal : {{ entreprise.codepostal }}<br>
Ville : {{ entreprise.ville }}<br>
Pays : {{ entreprise.pays }}
</p>
</div>
</div>
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<div>
<a class="btn btn-primary" href="{{ url_for('entreprises.edit_entreprise', id=entreprise.id) }}">Modifier</a>
<a class="btn btn-danger" href="{{ url_for('entreprises.delete_entreprise', id=entreprise.id) }}">Supprimer</a>
<a class="btn btn-primary" href="{{ url_for('entreprises.add_offre', id=entreprise.id) }}">Ajouter offre</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
historique</a>
{% endif %}
<a class="btn btn-primary" href="{{ url_for('entreprises.offres_expirees', id=entreprise.id) }}">Voir les offres expirées</a>
<div>
<div class="contacts-et-offres">
{% if contacts %}
<div>
@ -60,24 +73,12 @@
{% if offres %}
<div>
<h3>Offres</h3>
<h3>Offres - <a href="{{ url_for('entreprises.offres_expirees', id=entreprise.id) }}">Voir les offres expirées</a></h3>
{% for offre in offres %}
{% include 'entreprises/_offre.html' %}
{% endfor %}
</div>
{% endif %}
</div>
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
<div>
<a class="btn btn-primary" href="{{ url_for('entreprises.edit_entreprise', id=entreprise.id) }}">Modifier</a>
<a class="btn btn-danger" href="{{ url_for('entreprises.delete_entreprise', id=entreprise.id) }}">Supprimer</a>
<a class="btn btn-primary" href="{{ url_for('entreprises.add_offre', id=entreprise.id) }}">Ajouter offre</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
historique</a>
<a class="btn btn-primary" href="{{ url_for('entreprises.offres_expirees', id=entreprise.id) }}">Voir les offres expirées</a>
</div>
{% endif %}
</div>
{% endblock %}

View File

@ -5,23 +5,23 @@
<div class="container">
<h2>Fiche entreprise - {{ entreprise.nom }} ({{ entreprise.siret }})</h2>
<div>
<p>
<div class="entreprise">
<div>
SIRET : {{ entreprise.siret }}<br>
Nom : {{ entreprise.nom }}<br>
Adresse : {{ entreprise.adresse }}<br>
Code postal : {{ entreprise.codepostal }}<br>
Ville : {{ entreprise.ville }}<br>
Pays : {{ entreprise.pays }}
</p>
</div>
</div>
{% if contacts %}
<div>
{% for contact in contacts %}
Contact {{loop.index}}
<div>
<p>
<h3>Contact</h3>
<div class="contact">
Nom : {{ contact.nom }}<br>
Prénom : {{ contact.prenom }}<br>
Téléphone : {{ contact.telephone }}<br>
@ -32,14 +32,14 @@
{% if contact.service %}
Service : {{ contact.service }}<br>
{% endif %}
</p>
</div>
</div>
{% endfor %}
</div>
{% endif %}
<div>
<a class="btn btn-primary" href="{{ url_for('entreprises.validate_entreprise', id=entreprise.id) }}">Valider</a>
<a class="btn btn-success" href="{{ url_for('entreprises.validate_entreprise', id=entreprise.id) }}">Valider</a>
</div>
</div>
{% endblock %}

View File

@ -6,7 +6,6 @@
<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 %}
{% else %}

View File

@ -4,19 +4,23 @@
{% block app_content %}
<div class="container">
<h1>{{ title }}</h1>
{% if offres_recus %}
{% if offres_recues %}
<div class="table-responsive">
<div>
{% for offre in offres_recus %}
<div>
<p>
Date envoi : {{ offre[0].date_envoi.strftime('%d/%m/%Y %H:%M') }}<br>
{% for offre in offres_recues %}
<div class="offre">
<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>
Description : {{ offre[1].description }}<br>
Type de l'offre : {{ offre[1].type_offre }}<br>
Missions : {{ offre[1].missions }}<br>
Durée : {{ offre[1].duree }}<br>
</p>
{% 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>
{% endfor %}
</div>
</div>
{% endfor %}
</div>

View File

@ -0,0 +1,15 @@
{# -*- mode: jinja-html -*- #}
{% extends 'base.html' %}
{% import 'bootstrap/wtf.html' as wtf %}
{% block app_content %}
<h1>{{ title }}</h1>
<br>
<div style="color:green;">Cliquez sur le bouton Valider pour confirmer votre validation</div>
<br>
<div class="row">
<div class="col-md-4">
{{ wtf.quick_form(form) }}
</div>
</div>
{% endblock %}