Moved the url_with_return template tag from the accounting application to the Mia core application.
This commit is contained in:
parent
cafa927c07
commit
0a29ffaa12
@ -21,9 +21,6 @@
|
||||
import re
|
||||
|
||||
from django import template
|
||||
from django.urls import reverse
|
||||
|
||||
from mia_core.utils import UrlBuilder
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@ -43,20 +40,3 @@ def accounting_amount(value):
|
||||
if value < 0:
|
||||
s = "(%s)" % (s)
|
||||
return s
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def url_with_return(context, view_name, *args):
|
||||
"""Returns the transaction URL.
|
||||
|
||||
Args:
|
||||
context (RequestContext): The request context.
|
||||
view_name (str): The view name.
|
||||
*args (tuple[any]): The URL arguments.
|
||||
|
||||
Returns:
|
||||
str: The URL.
|
||||
"""
|
||||
url = reverse(view_name, args=args)
|
||||
return_to = context.request.get_full_path()
|
||||
return str(UrlBuilder(url).set_param("r", return_to))
|
||||
|
@ -120,3 +120,20 @@ def smart_month(value):
|
||||
if value.year == year and value.month == month:
|
||||
return gettext("Last Month")
|
||||
return defaultfilters.date(value, "Y/n")
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def url_with_return(context, view_name, *args):
|
||||
"""Returns the transaction URL.
|
||||
|
||||
Args:
|
||||
context (RequestContext): The request context.
|
||||
view_name (str): The view name.
|
||||
*args (tuple[any]): The URL arguments.
|
||||
|
||||
Returns:
|
||||
str: The URL.
|
||||
"""
|
||||
url = reverse(view_name, args=args)
|
||||
return_to = context.request.get_full_path()
|
||||
return str(UrlBuilder(url).set_param("r", return_to))
|
||||
|
Loading…
Reference in New Issue
Block a user