From b849c350f11dc2b5cceda1601a93e5c73be84970 Mon Sep 17 00:00:00 2001 From: Arthur ZHU Date: Thu, 17 Feb 2022 20:11:20 +0100 Subject: [PATCH] tableau avec datatables --- app/entreprises/routes.py | 9 +- app/templates/entreprises/contacts.html | 117 +++++++++------- app/templates/entreprises/entreprises.html | 126 ++++++++++-------- .../entreprises/entreprises_validation.html | 98 ++++++++++---- 4 files changed, 215 insertions(+), 135 deletions(-) diff --git a/app/entreprises/routes.py b/app/entreprises/routes.py index e3226c712..547d20511 100644 --- a/app/entreprises/routes.py +++ b/app/entreprises/routes.py @@ -53,10 +53,7 @@ def index(): """ Permet d'afficher une page avec la liste des entreprises et une liste des dernières opérations """ - page = request.args.get("page", 1, type=int) - entreprises = Entreprise.query.filter_by(visible=True).paginate( - page=page, per_page=10 - ) + entreprises = Entreprise.query.filter_by(visible=True) logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).limit(LOGS_LEN).all() return render_template( "entreprises/entreprises.html", @@ -103,12 +100,10 @@ def contacts(): """ Permet d'afficher une page la liste des contacts et une liste des dernières opérations """ - page = request.args.get("page", 1, type=int) contacts = ( db.session.query(EntrepriseContact, Entreprise) .join(Entreprise, EntrepriseContact.entreprise_id == Entreprise.id) .filter_by(visible=True) - .paginate(page=page, per_page=10) ) logs = EntrepriseLog.query.order_by(EntrepriseLog.date.desc()).limit(LOGS_LEN).all() return render_template( @@ -902,7 +897,7 @@ def import_entreprises(): entreprises_import = [] siret_list = [] ligne = 0 - titles = ["siret", "nom_entreprise", "adresse", "ville", "codepostal", "pays"] + titles = ["siret", "nom", "adresse", "ville", "code_postal", "pays"] if data[1][0] != titles: flash("Veuillez utilisez la feuille excel à remplir") return render_template( diff --git a/app/templates/entreprises/contacts.html b/app/templates/entreprises/contacts.html index 7ee982f76..7830f83a2 100644 --- a/app/templates/entreprises/contacts.html +++ b/app/templates/entreprises/contacts.html @@ -1,6 +1,13 @@ {# -*- mode: jinja-html -*- #} {% extends 'base.html' %} +{% block styles %} +{{super()}} + + + +{% endblock %} + {% block app_content %} {% include 'entreprises/nav.html' %} @@ -19,63 +26,77 @@ {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) %} Importer des contacts {% endif %} - {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) and contacts.items %} + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) and contacts %} Exporter la liste des contacts {% endif %}

Liste des contacts

- {% if contacts.items %} -
- +
+ - - - - - - - + + + + + + + - {% for contact in contacts.items %} - - - - - - - - + + + {% for contact in contacts %} + + + + + + + + - {% endfor %} -
NomPrenomTelephoneMailPosteServiceEntrepriseNomPrenomTelephoneMailPosteServiceEntreprise
{{ contact[0].nom }}{{ contact[0].prenom }}{{ contact[0].telephone }}{{ contact[0].mail }}{{ contact[0].poste}}{{ contact[0].service}}{{ contact[1].nom }}
{{ contact[0].nom }}{{ contact[0].prenom }}{{ contact[0].telephone }}{{ contact[0].mail }}{{ contact[0].poste}}{{ contact[0].service}}{{ contact[1].nom }}
-
- -
- - « - - {% for page_num in contacts.iter_pages(left_edge=1, right_edge=1, left_current=1, right_current=2) %} - {% if page_num %} - {% if contacts.page == page_num %} - {{ page_num }} - {% else %} - {{ page_num }} - {% endif %} - {% else %} - ... - {% endif %} {% endfor %} - - » - -
-

- Page {{ contacts.page }} sur {{ contacts.pages }} -

- {% else %} -
Aucun contact présent dans la base
- {% endif %} + + + + Nom + Prenom + Telephone + Mail + Poste + Service + Entreprise + + +
+ + {% endblock %} \ No newline at end of file diff --git a/app/templates/entreprises/entreprises.html b/app/templates/entreprises/entreprises.html index 3219c78dd..8e2768c66 100644 --- a/app/templates/entreprises/entreprises.html +++ b/app/templates/entreprises/entreprises.html @@ -1,6 +1,13 @@ {# -*- mode: jinja-html -*- #} {% extends 'base.html' %} +{% block styles %} +{{super()}} + + + +{% endblock %} + {% block app_content %} {% include 'entreprises/nav.html' %} @@ -22,80 +29,93 @@ {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) %} Importer des entreprises {% endif %} - {% if entreprises %} - {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) and entreprises.items%} - Exporter la liste des entreprises - {% endif %} + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesExport, None) and entreprises %} + Exporter la liste des entreprises {% endif %}

Liste des entreprises

- {% if entreprises.items %} -
- +
+ - - - - - - + + + + + + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} - + {% endif %} - {% for entreprise in entreprises.items %} - - - - - - - + + + {% for entreprise in entreprises %} + + + + + + + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} - {% endif %} {% endfor %} -
SIRETNomAdresseCode postalVillePaysSIRETNomAdresseCode postalVillePaysActionAction
{{ entreprise.siret }}{{ entreprise.nom }}{{ entreprise.adresse }}{{ entreprise.codepostal }}{{ entreprise.ville }}{{ entreprise.pays }}
{{ entreprise.siret }}{{ entreprise.nom }}{{ entreprise.adresse }}{{ entreprise.codepostal }}{{ entreprise.ville }}{{ entreprise.pays }} + - +
-
- -
- - « - - {% for page_num in entreprises.iter_pages(left_edge=1, right_edge=1, left_current=1, right_current=2) %} - {% if page_num %} - {% if entreprises.page == page_num %} - {{ page_num }} - {% else %} - {{ page_num }} + + + + SIRET + Nom + Adresse + Code postal + Ville + Pays + {% if current_user.has_permission(current_user.Permission.RelationsEntreprisesChange, None) %} + Action {% endif %} - {% else %} - ... - {% endif %} - {% endfor %} - - » - -
- -

- Page {{ entreprises.page }} sur {{ entreprises.pages }} -

- {% else %} -
Aucune entreprise présent dans la base
- {% 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 90c787a54..a7fbf0c94 100644 --- a/app/templates/entreprises/entreprises_validation.html +++ b/app/templates/entreprises/entreprises_validation.html @@ -1,6 +1,13 @@ {# -*- mode: jinja-html -*- #} {% extends 'base.html' %} +{% block styles %} +{{super()}} + + + +{% endblock %} + {% block app_content %} {% include 'entreprises/nav.html' %} @@ -17,35 +24,72 @@

Liste des entreprises à valider

- {% if entreprises %} -
- +
+ - - - - - - - + + + + + + + - {% for entreprise in entreprises %} - - - - - - - - + + + {% for entreprise in entreprises %} + + + + + + + + + + {% endfor %} + + + + + + + + + + - {% endfor %} -
SIRETNomAdresseCode postalVillePaysActionSIRETNomAdresseCode postalVillePaysAction
{{ entreprise.siret }}{{ entreprise.nom }}{{ entreprise.adresse }}{{ entreprise.codepostal }}{{ entreprise.ville }}{{ entreprise.pays }} - Voir -
{{ entreprise.siret }}{{ entreprise.nom }}{{ entreprise.adresse }}{{ entreprise.codepostal }}{{ entreprise.ville }}{{ entreprise.pays }} + Voir +
SIRETNomAdresseCode postalVillePaysAction
-
- {% else %} -
Aucune entreprise à valider
- {% endif %} + +
+ + {% endblock %} \ No newline at end of file