diff --git a/apis_core/apis_entities/templatetags/apis_templatetags.py b/apis_core/apis_entities/templatetags/apis_templatetags.py index 9287a1621..a75709c18 100644 --- a/apis_core/apis_entities/templatetags/apis_templatetags.py +++ b/apis_core/apis_entities/templatetags/apis_templatetags.py @@ -1,4 +1,6 @@ +from operator import itemgetter from django import template +from apis_core.utils import caching register = template.Library() @@ -15,3 +17,18 @@ def url_replace(request, field, value): dict_[field] = value return dict_.urlencode() + + +@register.simple_tag +def entities_list_links(): + """ + Retrieve all models which inherit from AbstractEntity class + and return their class name and verbose name. + """ + entities_classes = caching.get_all_entity_classes() or [] + entities_links = [ + (e.__name__.lower(), e._meta.verbose_name.title()) for e in entities_classes + ] + entities_links.sort(key=itemgetter(1)) + + return entities_links diff --git a/apis_core/apis_metainfo/templates/base.html b/apis_core/apis_metainfo/templates/base.html index 8684b3e72..1e07bf2d7 100644 --- a/apis_core/apis_metainfo/templates/base.html +++ b/apis_core/apis_metainfo/templates/base.html @@ -1,6 +1,8 @@ {% load static %} {% load apis_metainfo_extras %} +{% load apiscore %} +{% load apis_templatetags %}
@@ -19,18 +21,18 @@ + href="{% shared_url %}favicon/apple-touch-icon.png" /> + href="{% shared_url %}favicon/favicon-32x32.png" /> - + href="{% shared_url %}favicon/favicon-16x16.png" /> + @@ -49,7 +51,7 @@ rel="stylesheet" /> + href="{% shared_url %}apis/libraries/scroll-to-top/css/ap-scroll-top.min.css" /> {% block scriptHeader %}{% endblock %} @@ -103,12 +105,11 @@ @@ -238,7 +239,7 @@ {% include "partials/bootstrap4_js.html" %} - + {% endblock %} {% block scripts2 %} diff --git a/apis_core/core/templatetags/apiscore.py b/apis_core/core/templatetags/apiscore.py new file mode 100644 index 000000000..54740d520 --- /dev/null +++ b/apis_core/core/templatetags/apiscore.py @@ -0,0 +1,10 @@ +from django import template +from django.conf import settings + + +register = template.Library() + + +@register.simple_tag +def shared_url(): + return getattr(settings, "SHARED_URL", "/static")