From 2872cf9081cf9fae18b2a179d493980400f05034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 15 Mar 2018 17:44:48 +0100 Subject: [PATCH] readjust slug to producer code to work with formdata (#22542) --- combo_plugin_gnm/templatetags/gnm.py | 31 +++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/combo_plugin_gnm/templatetags/gnm.py b/combo_plugin_gnm/templatetags/gnm.py index 52d5032..80283cd 100644 --- a/combo_plugin_gnm/templatetags/gnm.py +++ b/combo_plugin_gnm/templatetags/gnm.py @@ -283,22 +283,25 @@ def as_producer(slug): producer = None if ':' in slug: # formdef_reference slug = slug.split(':')[0] - if slug.startswith('_'): - producer = slug.split('_')[1].replace('hobo-', '') - if slug == 'eservices': - # handle collectivity sites, they are individually named - # "eservices" but have the collectivity slug as a template - # variable. - producer = settings.TEMPLATE_VARS.get('gnm_commune') - if producer and settings.TEMPLATE_VARS.get('gnm_commune_name'): - return {'slug': producer, - 'label': settings.TEMPLATE_VARS.get('gnm_commune_name')} + + if slug.startswith('_'): + producer = slug.split('_')[1].replace('hobo-', '') else: producer = slugify(slug) - try: - producer = re.search(r'(^|\W)producer-(\w*)(\W|$)', producer).group(2).strip() - except AttributeError: - pass + + if slug == 'eservices': + # handle collectivity sites, they are individually named + # "eservices" but have the collectivity slug as a template + # variable. + producer = settings.TEMPLATE_VARS.get('gnm_commune', 'grandlyon') + if producer and settings.TEMPLATE_VARS.get('gnm_commune_name'): + return {'slug': producer, + 'label': settings.TEMPLATE_VARS.get('gnm_commune_name')} + + try: + producer = re.search(r'(^|\W)producer-(\w*)(\W|$)', producer).group(2).strip() + except AttributeError: + pass if settings.KNOWN_SERVICES['hobo'].get('hobo-%s' % producer): return {'slug': producer,