diff --git a/mayan/apps/appearance/templates/appearance/about.html b/mayan/apps/appearance/templates/appearance/about.html index d39ad72fa4..befb37c897 100644 --- a/mayan/apps/appearance/templates/appearance/about.html +++ b/mayan/apps/appearance/templates/appearance/about.html @@ -3,7 +3,7 @@ {% load i18n %} {% load static %} -{% load project_tags %} +{% load common_tags %} {% block title %} :: {% trans 'About' %}{% endblock %} diff --git a/mayan/apps/appearance/templates/appearance/base.html b/mayan/apps/appearance/templates/appearance/base.html index 5ef7bb3146..f1d3062bf6 100644 --- a/mayan/apps/appearance/templates/appearance/base.html +++ b/mayan/apps/appearance/templates/appearance/base.html @@ -3,8 +3,8 @@ {% load compress %} +{% load common_tags %} {% load navigation_tags %} -{% load project_tags %} diff --git a/mayan/apps/appearance/templates/appearance/generic_form.html b/mayan/apps/appearance/templates/appearance/generic_form.html index 6c7f7eac99..c1ebc06276 100644 --- a/mayan/apps/appearance/templates/appearance/generic_form.html +++ b/mayan/apps/appearance/templates/appearance/generic_form.html @@ -1,6 +1,6 @@ {% extends 'appearance/base.html' %} -{% load subtemplates_tags %} +{% load common_tags %} {% block title %} :: {% include 'appearance/calculate_form_title.html' %}{% endblock %} diff --git a/mayan/apps/appearance/templates/appearance/generic_list.html b/mayan/apps/appearance/templates/appearance/generic_list.html index 9acc5c2a95..3d33c7bc67 100644 --- a/mayan/apps/appearance/templates/appearance/generic_list.html +++ b/mayan/apps/appearance/templates/appearance/generic_list.html @@ -3,7 +3,6 @@ {% load i18n %} {% load navigation_tags %} -{% load subtemplates_tags %} {% block title %} :: {% include 'appearance/calculate_form_title.html' %}{% endblock %} diff --git a/mayan/apps/appearance/templates/appearance/generic_list_horizontal.html b/mayan/apps/appearance/templates/appearance/generic_list_horizontal.html index 34527c7a36..7ecbb2504b 100644 --- a/mayan/apps/appearance/templates/appearance/generic_list_horizontal.html +++ b/mayan/apps/appearance/templates/appearance/generic_list_horizontal.html @@ -1,7 +1,6 @@ {% extends 'appearance/base.html' %} {% load navigation_tags %} -{% load subtemplates_tags %} {% block title %} :: {{ title }}{% endblock %} diff --git a/mayan/apps/appearance/templates/appearance/generic_list_subtemplate.html b/mayan/apps/appearance/templates/appearance/generic_list_subtemplate.html index 8c337d9561..07bf891297 100644 --- a/mayan/apps/appearance/templates/appearance/generic_list_subtemplate.html +++ b/mayan/apps/appearance/templates/appearance/generic_list_subtemplate.html @@ -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 %}
diff --git a/mayan/apps/appearance/templates/appearance/generic_multi_subtemplates.html b/mayan/apps/appearance/templates/appearance/generic_multi_subtemplates.html index 9622c75429..419148bc98 100644 --- a/mayan/apps/appearance/templates/appearance/generic_multi_subtemplates.html +++ b/mayan/apps/appearance/templates/appearance/generic_multi_subtemplates.html @@ -1,6 +1,6 @@ {% extends 'appearance/base.html' %} -{% load subtemplates_tags %} +{% load common_tags %} {% block title %} :: {% include 'appearance/calculate_form_title.html' %}{% endblock %} diff --git a/mayan/apps/appearance/templates/appearance/home.html b/mayan/apps/appearance/templates/appearance/home.html index dee907106d..79b0cef6e2 100644 --- a/mayan/apps/appearance/templates/appearance/home.html +++ b/mayan/apps/appearance/templates/appearance/home.html @@ -4,7 +4,6 @@ {% load static %} {% load navigation_tags %} -{% load project_tags %} {% block title %} :: {% trans 'Home' %}{% endblock %} diff --git a/mayan/apps/appearance/templates/appearance/login.html b/mayan/apps/appearance/templates/appearance/login.html index 42ab6e8364..892f93d896 100644 --- a/mayan/apps/appearance/templates/appearance/login.html +++ b/mayan/apps/appearance/templates/appearance/login.html @@ -3,8 +3,8 @@ {% load i18n %} {% load static %} +{% load common_tags %} {% load autoadmin_tags %} -{% load project_tags %} {% block project_name %}{% endblock %} diff --git a/mayan/apps/common/templatetags/attribute_tags.py b/mayan/apps/common/templatetags/attribute_tags.py deleted file mode 100644 index d7328fb7da..0000000000 --- a/mayan/apps/common/templatetags/attribute_tags.py +++ /dev/null @@ -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) diff --git a/mayan/apps/common/templatetags/common_tags.py b/mayan/apps/common/templatetags/common_tags.py new file mode 100644 index 0000000000..708788f64b --- /dev/null +++ b/mayan/apps/common/templatetags/common_tags.py @@ -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) diff --git a/mayan/apps/common/templatetags/multiselect_tags.py b/mayan/apps/common/templatetags/multiselect_tags.py deleted file mode 100644 index 6408c53f23..0000000000 --- a/mayan/apps/common/templatetags/multiselect_tags.py +++ /dev/null @@ -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) diff --git a/mayan/apps/common/templatetags/non_breakable.py b/mayan/apps/common/templatetags/non_breakable.py deleted file mode 100644 index 55ef62f5f2..0000000000 --- a/mayan/apps/common/templatetags/non_breakable.py +++ /dev/null @@ -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') diff --git a/mayan/apps/common/templatetags/project_tags.py b/mayan/apps/common/templatetags/project_tags.py deleted file mode 100644 index b7eed36fb0..0000000000 --- a/mayan/apps/common/templatetags/project_tags.py +++ /dev/null @@ -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__ diff --git a/mayan/apps/common/templatetags/subtemplates_tags.py b/mayan/apps/common/templatetags/subtemplates_tags.py deleted file mode 100644 index 3da020b044..0000000000 --- a/mayan/apps/common/templatetags/subtemplates_tags.py +++ /dev/null @@ -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)