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,