From 511f06ac06d4e3cc23a6648e6c19b7ebc35d20a7 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Wed, 26 Jun 2024 11:37:40 +0200 Subject: [PATCH] Final fixes --- lemarche/siaes/models.py | 28 ++++++++++++++++++- .../dashboard/_siae_activity_card.html | 6 ++-- lemarche/www/dashboard_siaes/urls.py | 2 +- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lemarche/siaes/models.py b/lemarche/siaes/models.py index e1ef4c8db..30e35e8fc 100644 --- a/lemarche/siaes/models.py +++ b/lemarche/siaes/models.py @@ -1441,7 +1441,33 @@ class Meta: @property def presta_type_display(self) -> str: - return choice_array_to_string(siae_constants.PRESTA_CHOICES, self.presta_type) + return choice_array_to_values(siae_constants.PRESTA_CHOICES, self.presta_type) + + @property + def geo_range_pretty_display(self): + if self.geo_range == siae_constants.GEO_RANGE_COUNTRY: + return self.get_geo_range_display() + elif self.geo_range == siae_constants.GEO_RANGE_REGION: + return f"{self.get_geo_range_display().lower()} ({self.siae.region})" + elif self.geo_range == siae_constants.GEO_RANGE_DEPARTMENT: + return f"{self.get_geo_range_display().lower()} ({self.siae.department})" + elif self.geo_range == siae_constants.GEO_RANGE_CUSTOM: + if self.geo_range_custom_distance: + return f"{self.geo_range_custom_distance} km" + return "non disponible" + + @property + def geo_range_pretty_title(self): + if self.geo_range == siae_constants.GEO_RANGE_COUNTRY: + return self.geo_range_pretty_display + elif self.geo_range == siae_constants.GEO_RANGE_REGION: + return self.siae.region + elif self.geo_range == siae_constants.GEO_RANGE_DEPARTMENT: + return self.siae.get_department_display() + elif self.geo_range == siae_constants.GEO_RANGE_CUSTOM: + if self.geo_range_custom_distance: + return f"{self.geo_range_pretty_display} de {self.siae.city}" + return self.geo_range_pretty_display class SiaeOffer(models.Model): diff --git a/lemarche/templates/dashboard/_siae_activity_card.html b/lemarche/templates/dashboard/_siae_activity_card.html index 7f328efea..92c89b5d9 100644 --- a/lemarche/templates/dashboard/_siae_activity_card.html +++ b/lemarche/templates/dashboard/_siae_activity_card.html @@ -15,9 +15,9 @@ {{ activity.presta_type_display }}

- - Situé à {{ activity.location }} - {{ activity.location }} + + Intervient sur : {{ siae.geo_range_pretty_title }} + {{ siae.geo_range_pretty_display }}

diff --git a/lemarche/www/dashboard_siaes/urls.py b/lemarche/www/dashboard_siaes/urls.py index 1195d62fa..1a9ded358 100644 --- a/lemarche/www/dashboard_siaes/urls.py +++ b/lemarche/www/dashboard_siaes/urls.py @@ -34,7 +34,7 @@ ), path("contact/", SiaeEditContactView.as_view(), name="siae_edit_contact"), path("recherche/", SiaeEditSearchView.as_view(), name="siae_edit_search"), - path("activite/", SiaeEditActivitiesView.as_view(), name="siae_edit_activities"), + path("activites/", SiaeEditActivitiesView.as_view(), name="siae_edit_activities"), 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"),