From cf71441ecdcdfcbd7b8b27af57666209bbfa1a75 Mon Sep 17 00:00:00 2001 From: felipebormann Date: Mon, 6 Feb 2017 14:01:11 -0300 Subject: [PATCH] created template tags and now link opens in all screens --- subjects/templates/subjects/resource_card.html | 1 + topics/templates/resources/list.html | 8 ++++++-- topics/templatetags/__init__.py | 0 topics/templatetags/class_filter.py | 12 ++++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 topics/templatetags/__init__.py create mode 100644 topics/templatetags/class_filter.py diff --git a/subjects/templates/subjects/resource_card.html b/subjects/templates/subjects/resource_card.html index ae8f193..3b01d4f 100644 --- a/subjects/templates/subjects/resource_card.html +++ b/subjects/templates/subjects/resource_card.html @@ -2,6 +2,7 @@ {% resource_permissions request.user resource as has_resource_permissions %} {% subject_permissions request.user resource.topic.subject as has_subject_permissions %} + {% if has_resource_permissions %}
diff --git a/topics/templates/resources/list.html b/topics/templates/resources/list.html index a992b9d..d2de308 100644 --- a/topics/templates/resources/list.html +++ b/topics/templates/resources/list.html @@ -1,4 +1,4 @@ -{% load static i18n pagination permissions_tags %} +{% load static i18n pagination permissions_tags class_filter %} {% load django_bootstrap_breadcrumbs %} {% subject_permissions request.user topic.subject as has_subject_permissions %} @@ -14,11 +14,15 @@

- + {% if resource|class_name == 'link' %} + {{resource.name}} + {% else %} {{ resource.name }} + {% endif %} +

{% if has_subject_permissions %} diff --git a/topics/templatetags/__init__.py b/topics/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/topics/templatetags/__init__.py diff --git a/topics/templatetags/class_filter.py b/topics/templatetags/class_filter.py new file mode 100644 index 0000000..110bf34 --- /dev/null +++ b/topics/templatetags/class_filter.py @@ -0,0 +1,12 @@ +from django import template +from links.models import Link +register = template.Library() + +@register.filter('class_name') +def class_name(obj): + return obj._my_subclass + +@register.filter('resource_link') +def resource_link(resource): + link = Link.objects.get(id=resource.id) + return link.link_url \ No newline at end of file -- libgit2 0.21.2