# Path: remo/base/templatetags/helpers.py
# @library.filter
# def urlparams(url_, hash=None, **query):
#     """Add a fragment and/or query paramaters to a URL.
# 
#     New query params will be appended to exising parameters, except duplicate
#     names, which will be replaced.
#     """
#     url = urlparse.urlparse(url_)
#     fragment = hash if hash is not None else url.fragment
# 
#     # Use dict(parse_qsl) so we don't get lists of values.
#     q = url.query
#     query_dict = dict(urlparse.parse_qsl(smart_str(q))) if q else {}
#     query_dict.update((k, v) for k, v in query.items())
# 
#     query_string = _urlencode([(k, v) for k, v in query_dict.items()
#                                if v is not None])
#     new = urlparse.ParseResult(url.scheme, url.netloc, url.path, url.params,
#                                query_string, fragment)
#     return new.geturl()


from django.conf import settings
from django.core.urlresolvers import reverse
from django_jinja import library
from remo.base.templatetags.helpers import urlparams
    query = event.attendees.exclude(groups__name='Mozillians',
                                    userprofile__mozillian_username='')
    attendees = list(query.order_by('last_name', 'first_name'))
    if event.owner in attendees:
        attendees.remove(event.owner)
        attendees.insert(0, event.owner)
    return attendees


@library.filter
def get_total_attendees(event):
    """Return the total number of people attending an event."""
    return event.attendees.all().count()


@library.filter
def get_event_comment_delete_url(obj):
    """Return the delete url of an event comment."""

    return reverse('events_delete_event_comment',
                   kwargs={'slug': obj.event.slug,
                           'pk': obj.id})


@library.global_function
def get_event_filtered_url(category=None, initiative=None):
    """Returns events list page of given category or initiative."""

    url = reverse('events_list_events')
    if category:

# Path: remo/base/templatetags/helpers.py
# @library.filter
# def urlparams(url_, hash=None, **query):
#     """Add a fragment and/or query paramaters to a URL.
# 
#     New query params will be appended to exising parameters, except duplicate
#     names, which will be replaced.
#     """
#     url = urlparse.urlparse(url_)
#     fragment = hash if hash is not None else url.fragment
# 
#     # Use dict(parse_qsl) so we don't get lists of values.
#     q = url.query
#     query_dict = dict(urlparse.parse_qsl(smart_str(q))) if q else {}
#     query_dict.update((k, v) for k, v in query.items())
# 
#     query_string = _urlencode([(k, v) for k, v in query_dict.items()
#                                if v is not None])
#     new = urlparse.ParseResult(url.scheme, url.netloc, url.path, url.params,
#                                query_string, fragment)
#     return new.geturl()


# Path: remo/events/templatetags/helpers.py
from django.conf import settings
from django.core.urlresolvers import reverse
from django_jinja import library
from remo.base.templatetags.helpers import urlparams

    query = event.attendees.exclude(groups__name='Mozillians',
                                    userprofile__mozillian_username='')
    attendees = list(query.order_by('last_name', 'first_name'))
    if event.owner in attendees:
        attendees.remove(event.owner)
        attendees.insert(0, event.owner)
    return attendees


@library.filter
def get_total_attendees(event):
    """Return the total number of people attending an event."""
    return event.attendees.all().count()


@library.filter
def get_event_comment_delete_url(obj):
    """Return the delete url of an event comment."""

    return reverse('events_delete_event_comment',
                   kwargs={'slug': obj.event.slug,
                           'pk': obj.id})


@library.global_function
def get_event_filtered_url(category=None, initiative=None):
    """Returns events list page of given category or initiative."""

    url = reverse('events_list_events')
    if category:

        return urlparams(url, '/category/%s/' % category.lower())