by_mandate_url.py 429 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
from django import template
from django.core.urlresolvers import reverse

register = template.Library()


@register.filter
def by_mandate_url(mandate):
    kwargs = {'mandate_kind': mandate.group.kind}

    if mandate.group.abbreviation:
luxcem's avatar
luxcem committed
12
        kwargs['search'] = mandate.group.abbreviation
13
    else:
luxcem's avatar
luxcem committed
14
        kwargs['search'] = mandate.group.name
15
16

    return reverse(
luxcem's avatar
luxcem committed
17
        'representatives:list',
18
19
        kwargs=kwargs
    )