From 0c02ab9ba019882a32ff3da3d562ccf78d06cbee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Odini?= <raphodn@users.noreply.github.com>
Date: Wed, 3 Jul 2024 16:49:33 +0200
Subject: [PATCH] =?UTF-8?q?feat(Structures):=20SiaeActivity=20:=20afficher?=
 =?UTF-8?q?=20les=20activit=C3=A9s=20dans=20la=20fiche=20(#1308)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../dashboard/siae_edit_activities.html       |  2 +-
 .../siae_edit_activities_create.html          |  2 +-
 .../_siae_activity_card.html                  | 19 ++-----------
 .../siaes/_siae_activity_content.html         | 28 +++++++++++++++++++
 lemarche/templates/siaes/detail.html          | 19 +++++++++----
 5 files changed, 45 insertions(+), 25 deletions(-)
 rename lemarche/templates/{dashboard => siaes}/_siae_activity_card.html (57%)
 create mode 100644 lemarche/templates/siaes/_siae_activity_content.html

diff --git a/lemarche/templates/dashboard/siae_edit_activities.html b/lemarche/templates/dashboard/siae_edit_activities.html
index 9afd19100..419826d23 100644
--- a/lemarche/templates/dashboard/siae_edit_activities.html
+++ b/lemarche/templates/dashboard/siae_edit_activities.html
@@ -17,7 +17,7 @@ <h3>Ajoutez vos secteurs d'activité et recevez des opportunités commerciales c
     <div class="row mb-3 mb-lg-5">
         {% for activity in siae.activities.all %}
             <div class="col-12 col-lg-8">
-                {% include "dashboard/_siae_activity_card.html" with activity=activity %}
+                {% include "siaes/_siae_activity_card.html" with activity=activity %}
             </div>
         {% endfor %}
     </div>
diff --git a/lemarche/templates/dashboard/siae_edit_activities_create.html b/lemarche/templates/dashboard/siae_edit_activities_create.html
index 5767defb7..b72a2bd4a 100644
--- a/lemarche/templates/dashboard/siae_edit_activities_create.html
+++ b/lemarche/templates/dashboard/siae_edit_activities_create.html
@@ -41,7 +41,7 @@ <h3>{{ page_title }}</h3>
                     {% if activity %}
                         <div class="row mb-3 mb-lg-5">
                             <div class="col-12 col-lg-8">
-                                {% include "dashboard/_siae_activity_card.html" with activity=activity hide_actions=True %}
+                                {% include "siaes/_siae_activity_card.html" with activity=activity hide_actions=True %}
                             </div>
                         </div>
                     {% endif %}
diff --git a/lemarche/templates/dashboard/_siae_activity_card.html b/lemarche/templates/siaes/_siae_activity_card.html
similarity index 57%
rename from lemarche/templates/dashboard/_siae_activity_card.html
rename to lemarche/templates/siaes/_siae_activity_card.html
index 816a7e714..fd435d12a 100644
--- a/lemarche/templates/dashboard/_siae_activity_card.html
+++ b/lemarche/templates/siaes/_siae_activity_card.html
@@ -1,24 +1,9 @@
-{% load static siae_sectors_display %}
+{% load siae_sectors_display %}
 
 <div class="bg-white d-block rounded-lg shadow-lg p-3 mb-3">
     <div class="row">
         <div class="col-12 col-lg-8">
-            <p class="h4 lh-sm">{{ activity.sector_group }}</p>
-
-            <ul>
-                {% siae_sectors_display activity display_max=6 output_format='li' %}
-            </ul>
-
-            <p class="mb-0">
-                <i class="ri-briefcase-4-line mr-1"></i>
-                <span class="sr-only">Type(s) de prestation :</span>
-                <span>{{ activity.presta_type_display }}</span>
-            </p>
-            <p class="mb-0">
-                <i class="ri-map-2-line"></i>
-                <span class="sr-only">Intervient sur : {{ siae.geo_range_pretty_title }}</span>
-                <span>{{ siae.geo_range_pretty_display }}</span>
-            </p>
+            {% include "siaes/_siae_activity_content.html" with activity=activity with_collapse=with_collapse %}
         </div>
 
         {% if not hide_actions %}
diff --git a/lemarche/templates/siaes/_siae_activity_content.html b/lemarche/templates/siaes/_siae_activity_content.html
new file mode 100644
index 000000000..9581f8daf
--- /dev/null
+++ b/lemarche/templates/siaes/_siae_activity_content.html
@@ -0,0 +1,28 @@
+{% load siae_sectors_display %}
+
+<p class="h4 lh-sm">
+    {% if with_collapse %}
+        <a href="#collapseSiaeActiviyContent{{ activity.id }}" class="text-decoration-none has-collapse-caret collapsed" data-toggle="collapse">
+            {{ activity.sector_group }}
+        </a>
+    {% else %}
+        {{ activity.sector_group }}
+    {% endif %}
+</p>
+
+<div id="collapseSiaeActiviyContent{{ activity.id }}" class="{% if with_collapse %}pb-3 collapse{% endif %}">
+    <ul style="padding-left:1.5rem">
+        {% siae_sectors_display activity display_max=6 output_format='li' %}
+    </ul>
+
+    <p class="mb-0">
+        <i class="ri-briefcase-4-line mr-1"></i>
+        <span class="sr-only">Type(s) de prestation :</span>
+        <span>{{ activity.presta_type_display }}</span>
+    </p>
+    <p class="mb-0">
+        <i class="ri-map-2-line"></i>
+        <span class="sr-only">Intervient sur : {{ siae.geo_range_pretty_title }}</span>
+        <span>{{ siae.geo_range_pretty_display }}</span>
+    </p>
+</div>
diff --git a/lemarche/templates/siaes/detail.html b/lemarche/templates/siaes/detail.html
index a09f9c1f7..c59551495 100644
--- a/lemarche/templates/siaes/detail.html
+++ b/lemarche/templates/siaes/detail.html
@@ -91,11 +91,18 @@ <h3 class="h2 mb-1 mt-1">Présentation du prestataire</h3>
                             </div>
                             <div class="il-r">
                                 <h3 class="h2 mb-1 mt-1">Secteurs d'activité</h3>
-                                <ul>
-                                    {% siae_sectors_display siae display_max=6 current_search_query=current_search_query output_format='li' %}
-                                </ul>
-                                {% if not siae.sector_count %}
-                                    <p>Non renseigné</p>
+                                {% if user.is_authenticated and user.is_admin %}
+                                    {% for activity in siae.activities.all %}
+                                        {% include "siaes/_siae_activity_content.html" with activity=activity with_collapse=True %}
+                                    {% endfor %}
+                                {% else %}
+                                    {% if not siae.sector_count %}
+                                        <p>Non renseigné</p>
+                                    {% else %}
+                                        <ul>
+                                            {% siae_sectors_display siae display_max=6 current_search_query=current_search_query output_format='li' %}
+                                        </ul>
+                                    {% endif %}
                                 {% endif %}
                             </div>
                         </div>
@@ -122,7 +129,7 @@ <h3 class="h2 mb-1 mt-1">Références clients</h3>
                                             </li>
                                         {% endfor %}
                                         </ul>
-                                        <div class="collapse" id="collapseMoreRefClients">
+                                        <div id="collapseMoreRefClients" class="collapse">
                                             <ul class="list-unstyled row row-cols-3 align-items-center mb-0">
                                             {% for image in siae.client_references.all|slice:"6:" %}
                                                 <li class="col">