Consolidate common app's template tags.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
|
||||
{% load project_tags %}
|
||||
{% load common_tags %}
|
||||
|
||||
{% block title %} :: {% trans 'About' %}{% endblock %}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
{% load compress %}
|
||||
|
||||
{% load common_tags %}
|
||||
{% load navigation_tags %}
|
||||
{% load project_tags %}
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends 'appearance/base.html' %}
|
||||
|
||||
{% load subtemplates_tags %}
|
||||
{% load common_tags %}
|
||||
|
||||
{% block title %} :: {% include 'appearance/calculate_form_title.html' %}{% endblock %}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
{% load i18n %}
|
||||
|
||||
{% load navigation_tags %}
|
||||
{% load subtemplates_tags %}
|
||||
|
||||
{% block title %} :: {% include 'appearance/calculate_form_title.html' %}{% endblock %}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{% extends 'appearance/base.html' %}
|
||||
|
||||
{% load navigation_tags %}
|
||||
{% load subtemplates_tags %}
|
||||
|
||||
{% block title %} :: {{ title }}{% endblock %}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
|
||||
{% load attribute_tags %}
|
||||
{% load common_tags %}
|
||||
{% load pagination_tags %}
|
||||
{% load navigation_tags %}
|
||||
{% load non_breakable %}
|
||||
{% load multiselect_tags %}
|
||||
|
||||
{% autopaginate object_list %}
|
||||
<div class="row">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends 'appearance/base.html' %}
|
||||
|
||||
{% load subtemplates_tags %}
|
||||
{% load common_tags %}
|
||||
|
||||
{% block title %} :: {% include 'appearance/calculate_form_title.html' %}{% endblock %}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
{% load static %}
|
||||
|
||||
{% load navigation_tags %}
|
||||
{% load project_tags %}
|
||||
|
||||
{% block title %} :: {% trans 'Home' %}{% endblock %}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
|
||||
{% load common_tags %}
|
||||
{% load autoadmin_tags %}
|
||||
{% load project_tags %}
|
||||
|
||||
{% block project_name %}{% endblock %}
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
from django.template import Library
|
||||
|
||||
from common.utils import return_attrib
|
||||
|
||||
register = Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
def object_property(value, arg):
|
||||
return return_attrib(value, arg)
|
||||
53
mayan/apps/common/templatetags/common_tags.py
Normal file
53
mayan/apps/common/templatetags/common_tags.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from json import dumps
|
||||
|
||||
from django.conf import settings
|
||||
from django.template import Context, Library
|
||||
from django.template.loader import get_template
|
||||
|
||||
import mayan
|
||||
|
||||
from ..utils import return_attrib
|
||||
|
||||
register = Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
def get_encoded_parameter(item, parameters_dict):
|
||||
result = {}
|
||||
for attrib_name, attrib in parameters_dict.items():
|
||||
result[attrib_name] = return_attrib(item, attrib)
|
||||
return dumps(result)
|
||||
|
||||
|
||||
@register.filter
|
||||
def make_non_breakable(value):
|
||||
return value.replace('-', '\u2011')
|
||||
|
||||
|
||||
@register.filter
|
||||
def object_property(value, arg):
|
||||
return return_attrib(value, arg)
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def project_name():
|
||||
return settings.PROJECT_TITLE
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def project_version():
|
||||
return mayan.__version__
|
||||
|
||||
|
||||
@register.assignment_tag(takes_context=True)
|
||||
def render_subtemplate(context, template_name, template_context):
|
||||
"""
|
||||
Renders the specified template with the mixed parent and
|
||||
subtemplate contexts
|
||||
"""
|
||||
|
||||
new_context = Context(context)
|
||||
new_context.update(Context(template_context))
|
||||
return get_template(template_name).render(new_context)
|
||||
@@ -1,14 +0,0 @@
|
||||
from json import dumps
|
||||
from django.template import Library
|
||||
|
||||
from ..utils import return_attrib
|
||||
|
||||
register = Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
def get_encoded_parameter(item, parameters_dict):
|
||||
result = {}
|
||||
for attrib_name, attrib in parameters_dict.items():
|
||||
result[attrib_name] = return_attrib(item, attrib)
|
||||
return dumps(result)
|
||||
@@ -1,10 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.template import Library
|
||||
|
||||
register = Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
def make_non_breakable(value):
|
||||
return value.replace('-', '\u2011')
|
||||
@@ -1,16 +0,0 @@
|
||||
from django.conf import settings
|
||||
from django.template import Library
|
||||
|
||||
import mayan
|
||||
|
||||
register = Library()
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def project_name():
|
||||
return settings.PROJECT_TITLE
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def project_version():
|
||||
return mayan.__version__
|
||||
@@ -1,18 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.template import Context, Library
|
||||
from django.template.loader import get_template
|
||||
|
||||
register = Library()
|
||||
|
||||
|
||||
@register.assignment_tag(takes_context=True)
|
||||
def render_subtemplate(context, template_name, template_context):
|
||||
"""
|
||||
Renders the specified template with the mixed parent and
|
||||
subtemplate contexts
|
||||
"""
|
||||
|
||||
new_context = Context(context)
|
||||
new_context.update(Context(template_context))
|
||||
return get_template(template_name).render(new_context)
|
||||
Reference in New Issue
Block a user