From d32d49ea4d35de4df0093b04b60dbe84c886de7e Mon Sep 17 00:00:00 2001 From: Arthur ZHU Date: Tue, 1 Feb 2022 18:35:48 +0100 Subject: [PATCH] correctifs divers --- app/entreprises/__init__.py | 6 ++++ app/entreprises/forms.py | 4 +++ app/entreprises/routes.py | 33 ++++++++++++++++--- app/static/css/entreprises.css | 5 +-- app/templates/entreprises/_contact.html | 4 +-- app/templates/entreprises/_offre.html | 7 ++-- app/templates/entreprises/contacts.html | 18 +++++----- .../entreprises/delete_confirmation.html | 2 +- app/templates/entreprises/entreprises.html | 22 ++++++------- .../entreprises/entreprises_validation.html | 2 +- .../entreprises/fiche_entreprise.html | 31 ++++++++--------- .../fiche_entreprise_validation.html | 14 ++++---- .../entreprises/offres_expirees.html | 1 - app/templates/entreprises/offres_recues.html | 16 +++++---- .../entreprises/validate_confirmation.html | 15 +++++++++ 15 files changed, 118 insertions(+), 62 deletions(-) create mode 100644 app/templates/entreprises/validate_confirmation.html diff --git a/app/entreprises/__init__.py b/app/entreprises/__init__.py index 813fd73b6..301b8eaf3 100644 --- a/app/entreprises/__init__.py +++ b/app/entreprises/__init__.py @@ -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 diff --git a/app/entreprises/forms.py b/app/entreprises/forms.py index 9ea927813..6836048d2 100644 --- a/app/entreprises/forms.py +++ b/app/entreprises/forms.py @@ -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;"}) diff --git a/app/entreprises/routes.py b/app/entreprises/routes.py index a6f91813b..48e6661d2 100644 --- a/app/entreprises/routes.py +++ b/app/entreprises/routes.py @@ -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/", methods=["GET", "POST"]) diff --git a/app/static/css/entreprises.css b/app/static/css/entreprises.css index aebcc2e68..e6304647f 100644 --- a/app/static/css/entreprises.css +++ b/app/static/css/entreprises.css @@ -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 { diff --git a/app/templates/entreprises/_contact.html b/app/templates/entreprises/_contact.html index 5030f46ea..50fe4185c 100644 --- a/app/templates/entreprises/_contact.html +++ b/app/templates/entreprises/_contact.html @@ -1,6 +1,6 @@ {# -*- mode: jinja-html -*- #}
-

+

Nom : {{ contact.nom }}
Prénom : {{ contact.prenom }}
Téléphone : {{ contact.telephone }}
@@ -11,7 +11,7 @@ {% if contact.service %} Service : {{ contact.service }}
{% endif %} -

+
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %}
diff --git a/app/templates/entreprises/_offre.html b/app/templates/entreprises/_offre.html index 683131ace..a81dc647f 100644 --- a/app/templates/entreprises/_offre.html +++ b/app/templates/entreprises/_offre.html @@ -1,6 +1,6 @@ {# -*- mode: jinja-html -*- #}
-

+

Intitulé : {{ offre[0].intitule }}
Description : {{ offre[0].description }}
Type de l'offre : {{ offre[0].type_offre }}
@@ -9,13 +9,14 @@ {% for fichier in offre[1] %} {{ fichier[1] }} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} - supprimer
+ supprimer {% endif %} +
{% endfor %} {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} Ajoutez un fichier {% endif %} -

+
{% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} diff --git a/app/templates/entreprises/contacts.html b/app/templates/entreprises/contacts.html index 4656e607e..7370855d6 100644 --- a/app/templates/entreprises/contacts.html +++ b/app/templates/entreprises/contacts.html @@ -13,6 +13,15 @@
{% endif %} + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) %} + + {% endif %} +

Liste des contacts

{% if contacts %} @@ -67,14 +76,5 @@
Aucun contact présent dans la base
{% endif %} - - {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) %} - - {% endif %}
{% endblock %} \ No newline at end of file diff --git a/app/templates/entreprises/delete_confirmation.html b/app/templates/entreprises/delete_confirmation.html index 4894bca3e..abd59c47e 100644 --- a/app/templates/entreprises/delete_confirmation.html +++ b/app/templates/entreprises/delete_confirmation.html @@ -5,7 +5,7 @@ {% block app_content %}

{{ title }}


-
Cliquez sur le bouton supprimer pour confirmer votre supression
+
Cliquez sur le bouton Supprimer pour confirmer votre supression

diff --git a/app/templates/entreprises/entreprises.html b/app/templates/entreprises/entreprises.html index 27e11c6ca..5b4531fcb 100644 --- a/app/templates/entreprises/entreprises.html +++ b/app/templates/entreprises/entreprises.html @@ -13,6 +13,17 @@
{% endif %} +
+ {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} + Ajouter une entreprise + {% endif %} + {% if entreprises %} + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) %} + Exporter la liste des entreprises + {% endif %} + {% endif %} +
+

Liste des entreprises

{% if entreprises.items %} @@ -82,16 +93,5 @@
{% endif %} - -
- {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} - Ajouter une entreprise - {% endif %} - {% if entreprises %} - {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) %} - Exporter la liste des entreprises - {% endif %} - {% endif %} -
{% endblock %} \ No newline at end of file diff --git a/app/templates/entreprises/entreprises_validation.html b/app/templates/entreprises/entreprises_validation.html index 64b503813..8c3da9d37 100644 --- a/app/templates/entreprises/entreprises_validation.html +++ b/app/templates/entreprises/entreprises_validation.html @@ -36,7 +36,7 @@ {{ entreprise.ville }} {{ entreprise.pays }} - Valider + Valider {% endfor %} diff --git a/app/templates/entreprises/fiche_entreprise.html b/app/templates/entreprises/fiche_entreprise.html index 238553324..36078189a 100644 --- a/app/templates/entreprises/fiche_entreprise.html +++ b/app/templates/entreprises/fiche_entreprise.html @@ -38,16 +38,29 @@

Fiche entreprise - {{ entreprise.nom }} ({{ entreprise.siret }})

-

+

SIRET : {{ entreprise.siret }}
Nom : {{ entreprise.nom }}
Adresse : {{ entreprise.adresse }}
Code postal : {{ entreprise.codepostal }}
Ville : {{ entreprise.ville }}
Pays : {{ entreprise.pays }} -

+
+ {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} +
+ Modifier + Supprimer + Ajouter offre + Ajouter contact + Ajouter + historique + {% endif %} + Voir les offres expirées +
+ +
{% if contacts %}
@@ -60,24 +73,12 @@ {% if offres %}
-

Offres

+

Offres - Voir les offres expirées

{% for offre in offres %} {% include 'entreprises/_offre.html' %} {% endfor %}
{% endif %}
- - {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} - - {% endif %}
{% endblock %} \ No newline at end of file diff --git a/app/templates/entreprises/fiche_entreprise_validation.html b/app/templates/entreprises/fiche_entreprise_validation.html index 6daf2ce11..ee36ca742 100644 --- a/app/templates/entreprises/fiche_entreprise_validation.html +++ b/app/templates/entreprises/fiche_entreprise_validation.html @@ -5,23 +5,23 @@

Fiche entreprise - {{ entreprise.nom }} ({{ entreprise.siret }})

-
-

+

+
SIRET : {{ entreprise.siret }}
Nom : {{ entreprise.nom }}
Adresse : {{ entreprise.adresse }}
Code postal : {{ entreprise.codepostal }}
Ville : {{ entreprise.ville }}
Pays : {{ entreprise.pays }} -

+
{% if contacts %}
{% for contact in contacts %} - Contact {{loop.index}}
-

+

Contact

+
Nom : {{ contact.nom }}
Prénom : {{ contact.prenom }}
Téléphone : {{ contact.telephone }}
@@ -32,14 +32,14 @@ {% if contact.service %} Service : {{ contact.service }}
{% endif %} -

+
{% endfor %}
{% endif %}
{% endblock %} \ No newline at end of file diff --git a/app/templates/entreprises/offres_expirees.html b/app/templates/entreprises/offres_expirees.html index 057afee55..1c94a0937 100644 --- a/app/templates/entreprises/offres_expirees.html +++ b/app/templates/entreprises/offres_expirees.html @@ -6,7 +6,6 @@

Offres expirées de {{ entreprise.nom }}

{% 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 %} diff --git a/app/templates/entreprises/offres_recues.html b/app/templates/entreprises/offres_recues.html index 9aeb4542e..36163d829 100644 --- a/app/templates/entreprises/offres_recues.html +++ b/app/templates/entreprises/offres_recues.html @@ -4,19 +4,23 @@ {% block app_content %}

{{ title }}

- {% if offres_recus %} + {% if offres_recues %}
- {% for offre in offres_recus %} -
-

- Date envoi : {{ offre[0].date_envoi.strftime('%d/%m/%Y %H:%M') }}
+ {% for offre in offres_recues %} +

+
+ Envoyé le {{ offre[0].date_envoi.strftime('%d %B %Y à %H:%M') }} par {{ offre[0].sender_id|get_nomcomplet_by_id }}
Intitulé : {{ offre[1].intitule }}
Description : {{ offre[1].description }}
Type de l'offre : {{ offre[1].type_offre }}
Missions : {{ offre[1].missions }}
Durée : {{ offre[1].duree }}
-

+ + {% for fichier in offre[2] %} + {{ fichier[1] }}
+ {% endfor %} +
{% endfor %}
diff --git a/app/templates/entreprises/validate_confirmation.html b/app/templates/entreprises/validate_confirmation.html new file mode 100644 index 000000000..04ab1eac1 --- /dev/null +++ b/app/templates/entreprises/validate_confirmation.html @@ -0,0 +1,15 @@ +{# -*- mode: jinja-html -*- #} +{% extends 'base.html' %} +{% import 'bootstrap/wtf.html' as wtf %} + +{% block app_content %} +

{{ title }}

+
+
Cliquez sur le bouton Valider pour confirmer votre validation
+
+
+
+ {{ wtf.quick_form(form) }} +
+
+{% endblock %} \ No newline at end of file