Commit | Line | Data |
---|---|---|
9af73c99 AJ |
1 | # -*- encoding: utf-8 -*- |
2 | ||
bae03b7b | 3 | import re |
9af73c99 | 4 | |
bae03b7b EMS |
5 | DISCIPLINE_REGION_RE = re.compile(r'/(discipline/(?P<discipline>\d+)/)?(region/(?P<region>\d+)/)?') |
6 | def discipline_region(request): | |
3b828312 PP |
7 | discipline = request.GET.get('discipline', None) |
8 | region = request.GET.get('region', None) | |
9 | ||
10 | if not discipline and not region: | |
11 | match = DISCIPLINE_REGION_RE.match(request.path) | |
12 | discipline = match.group('discipline') | |
13 | region = match.group('region') | |
14 | ||
bae03b7b EMS |
15 | discipline = discipline and int(discipline) |
16 | region = region and int(region) | |
3b828312 | 17 | |
bae03b7b | 18 | return dict(discipline_active=discipline, region_active=region) |