|
@@ -18,13 +18,13 @@
|
|
|
# Django Conntrackt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
#
|
|
|
|
|
|
|
|
|
# Django imports.
|
|
|
from django import template
|
|
|
from django.core import urlresolvers
|
|
|
from django import urls
|
|
|
from django.utils.html import format_html
|
|
|
|
|
|
|
|
|
# Get an instance of Django's template library.
|
|
|
register = template.Library()
|
|
|
|
|
@@ -59,13 +59,13 @@ def html_link(text, view, *args, **kwarg
|
|
|
for key in kwargs.keys():
|
|
|
if key not in ("get", "class", "title", "id"):
|
|
|
raise template.TemplateSyntaxError("Unknown argument for 'html_link' tag: %r" % key)
|
|
|
|
|
|
# Generate the URL by using the supplied view name and arguments that should
|
|
|
# be passed to the view.
|
|
|
url = urlresolvers.reverse(view, args=args)
|
|
|
url = urls.reverse(view, args=args)
|
|
|
|
|
|
# Set-up the base pattern (url, parameters, text).
|
|
|
if 'get' in kwargs:
|
|
|
pattern = '<a href="{url}?{get}"'
|
|
|
else:
|
|
|
pattern = '<a href="{url}"'
|
|
@@ -118,14 +118,14 @@ def current_url_equals(context, url_name
|
|
|
"""
|
|
|
|
|
|
# Assume that we have not been able to resolve the request path to an URL.
|
|
|
resolved = False
|
|
|
try:
|
|
|
# Use the request path, and resolve it to a URL name.
|
|
|
resolved = urlresolvers.resolve(context.get('request').path)
|
|
|
except urlresolvers.Resolver404:
|
|
|
resolved = urls.resolve(context.get('request').path)
|
|
|
except urls.Resolver404:
|
|
|
# This means we haven't been able to resolve the path from request.
|
|
|
pass
|
|
|
|
|
|
# If the request was resolved and URL names match, verify that the kwargs
|
|
|
# match as well.
|
|
|
matches = resolved and resolved.url_name == url_name
|