Skip to content

Commit

Permalink
Siae edit form: basic activity list display
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Jun 18, 2024
1 parent aaaec6e commit f646813
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lemarche/siaes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,10 @@ class Meta:
verbose_name_plural = "Activités"
ordering = ["-created_at"]

@property
def presta_type_display(self) -> str:
return choice_array_to_string(siae_constants.PRESTA_CHOICES, self.presta_type)


class SiaeOffer(models.Model):
name = models.CharField(verbose_name="Nom", max_length=255)
Expand Down
39 changes: 39 additions & 0 deletions lemarche/templates/dashboard/_siae_activity_card.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% load static siae_sectors_display %}

<div class="bg-white d-block rounded-lg shadow-lg p-3 p-lg-5">
<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-pin-line"></i>
<span class="sr-only">Situé à {{ activity.location }}</span>
<span>{{ activity.location }}</span>
</p>
</div>
<!--
<div class="col-12 col-lg-4 text-right">
<a href="" class="btn btn-outline-primary btn-sm btn-ico" disabled>
<i class="ri-pencil-fill ri-lg"></i>
<span>Modifier</span>
</a>
<br />
<br />
<a href="" class="btn btn-outline-secondary btn-sm btn-ico" disabled>
<i class="ri-delete-bin-line ri-lg"></i>
<span>Supprimer</span>
</a>
</div>
</div>
-->
</div>
</div>
5 changes: 5 additions & 0 deletions lemarche/templates/dashboard/siae_edit_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
Votre référencement
</a>
</li>
<li class="nav-item" role="presentation">
<a href="{% url 'dashboard_siaes:siae_edit_search_2' siae.slug %}#editTabs" id="siae-edit-search-2-tab" class="nav-link {% if 'siae_edit_search_2' in request.resolver_match.url_name %}active{% endif %}" aria-selected="{% if 'siae_edit_search_2' in request.resolver_match.url_name %}true{% else %}false{% endif %}">
Votre référencement (2)
</a>
</li>
<li class="nav-item" role="presentation">
<a href="{% url 'dashboard_siaes:siae_edit_info' siae.slug %}#editTabs" id="siae-edit-info-tab" class="nav-link {% if 'siae_edit_info' in request.resolver_match.url_name %}active{% endif %}" aria-selected="{% if 'siae_edit_info' in request.resolver_match.url_name %}true{% else %}false{% endif %}">
Votre structure
Expand Down
23 changes: 23 additions & 0 deletions lemarche/templates/dashboard/siae_edit_search_2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends "dashboard/siae_edit_base.html" %}
{% load static bootstrap4 %}

{% block content_siae_form %}
<div class="row mb-3">
<div class="col-12">
<h3>Ajoutez vos secteurs d'activité et recevez des opportunités commerciales ciblées</h3>
</div>
</div>

{% if siae.activities.count %}
<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 %}
</div>
{% endfor %}
</div>
{% endif %}
{% endblock %}

{% block extra_js %}
{% endblock %}
11 changes: 7 additions & 4 deletions lemarche/utils/templatetags/siae_sectors_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@


@register.simple_tag
def siae_sectors_display(siae, display_max=5, current_search_query="", output_format="string"):
"""Pretty rendering of M2M fields."""
def siae_sectors_display(object, display_max=5, current_search_query="", output_format="string"):
"""
Pretty rendering of M2M fields.
- object can be Siae, SectorGroup, SiaeActivity...
"""

values = []
for sector in siae.sectors.all():
for sector in object.sectors.all():
values.append({"slug": sector.slug, "name": sector.name})

# if the search query contains sectors, filter values on these sectors
if "sectors=" in current_search_query:
values = [elem for elem in values if elem["slug"] in current_search_query]
# if SIAE ETTI with many sectors, then display simply "Multisectoriel"
elif hasattr(siae, "kind") and siae.kind == "ETTI" and len(values) > 3:
elif hasattr(object, "kind") and object.kind == "ETTI" and len(values) > 3:
values = [{"name": "Multisectoriel"}]

# get list of names
Expand Down
2 changes: 2 additions & 0 deletions lemarche/www/dashboard_siaes/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
SiaeEditInfoView,
SiaeEditLinksView,
SiaeEditOfferView,
SiaeEditSearch2View,
SiaeEditSearchView,
SiaeSearchAdoptConfirmView,
SiaeSearchBySiretView,
Expand Down Expand Up @@ -33,6 +34,7 @@
),
path("contact/", SiaeEditContactView.as_view(), name="siae_edit_contact"),
path("recherche/", SiaeEditSearchView.as_view(), name="siae_edit_search"),
path("recherche_2/", SiaeEditSearch2View.as_view(), name="siae_edit_search_2"),
path("info/", SiaeEditInfoView.as_view(), name="siae_edit_info"),
path("offre/", SiaeEditOfferView.as_view(), name="siae_edit_offer"),
path("liens/", SiaeEditLinksView.as_view(), name="siae_edit_links"),
Expand Down
11 changes: 11 additions & 0 deletions lemarche/www/dashboard_siaes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ def get_success_url(self):
return reverse_lazy("dashboard_siaes:siae_edit_search", args=[self.kwargs.get("slug")])


class SiaeEditSearch2View(SiaeMemberRequiredMixin, SuccessMessageMixin, UpdateView):
form_class = SiaeEditSearchForm
template_name = "dashboard/siae_edit_search_2.html"
context_object_name = "siae"
queryset = Siae.objects.all()
success_message = "Vos modifications ont bien été prises en compte."

def get_success_url(self):
return reverse_lazy("dashboard_siaes:siae_edit_search_2", args=[self.kwargs.get("slug")])


class SiaeEditInfoView(SiaeMemberRequiredMixin, SuccessMessageMixin, UpdateView):
form_class = SiaeEditInfoForm
template_name = "dashboard/siae_edit_info.html"
Expand Down

0 comments on commit f646813

Please sign in to comment.