From ed8b86f5ce6e81fe3dbe1d94acc15ab9e41dca7f Mon Sep 17 00:00:00 2001 From: Vencespass Date: Wed, 22 May 2024 17:48:56 +0200 Subject: [PATCH] (PC-29891)[BO] feat: use build_modal_form more often in BO --- .../routes/backoffice/pro_users/blueprint.py | 2 +- .../templates/accounts/get/general.html | 72 ++-------------- .../templates/admin/users_generator.html | 2 +- .../templates/bank_account/get.html | 33 +------- .../templates/components/generic_modal.html | 22 ++--- .../public_accounts/registration_steps.html | 2 +- .../multiple_offers/search_result.html | 3 +- .../backoffice/templates/offer/details.html | 32 +------ .../backoffice/templates/offerer/get.html | 83 +++---------------- .../templates/offerer/get/details/users.html | 39 +-------- .../templates/offerer/offerer_tag.html | 63 +------------- .../backoffice/templates/pro_user/get.html | 39 ++------- .../backoffice/templates/tags/list_tags.html | 32 +------ .../backoffice/templates/venue/get.html | 74 +---------------- 14 files changed, 56 insertions(+), 442 deletions(-) diff --git a/api/src/pcapi/routes/backoffice/pro_users/blueprint.py b/api/src/pcapi/routes/backoffice/pro_users/blueprint.py index 7e7af83bb8d..b734e599381 100644 --- a/api/src/pcapi/routes/backoffice/pro_users/blueprint.py +++ b/api/src/pcapi/routes/backoffice/pro_users/blueprint.py @@ -288,7 +288,7 @@ def _user_can_be_deleted(user: users_models.User) -> bool: def _get_delete_kwargs(user: users_models.User) -> dict: kwargs = { "can_be_deleted": _user_can_be_deleted(user), - "delete_dest": url_for("backoffice_web.pro_user.delete", user_id=user.id), + "delete_dst": url_for("backoffice_web.pro_user.delete", user_id=user.id), "delete_form": pro_users_forms.DeleteProUser(), } return kwargs diff --git a/api/src/pcapi/routes/backoffice/templates/accounts/get/general.html b/api/src/pcapi/routes/backoffice/templates/accounts/get/general.html index 6713f2e51b4..0a901ec51ab 100644 --- a/api/src/pcapi/routes/backoffice/templates/accounts/get/general.html +++ b/api/src/pcapi/routes/backoffice/templates/accounts/get/general.html @@ -26,37 +26,7 @@
{% if edit_account_form %} - - + {{ build_modal_form("edit-account", edit_account_dst, edit_account_form, "Modifier les informations", "Modifier les informations", "Enregistrer") }} {% endif %} {% if user.isActive %} {% endblock page %} diff --git a/api/src/pcapi/routes/backoffice/templates/bank_account/get.html b/api/src/pcapi/routes/backoffice/templates/bank_account/get.html index dd5fc16471a..1a6753d6abf 100644 --- a/api/src/pcapi/routes/backoffice/templates/bank_account/get.html +++ b/api/src/pcapi/routes/backoffice/templates/bank_account/get.html @@ -1,5 +1,5 @@ {% import "components/clipboard.html" as clipboard %} -{% from "components/forms.html" import build_form_fields_group with context %} +{% from "components/generic_modal.html" import build_modal_form with context %} {% import "components/links.html" as links %} {% from "components/presentation/details/tabs.html" import build_details_tab %} {% from "components/presentation/details/tabs.html" import build_details_tabs_wrapper %} @@ -22,36 +22,7 @@

{{ bank_account.label }}

{% if edit_form %} {% set edit_bank_account_aria_described_by_id = random_hash() %} - - + {{ build_modal_form("edit-bank-account", url_for("backoffice_web.bank_account.update_bank_account", bank_account_id=bank_account.id) , edit_form, "Modifier les informations", "Modifier les informations du compte bancaire", "Enregistrer") }} {% endif %} {% if dms_stats %} {{ title }} - diff --git a/api/src/pcapi/routes/backoffice/templates/components/public_accounts/registration_steps.html b/api/src/pcapi/routes/backoffice/templates/components/public_accounts/registration_steps.html index 5d8f3797825..d39fcd382af 100644 --- a/api/src/pcapi/routes/backoffice/templates/components/public_accounts/registration_steps.html +++ b/api/src/pcapi/routes/backoffice/templates/components/public_accounts/registration_steps.html @@ -94,7 +94,7 @@
                              
{{ fraud_action['technicalDetails'] | tojson(indent=4) | safe | empty_string_if_null }}
-
+
diff --git a/api/src/pcapi/routes/backoffice/templates/offerer/get.html b/api/src/pcapi/routes/backoffice/templates/offerer/get.html index 6253c19817f..bff1151ef39 100644 --- a/api/src/pcapi/routes/backoffice/templates/offerer/get.html +++ b/api/src/pcapi/routes/backoffice/templates/offerer/get.html @@ -23,86 +23,23 @@

{{ links.build_offerer_name_to_pc_pro_link(o {{ build_offerer_badges(offerer) }}
{% if has_permission("MANAGE_PRO_ENTITY") %} - - + {{ build_modal_form("edit-offerer", url_for("backoffice_web.offerer.update_offerer", offerer_id=offerer.id) , + edit_offerer_form, "Modifier les informations", "Modifier les informations de la structure", "Enregistrer") }} {% endif %} {% if has_permission("PRO_FRAUD_ACTIONS") %} {% if offerer.isActive %} - {{ build_modal_form("suspend", url_for("backoffice_web.offerer.suspend_offerer", offerer_id=offerer.id) , - suspension_form, "Suspendre la structure", "Confirmer la suspension") }} + {{ build_modal_form("suspend-offerer", url_for("backoffice_web.offerer.suspend_offerer", offerer_id=offerer.id) , + suspension_form, "Suspendre la structure", "Suspendre la structure", "Confirmer la suspension") }} {% else %} - {{ build_modal_form("unsuspend", url_for("backoffice_web.offerer.unsuspend_offerer", offerer_id=offerer.id) , - suspension_form, "Réactiver la structure", "Confirmer la réactivation") }} + {{ build_modal_form("unsuspend-offerer", url_for("backoffice_web.offerer.unsuspend_offerer", offerer_id=offerer.id) , + suspension_form, "Réactiver la structure", "Réactiver la structure", "Confirmer la réactivation") }} {% endif %} {% endif %} {% if has_permission("DELETE_PRO_ENTITY") %} - - + {% set form_description = "La structure "|safe + offerer.name + " ("|safe + offerer.id|string + ") sera définitivement supprimée de la base de données. Veuillez confirmer ce choix." %} + {{ build_modal_form("delete-offerer", url_for("backoffice_web.offerer.delete_offerer", offerer_id=offerer.id) , + delete_offerer_form, "Supprimer la structure", "Supprimer la structure " + offerer.name, + "Confirmer", form_description, "bi-trash3-fill") }} {% endif %}

diff --git a/api/src/pcapi/routes/backoffice/templates/offerer/get/details/users.html b/api/src/pcapi/routes/backoffice/templates/offerer/get/details/users.html index c18592c83c6..8790796a5d3 100644 --- a/api/src/pcapi/routes/backoffice/templates/offerer/get/details/users.html +++ b/api/src/pcapi/routes/backoffice/templates/offerer/get/details/users.html @@ -1,6 +1,7 @@ {% from "components/badges.html" import build_user_offerer_status_badge %} {% from "components/badges.html" import build_new_navigation_badge %} {% from "components/badges.html" import build_old_navigation_badge %} +{% from "components/generic_modal.html" import build_modal_form with context %} {% import "components/links.html" as links %} {% from "components/turbo/lazy_modal.html" import build_lazy_modal with context %} {% import "components/clipboard.html" as clipboard %} @@ -8,43 +9,7 @@ {% if has_permission("VALIDATE_OFFERER") %} {% if add_user_form %} {% set add_pro_user_modal_label_id = random_hash() %} - - + {{ build_modal_form("add-pro-user", add_user_dst, add_user_form, "Récupérer un compte pro rejeté", "Récupérer un compte pro rejeté", "Valider le rattachement", "Veuillez sélectionner le compte pro à rattacher à cette structure") }} {% else %} - + {{ build_modal_form("create-offerer-tag", url_for("backoffice_web.offerer_tag.create_offerer_tag") , create_tag_form, "Créer un tag structure", "Créer un tag structure", "Enregistrer") }} {% endif %}
@@ -164,36 +136,7 @@ {% endcall %} {% call tabs.build_details_tab_content("categories", active_tab == 'categories') %} {% if create_category_form %} - - + {{ build_modal_form("create-offerer-tag-category", url_for("backoffice_web.offerer_tag.create_offerer_tag_category") , create_category_form, "Créer une catégorie", "Créer une catégorie", "Enregistrer") }} {% endif %}
diff --git a/api/src/pcapi/routes/backoffice/templates/pro_user/get.html b/api/src/pcapi/routes/backoffice/templates/pro_user/get.html index 36d61353fb4..ae59ee564cc 100644 --- a/api/src/pcapi/routes/backoffice/templates/pro_user/get.html +++ b/api/src/pcapi/routes/backoffice/templates/pro_user/get.html @@ -3,7 +3,6 @@ {% from "components/badges.html" import build_pro_user_status_badge, build_old_navigation_badge, build_new_navigation_badge %} {% from "components/generic_modal.html" import build_modal_form with context %} {% from "components/forms.html" import build_form_fields_group with context %} -{% from "components/generic_modal.html" import build_modal_form with context %} {% from "components/turbo/spinner.html" import build_loading_spinner with context %} {% extends "layouts/pro.html" %} {% block pro_main_content %} @@ -29,44 +28,16 @@

{{ user.firstName }} {{ user.lastName |
{% if has_permission("MANAGE_PRO_ENTITY") %} {% set edit_pro_user_information_label_id = random_hash() %} - - + {{ build_modal_form("edit-pro-user", dst, form, "Modifier les informations", "Modification des informations + de " + user.firstName + " " + user.lastName|upper, "Enregistrer") }} {% endif %} {% if has_permission("PRO_FRAUD_ACTIONS") and user.isActive %} - {{ build_modal_form("suspend", suspension_dst, suspension_form, "Suspendre le compte", "Confirmer la suspension") }} + {{ build_modal_form("suspend-pro-user", suspension_dst, suspension_form, "Suspendre le compte", "Suspendre le compte", "Confirmer la suspension") }} {% elif has_permission("PRO_FRAUD_ACTIONS") and not user.isActive %} - {{ build_modal_form("unsuspend", suspension_dst, suspension_form, "Réactiver le compte", "Confirmer la réactivation") }} + {{ build_modal_form("unsuspend-pro-user", suspension_dst, suspension_form, "Réactiver le compte", "Réactiver le compte", "Confirmer la réactivation") }} {% endif %} {% if has_permission("MANAGE_PRO_ENTITY") and can_be_deleted %} - {{ build_modal_form("delete", delete_dest, delete_form, "Supprimer le compte", "Supprimer le compte", "Pour confirmer la suppression du compte merci de saisir son adresse email") }} + {{ build_modal_form("delete-pro-user", delete_dst, delete_form, "Supprimer le compte", "Supprimer le compte", "Supprimer le compte", "Pour confirmer la suppression du compte merci de saisir son adresse email") }} {% endif %} {% if user.isActive %}

diff --git a/api/src/pcapi/routes/backoffice/templates/venue/get.html b/api/src/pcapi/routes/backoffice/templates/venue/get.html index d9de345ebf5..b457bfb6ae5 100644 --- a/api/src/pcapi/routes/backoffice/templates/venue/get.html +++ b/api/src/pcapi/routes/backoffice/templates/venue/get.html @@ -1,6 +1,7 @@ {% import "components/clipboard.html" as clipboard %} {% from "components/badges.html" import build_venue_badges %} {% from "components/forms.html" import build_form_fields_group with context %} +{% from "components/generic_modal.html" import build_modal_form with context %} {% import "components/links.html" as links %} {% from "components/presentation/details/tabs.html" import build_details_tab %} {% from "components/presentation/details/tabs.html" import build_details_tabs_wrapper %} @@ -63,79 +64,12 @@