Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Activités des structures): Passage du formulaire "Votre référencement" en lecture seule #1498

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 56 additions & 63 deletions lemarche/templates/dashboard/siae_edit_search.html
Original file line number Diff line number Diff line change
@@ -1,76 +1,69 @@
{% extends "dashboard/siae_edit_base.html" %}
{% load static dsfr_tags %}

{% block content_siae_form %}
<form method="post" action="">
{% csrf_token %}
{% if form.non_field_errors %}
<section class="fr-my-4v fr-input-group fr-input-group--error">
{{ form.non_field_errors }}
</section>
{% endif %}
<div class="fr-grid-row fr-mb-4v">
<div class="fr-col-12">
<h3>Réferencez efficacement votre structure dans les résultats de recherche</h3>
</div>
</div>

<div class="fr-grid-row fr-grid-row--gutters fr-mb-4v">
<div class="fr-col-12 fr-col-lg-8">
{% dsfr_form_field form.presta_type %}
</div>
<div class="fr-col-12 fr-col-lg-4">
<div class="fr-callout fr-p-4v">
<h3 class="fr-callout__title fr-text--sm"><span class="fr-icon-lightbulb-line" aria-hidden="true"></span> Type de prestation</h3>
<p class="fr-callout__text fr-text--sm fr-pl-7v">
Vous pourrez ensuite détailler vos prestations dans l'onglet <strong>offre commerciale</strong>.
</p>
<form method="post" action="">
{% csrf_token %}
{% if form.non_field_errors %}
<section class="fr-my-4v fr-input-group fr-input-group--error">
{{ form.non_field_errors }}
</section>
{% endif %}
<div class="fr-grid-row fr-mb-4v">
<div class="fr-col-12">
<h3>Réferencez efficacement votre structure dans les résultats de recherche</h3>
<div class="fr-alert fr-alert--warning">
<p>
Les informations ne sont actuellement plus éditables, car la refonte de cette fonctionnalité est en cours de déploiement.
</p>
</div>
</div>
</div>
</div>

<div class="fr-grid-row fr-grid-row--gutters fr-mb-4v">
<div class="fr-col-12 fr-col-lg-8">
{% dsfr_form_field form.geo_range %}
{{ form.geo_range_custom_distance }}
</div>
<div class="fr-col-12 fr-col-lg-4">
<div class="fr-callout fr-p-4v">
<h3 class="fr-callout__title fr-text--sm"><span class="fr-icon-lightbulb-line" aria-hidden="true"></span> Périmètre d'intervention</h3>
<p class="fr-callout__text fr-text--sm fr-pl-7v">
Le périmètre d'intervention est un critère essentiel dans le choix des acheteurs.
Il est nécessaire de bien le renseigner.
</p>
<div class="fr-grid-row fr-grid-row--gutters fr-mb-4v">
<div class="fr-col-12 fr-col-lg-8">{% dsfr_form_field form.presta_type %}</div>
<div class="fr-col-12 fr-col-lg-4">
<div class="fr-callout fr-p-4v">
<h3 class="fr-callout__title fr-text--sm">
<span class="fr-icon-lightbulb-line" aria-hidden="true"></span> Type de prestation
</h3>
<p class="fr-callout__text fr-text--sm fr-pl-7v">
Vous pourrez ensuite détailler vos prestations dans l'onglet <strong>offre commerciale</strong>.
</p>
</div>
</div>
</div>
</div>

<div class="fr-grid-row fr-grid-row--gutters fr-mb-4v">
<div class="fr-col-12 fr-col-lg-8">
{% dsfr_form_field form.sectors %}
</div>
<div class="fr-col-12 fr-col-lg-4">
<div class="fr-callout fr-p-4v">
<h3 class="fr-callout__title fr-text--sm"><span class="fr-icon-lightbulb-line" aria-hidden="true"></span> Secteurs d'activité</h3>
<p class="fr-callout__text fr-text--sm fr-pl-7v">
Améliorez votre référencement en indiquant tous les secteurs d'activités sur lesquels votre struture est positionnée.
</p>
<div class="fr-grid-row fr-grid-row--gutters fr-mb-4v">
<div class="fr-col-12 fr-col-lg-8">
{% dsfr_form_field form.geo_range %}
{{ form.geo_range_custom_distance }}
</div>
<div class="fr-col-12 fr-col-lg-4">
<div class="fr-callout fr-p-4v">
<h3 class="fr-callout__title fr-text--sm">
<span class="fr-icon-lightbulb-line" aria-hidden="true"></span> Périmètre d'intervention
</h3>
<p class="fr-callout__text fr-text--sm fr-pl-7v">
Le périmètre d'intervention est un critère essentiel dans le choix des acheteurs.
Il est nécessaire de bien le renseigner.
</p>
</div>
</div>
</div>
</div>
<div class="fr-grid-row">
<div class="fr-col-12 fr-col-lg-8">
<ul class="fr-btns-group--right fr-btns-group fr-btns-group--inline">
<li>
{% dsfr_button label="Enregistrer mes modifications" extra_classes="fr-mt-4v" %}
</li>
</ul>
<div class="fr-grid-row fr-grid-row--gutters fr-mb-4v">
<div class="fr-col-12 fr-col-lg-8">{% dsfr_form_field form.sectors %}</div>
<div class="fr-col-12 fr-col-lg-4">
<div class="fr-callout fr-p-4v">
<h3 class="fr-callout__title fr-text--sm">
<span class="fr-icon-lightbulb-line" aria-hidden="true"></span> Secteurs d'activité
</h3>
<p class="fr-callout__text fr-text--sm fr-pl-7v">
Améliorez votre référencement en indiquant tous les secteurs d'activités sur lesquels votre struture est positionnée.
</p>
</div>
</div>
</div>
<div class="fr-col-12 fr-col-lg-4"></div>
</div>
</form>
</form>
{% endblock content_siae_form %}

{% block extra_js %}
<script type="text/javascript" src="{% static 'js/siae_geo_range_field.js' %}"></script>
<script type="text/javascript"
src="{% static 'js/siae_geo_range_field.js' %}"></script>
{% endblock extra_js %}
3 changes: 3 additions & 0 deletions lemarche/www/dashboard_siaes/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,22 @@ class SiaeEditSearchForm(forms.ModelForm):
choices=siae_constants.PRESTA_CHOICES,
required=True,
widget=forms.CheckboxSelectMultiple,
disabled=True,
)
geo_range = forms.ChoiceField(
label=Siae._meta.get_field("geo_range").verbose_name,
choices=siae_constants.GEO_RANGE_CHOICES,
required=True,
widget=forms.RadioSelect,
disabled=True,
)
sectors = GroupedModelMultipleChoiceField(
label=Sector._meta.verbose_name_plural,
queryset=Sector.objects.form_filter_queryset(),
choices_groupby="group",
required=True,
widget=forms.CheckboxSelectMultiple,
disabled=True,
)

class Meta:
Expand Down
19 changes: 14 additions & 5 deletions lemarche/www/siaes/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest import mock

from django.contrib.gis.geos import Point
from django.contrib.sites.models import Site
from django.test import TestCase
from django.urls import reverse

Expand Down Expand Up @@ -58,6 +59,11 @@ def setUpTestData(cls):

def test_search_num_queries(self):
url = reverse("siae:search_results")

# fix cache issue in parallel testing context because only first call fetches database
# See https://docs.djangoproject.com/en/5.1/ref/contrib/sites/#caching-the-current-site-object
Site.objects.get_current()

with self.assertNumQueries(12):
response = self.client.get(url)
siaes = list(response.context["siaes"])
Expand Down Expand Up @@ -1032,11 +1038,14 @@ def test_search_query_no_result(self):
mock_siaes_similarity_search.assert_called_once()

def test_search_query_with_results(self):
with mock.patch(
"lemarche.utils.apis.api_elasticsearch.siaes_similarity_search"
) as mock_siaes_similarity_search, mock.patch(
"lemarche.utils.apis.api_elasticsearch.siaes_similarity_search_with_city"
) as mock_siaes_similarity_search_with_city:
with (
mock.patch(
"lemarche.utils.apis.api_elasticsearch.siaes_similarity_search"
) as mock_siaes_similarity_search,
mock.patch(
"lemarche.utils.apis.api_elasticsearch.siaes_similarity_search_with_city"
) as mock_siaes_similarity_search_with_city,
):
mock_siaes_similarity_search.return_value = [self.siae_two.pk, self.siae_three.pk, self.siae_four.pk]
url = self.url + "?semantic_q=entretien espace vert&id_semantic_city_name=&semantic_city="
response = self.client.get(url)
Expand Down
Loading