except KeyError:
# a context without 'requests' may happen when rendering error pages
request_path = 'xxx'
- section = 'About'
+ paths = {
+ '/actus/': 'News',
+ '/sons/': 'Listen',
+ '/podcasts/': 'Listen',
+ '/topiks/': 'Topiks',
+ '/emissions': 'Emissions',
+ '/grille': 'Emissions',
+ '/programme/': 'Emissions',
+ '/recherche/': 'Search',
+ '/la-radio/': 'About',
+ }
+ section = ''
if request_path == '/':
section = 'Home'
- elif request_path.startswith('/actus/'):
- section = 'News'
- elif request_path.startswith('/sons/'):
- section = 'Listen'
- elif request_path.startswith('/topiks'):
- section = 'Topiks'
- elif request_path.startswith('/emissions') or request_path == '/grille' or request_path == '/programme/':
- section = 'Emissions'
- elif request_path == '/recherche/':
- section = 'Search'
+ else:
+ for path, section_name in paths.items():
+ if request_path.startswith(path):
+ section = section_name
+ break
return {
'LANGUAGE_CODE': context.get('LANGUAGE_CODE'),
'sectionName': section,
- }
+ }
+
@register.inclusion_tag('includes/week.html')
def weekview(year=None, week=None):