Skip to content

Commit

Permalink
Split treks by itinerancy
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaël UTARD committed Jun 25, 2018
1 parent 322a891 commit 42349b8
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 50 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CHANGELOG

* Allow to share glossaries between structure
* Optional img-responsive class on flatpage images
* Allow to split treks by itinerancy

**Bug fixes**

Expand Down
6 changes: 4 additions & 2 deletions geotrek/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,12 @@ def gettext_noop(s):

CACHE_TIMEOUT_LAND_LAYERS = 60 * 60 * 24

TREK_CATEGORY_ORDER = None
TOURISTIC_EVENT_CATEGORY_ORDER = None
TREK_CATEGORY_ORDER = 1
ITINERANCY_CATEGORY_ORDER = 2
TOURISTIC_EVENT_CATEGORY_ORDER = 99
SPLIT_TREKS_CATEGORIES_BY_PRACTICE = False
SPLIT_TREKS_CATEGORIES_BY_ACCESSIBILITY = False
SPLIT_TREKS_CATEGORIES_BY_ITINERANCY = False
HIDE_PUBLISHED_TREKS_IN_TOPOLOGIES = False
ZIP_TOURISTIC_CONTENTS_AS_POI = False

Expand Down
2 changes: 1 addition & 1 deletion geotrek/tourism/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def test_type1(self):
def test_category(self):
self.assertDictEqual(self.result['category'],
{u"id": 'E',
u"order": None,
u"order": 99,
u"label": u"Touristic events",
u"slug": u"touristic-event",
u"type1_label": u"Type",
Expand Down
32 changes: 23 additions & 9 deletions geotrek/trekking/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-01-25 14:55+0000\n"
"POT-Creation-Date: 2018-06-25 16:40+0200\n"
"PO-Revision-Date: 2015-10-21 11:16+0200\n"
"Last-Translator: jean-etienne.castagnede@makina-corpus.com\n"
"Language-Team: \n"
Expand Down Expand Up @@ -210,7 +210,7 @@ msgid "Source"
msgstr "Source"

msgid "Portal"
msgstr ""
msgstr "Portail"

msgid "External id"
msgstr "Id externe"
Expand All @@ -234,6 +234,15 @@ msgstr "Impossible d'utiliser un itinéraire comme son propre enfant."
msgid "trek"
msgstr "itineraire"

msgid "Sensitive area"
msgstr "Zone de sensibilité"

msgid "POIs"
msgstr "POIs"

msgid "services"
msgstr "services"

msgid "Published treks"
msgstr "Itinéraires publiés"

Expand Down Expand Up @@ -333,9 +342,6 @@ msgstr "Type"
msgid "POI"
msgstr "POIs"

msgid "POIs"
msgstr "POIs"

msgid "Published POIs"
msgstr "POIs publiés"

Expand Down Expand Up @@ -391,6 +397,13 @@ msgstr ""
"Le type de géométrie du champ '{src}' est invalide. Il devrait être "
"LineString, pas {geom_type}"

#. Translators: This is a slug (without space, accent or special char)
msgid "itinerancy"
msgstr "itinerance"

msgid "Itinerancy"
msgstr "Itinérance"

msgid "Init sync ..."
msgstr "Début de synchro"

Expand Down Expand Up @@ -462,9 +475,6 @@ msgstr "KML"
msgid "yes,no"
msgstr "oui,non"

msgid "Itinerancy"
msgstr "Itinérance"

msgid "Child of:"
msgstr "Enfant de:"

Expand Down Expand Up @@ -554,7 +564,8 @@ msgid ""
"area.\n"
" "
msgstr ""
"\nLe long de votre itinéraire, vous allez traverser des zones de sensibilité "
"\n"
"Le long de votre itinéraire, vous allez traverser des zones de sensibilité "
"liées à la présence d’une espèce ou d’un milieu particulier. Dans ces zones, "
"un comportement adapté permet de contribuer à leur préservation. Pour plus "
"d’informations détaillées, des fiches spécifiques sont accessibles pour "
Expand All @@ -563,6 +574,9 @@ msgstr ""
msgid "Sensitivity period:"
msgstr "Période de sensibilité :"

msgid "Contact:"
msgstr "Contact :"

msgid "Altimetric profile"
msgstr "Profil altimétrique"

Expand Down
1 change: 1 addition & 0 deletions geotrek/trekking/management/commands/sync_rando.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ def sync_trekking(self, lang):
os.path.join('api', lang, 'feedback', 'categories.json'),
zipfile=self.zipfile)
self.sync_static_file(lang, 'trekking/trek.svg')
self.sync_static_file(lang, 'trekking/itinerancy.svg')
self.sync_pictograms(lang, common_models.Theme, zipfile=self.zipfile)
self.sync_pictograms(lang, common_models.RecordSource, zipfile=self.zipfile)
self.sync_pictograms(lang, trekking_models.TrekNetwork, zipfile=self.zipfile)
Expand Down
4 changes: 3 additions & 1 deletion geotrek/trekking/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ def clean(self):

@property
def prefixed_category_id(self):
if settings.SPLIT_TREKS_CATEGORIES_BY_PRACTICE and self.practice:
if settings.SPLIT_TREKS_CATEGORIES_BY_ITINERANCY and self.children.exists():
return 'I'
elif settings.SPLIT_TREKS_CATEGORIES_BY_PRACTICE and self.practice:
return '{prefix}{id}'.format(prefix=self.category_id_prefix, id=self.practice.id)
else:
return self.category_id_prefix
Expand Down
19 changes: 12 additions & 7 deletions geotrek/trekking/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ class Meta:
fields = ('id', 'pk', 'slug', 'name', 'category_slug')

def get_category_slug(self, obj):
if settings.SPLIT_TREKS_CATEGORIES_BY_ITINERANCY and obj.children.exists():
# Translators: This is a slug (without space, accent or special char)
return _('itinerancy')
if settings.SPLIT_TREKS_CATEGORIES_BY_PRACTICE and obj.practice:
return obj.practice.slug
else:
Expand Down Expand Up @@ -250,13 +253,13 @@ def get_kml_url(self, obj):
return reverse('trekking:trek_kml_detail', kwargs={'lang': get_language(), 'pk': obj.pk, 'slug': obj.slug})

def get_category(self, obj):
accessibility = getattr(obj, 'accessibility', None)
if accessibility:
if settings.SPLIT_TREKS_CATEGORIES_BY_ITINERANCY and obj.children.exists():
data = {
'id': accessibility.prefixed_id,
'label': accessibility.name,
'pictogram': accessibility.get_pictogram_url(),
'slug': accessibility.slug,
'id': 'I',
'label': _(u"Itinerancy"),
'pictogram': '/static/trekking/itinerancy.svg',
# Translators: This is a slug (without space, accent or special char)
'slug': _('itinerancy'),
}
elif settings.SPLIT_TREKS_CATEGORIES_BY_PRACTICE and obj.practice:
data = {
Expand All @@ -273,7 +276,9 @@ def get_category(self, obj):
# Translators: This is a slug (without space, accent or special char)
'slug': _('trek'),
}
if settings.SPLIT_TREKS_CATEGORIES_BY_PRACTICE:
if settings.SPLIT_TREKS_CATEGORIES_BY_ITINERANCY and obj.children.exists():
data['order'] = settings.ITINERANCY_CATEGORY_ORDER
elif settings.SPLIT_TREKS_CATEGORIES_BY_PRACTICE:
data['order'] = obj.practice and obj.practice.order
else:
data['order'] = settings.TREK_CATEGORY_ORDER
Expand Down
26 changes: 26 additions & 0 deletions geotrek/trekking/static/trekking/itinerancy.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 43 additions & 29 deletions geotrek/trekking/static/trekking/trek.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion geotrek/trekking/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ def test_type2(self):
def test_category(self):
self.assertDictEqual(self.result['category'],
{u"id": 'T',
u"order": None,
u"order": 1,
u"label": u"Trek",
u"slug": u"trek",
u"type1_label": u"Practice",
Expand Down

0 comments on commit 42349b8

Please sign in to comment.