Skip to content

Commit

Permalink
fix: cities display on string (refs #3585)
Browse files Browse the repository at this point in the history
Avant: La liste des "cities" était retournée dans un tableau.

Maintenant: Elle est retournée sous forme de "string" avec chaque ville / commune
séparées par des virgules
  • Loading branch information
juggler31 committed Sep 12, 2023
1 parent 820eb65 commit 8263169
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion geotrek/infrastructure/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,13 @@ def type_display(self):

@property
def cities_display(self):
return [str(c) for c in self.cities] if hasattr(self, 'cities') else []
all_cities_name = []
if hasattr(self, 'cities'):
for city in self.cities:
all_cities_name.append(city.name)
return ", ".join(all_cities_name)
else:
return ""

@classproperty
def cities_verbose_name(cls):
Expand Down
2 changes: 1 addition & 1 deletion geotrek/infrastructure/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_expected_json_attrs(self):

def get_expected_datatables_attrs(self):
return {
'cities': '[]',
'cities': '',
'condition': self.obj.condition.label,
'id': self.obj.pk,
'name': self.obj.name_display,
Expand Down

0 comments on commit 8263169

Please sign in to comment.