Complete prefixing template tags with app names

Additionally remove unused template tags.

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-11-17 01:59:17 -04:00
parent 820e997165
commit f1c704e3e1
24 changed files with 63 additions and 186 deletions

View File

@@ -12,47 +12,6 @@ from django.utils.translation import ugettext
from .settings import setting_home_view
@python_2_unicode_compatible
class Collection(object):
_registry = []
@classmethod
def get_all(cls):
return sorted(cls._registry, key=lambda entry: entry._order)
def __init__(
self, label, icon_class=None, link=None, queryset=None, model=None,
order=None
):
self._label = label
self._icon_class = icon_class
self._link = link
self._queryset = queryset
self._model = model
self._order = order or 99
self.__class__._registry.append(self)
def __str__(self):
return force_text(self.label)
def _get_children(self):
if self._queryset:
return self._queryset
else:
if self._model:
return self._model.objects.all()
def resolve(self):
self.children = self._get_children()
self.icon = self._icon
self.label = self._label
self.url = None
if self._link:
self.icon_class = getattr(self._link, 'icon_class', self._icon_class)
self.url = reverse(viewname=self._link.view, args=self._link.args)
return ''
@python_2_unicode_compatible
class ErrorLogNamespace(object):
def __init__(self, name, label=None):

View File

@@ -1,7 +1,5 @@
from __future__ import unicode_literals
from json import dumps
from django.template import Context, Library
from django.template.defaultfilters import truncatechars
from django.template.loader import get_template
@@ -12,7 +10,6 @@ from django.utils.translation import ugettext_lazy as _
import mayan
from mayan.apps.appearance.settings import setting_max_title_length
from ..classes import Collection
from ..literals import MESSAGE_SQLITE_WARNING
from ..utils import check_for_sqlite, return_attrib
@@ -70,36 +67,23 @@ def common_get_object_verbose_name(obj):
return type(obj)
@register.simple_tag
def get_collections():
return Collection.get_all()
@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 get_type(value):
def common_get_type(value):
return force_text(type(value))
@register.filter
def object_property(value, arg):
def common_object_property(value, arg):
return return_attrib(value, arg)
@register.simple_tag
def project_information(attribute_name):
def common_project_information(attribute_name):
return getattr(mayan, attribute_name)
@register.simple_tag(takes_context=True)
def render_subtemplate(context, template_name, template_context):
def common_render_subtemplate(context, template_name, template_context):
"""
Renders the specified template with the mixed parent and
subtemplate contexts