Event search: first version

This commit is contained in:
Klaas van Schelven
2025-03-04 13:51:56 +01:00
parent 0cbdae9411
commit 4cde74d7cb
11 changed files with 240 additions and 87 deletions

View File

@@ -7,6 +7,8 @@ register = template.Library()
@register.simple_tag(takes_context=True)
def add_to_qs(context, **kwargs):
"""add kwargs to query string"""
if 'request' not in context:
# "should not happen", because this tag is only assumed to be used in RequestContext templates, but it's not
# something I want to break for. Also: we have an answer that "mostly works" for that case, so let's do that.
@@ -15,3 +17,16 @@ def add_to_qs(context, **kwargs):
query = copy(context['request'].GET.dict())
query.update(kwargs)
return urlencode(query)
@register.simple_tag(takes_context=True)
def current_qs(context):
if 'request' not in context:
# "should not happen", because this tag is only assumed to be used in RequestContext templates, but it's not
# something I want to break for. Also: we have an answer that "mostly works" for that case, so let's do that.
return ""
query = copy(context['request'].GET.dict())
if query:
return '?' + urlencode(query)
return ""