Consolidate common app's template tags.

This commit is contained in:
Roberto Rosario
2015-07-17 02:04:01 -04:00
parent fb824c6ee1
commit e421c8e382
15 changed files with 59 additions and 79 deletions

View File

@@ -3,7 +3,7 @@
{% load i18n %}
{% load static %}
{% load project_tags %}
{% load common_tags %}
{% block title %} :: {% trans 'About' %}{% endblock %}

View File

@@ -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">

View File

@@ -1,6 +1,6 @@
{% extends 'appearance/base.html' %}
{% load subtemplates_tags %}
{% load common_tags %}
{% block title %} :: {% include 'appearance/calculate_form_title.html' %}{% endblock %}

View File

@@ -3,7 +3,6 @@
{% load i18n %}
{% load navigation_tags %}
{% load subtemplates_tags %}
{% block title %} :: {% include 'appearance/calculate_form_title.html' %}{% endblock %}

View File

@@ -1,7 +1,6 @@
{% extends 'appearance/base.html' %}
{% load navigation_tags %}
{% load subtemplates_tags %}
{% block title %} :: {{ title }}{% endblock %}

View File

@@ -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">

View File

@@ -1,6 +1,6 @@
{% extends 'appearance/base.html' %}
{% load subtemplates_tags %}
{% load common_tags %}
{% block title %} :: {% include 'appearance/calculate_form_title.html' %}{% endblock %}

View File

@@ -4,7 +4,6 @@
{% load static %}
{% load navigation_tags %}
{% load project_tags %}
{% block title %} :: {% trans 'Home' %}{% endblock %}

View File

@@ -3,8 +3,8 @@
{% load i18n %}
{% load static %}
{% load common_tags %}
{% load autoadmin_tags %}
{% load project_tags %}
{% block project_name %}{% endblock %}

View File

@@ -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)

View 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)

View File

@@ -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)

View File

@@ -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')

View File

@@ -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__

View File

@@ -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)