Skip to content

Commit

Permalink
Final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Jun 26, 2024
1 parent aecf516 commit 11e5e2f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
28 changes: 27 additions & 1 deletion lemarche/siaes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions lemarche/templates/dashboard/_siae_activity_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<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>
<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>
</div>
Expand Down
2 changes: 0 additions & 2 deletions lemarche/utils/templatetags/array_choices_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ def array_choices_display(obj, field, output_format="string"):
except: # noqa
keys = getattr(obj, field, [])

print(obj, field, keys)
values = choice_array_to_values(choices_dict, keys, output_format="list")
print(values, len(values))

# output format
if output_format == "list":
Expand Down
2 changes: 1 addition & 1 deletion lemarche/www/dashboard_siaes/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 11e5e2f

Please sign in to comment.