Skip to content

Commit

Permalink
display sector_group instead sectors
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienReuiller committed Nov 7, 2024
1 parent caf3a63 commit 222c796
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 37 deletions.
80 changes: 43 additions & 37 deletions lemarche/templates/siaes/_card_search_result.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<div class="fr-col-1">
{% if siae.logo_url %}
<img src="{{ siae.logo_url }}"
class="fr-responsive-img"
alt="Logo de la structure {{ siae.name }}"
loading="lazy" />
class="fr-responsive-img"
alt="Logo de la structure {{ siae.name }}"
loading="lazy" />
{% else %}
<img src="{% static 'img/default-listing.png' %}"
class="fr-responsive-img"
alt="{{ siae.name }}"
loading="lazy" />
class="fr-responsive-img"
alt="{{ siae.name }}"
loading="lazy" />
{% endif %}
</div>
<div class="fr-col-10 fr-col-lg-7">
Expand All @@ -27,7 +27,7 @@ <h3 class="fr-card__title">
{% if siae.is_qpv %}
<li>
<span class="fr-tag"
title="Quartier prioritaire de la politique de la ville">QPV</span>
title="Quartier prioritaire de la politique de la ville">QPV</span>
</li>
{% endif %}
{% if siae.is_zrr %}
Expand All @@ -39,34 +39,29 @@ <h3 class="fr-card__title">
<li>
{% if user.is_authenticated %}
{% if from_profile or siae.in_user_favorite_list_count_annotated %}
<button
id="favorite-remove-modal-btn"
class="fr-btn fr-btn--sm fr-btn--tertiary-no-outline fr-icon-star-fill"
x-data="favoriteItem"
x-init="initOptions('{{ siae.slug }}', '{{ siae.name_display|escapejs }}')"
@click="remove"
title="Dans votre liste d'achat">
Supprimer de votre liste d'achat
</button>
<button id="favorite-remove-modal-btn"
class="fr-btn fr-btn--sm fr-btn--tertiary-no-outline fr-icon-star-fill"
x-data="favoriteItem"
x-init="initOptions('{{ siae.slug }}', '{{ siae.name_display|escapejs }}')"
@click="remove"
title="Dans votre liste d'achat">Supprimer de votre liste d'achat</button>
{% else %}
<button
id="favorite-add-modal-btn"
class="fr-btn fr-btn--sm fr-btn--tertiary-no-outline fr-icon-star-line"
x-data="favoriteItem"
x-init="initOptions('{{ siae.slug }}', '{{ siae.name_display|escapejs }}')"
@click="add"
title="Ajouter à votre liste d'achat">
<button id="favorite-add-modal-btn"
class="fr-btn fr-btn--sm fr-btn--tertiary-no-outline fr-icon-star-line"
x-data="favoriteItem"
x-init="initOptions('{{ siae.slug }}', '{{ siae.name_display|escapejs }}')"
@click="add"
title="Ajouter à votre liste d'achat">
Ajouter à votre liste d'achat
</button>
{% endif %}
{% else %}
<button
id="favorite-modal-btn"
class="fr-btn fr-btn--tertiary-no-outline fr-icon-star-line"
data-fr-opened="false"
aria-controls="login_or_signup_modal"
data-next-params="{% url 'siae:search_results' %}?{{ current_search_query_escaped }}"
title="Ajouter à votre liste d'achat">
<button id="favorite-modal-btn"
class="fr-btn fr-btn--tertiary-no-outline fr-icon-star-line"
data-fr-opened="false"
aria-controls="login_or_signup_modal"
data-next-params="{% url 'siae:search_results' %}?{{ current_search_query_escaped }}"
title="Ajouter à votre liste d'achat">
Se connecter pour Ajouter à votre liste d'achat
</button>
{% endif %}
Expand All @@ -82,17 +77,28 @@ <h3 class="fr-card__title">
</p>
</div>
<div class="fr-col-12 fr-col-lg-6">
<p>{% siae_sectors_display siae display_max=3 current_search_query=current_search_query %}</p>
</div>
</div>
<div class="fr-grid-row fr-grid-row--gutters">
<div class="fr-col-12">
<p class="fr-m-0">
<span class="fr-icon-map-pin-2-line" aria-hidden="true"></span>
{{ siae.city }}
<span class="fr-icon-road-map-line fr-ml-2w" aria-hidden="true"></span>
{{ siae.geo_range_pretty_display }}
</p>
</div>
</div>
<div class="fr-grid-row fr-grid-row--gutters">
<div class="fr-col-12">
<ul class="fr-tags-group">
{% for activity in siae.activities.all %}
{% if forloop.counter <= 4 %}
<li>
<p class="fr-tag">{{ activity.sector_group }}</p>
</li>
{% endif %}
{% endfor %}
{% if siae.activities.count > 4 %}
<li>
<p class="fr-tag">+ {{ siae.activities.count|add:"-4" }}</p>
</li>
{% endif %}
</ul>
{% if user.is_authenticated and user.is_admin and not siae.user_count %}
<p class="fr-card__detail fr-icon-warning-fill fr-mt-3w">pas encore inscrite</p>
{% endif %}
Expand Down
2 changes: 2 additions & 0 deletions lemarche/www/siaes/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ def filter_queryset(self, qs=None): # noqa C901
if not hasattr(self, "cleaned_data"):
self.full_clean()

qs = qs.prefetch_related("activities__sector_group")

sectors = self.cleaned_data.get("sectors", None)
if sectors:
qs = qs.filter_sectors(sectors)
Expand Down

0 comments on commit 222c796

Please sign in to comment.