Commit cf71441ecdcdfcbd7b8b27af57666209bbfa1a75

Authored by felipebormann
1 parent fbaec8c4

created template tags and now link opens in all screens

subjects/templates/subjects/resource_card.html
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 {% resource_permissions request.user resource as has_resource_permissions %} 3 {% resource_permissions request.user resource as has_resource_permissions %}
4 {% subject_permissions request.user resource.topic.subject as has_subject_permissions %} 4 {% subject_permissions request.user resource.topic.subject as has_subject_permissions %}
  5 +
5 {% if has_resource_permissions %} 6 {% if has_resource_permissions %}
6 <div class="panel panel-info resource-panel"> 7 <div class="panel panel-info resource-panel">
7 <div class="panel-heading"> 8 <div class="panel-heading">
topics/templates/resources/list.html
1 -{% load static i18n pagination permissions_tags %} 1 +{% load static i18n pagination permissions_tags class_filter %}
2 {% load django_bootstrap_breadcrumbs %} 2 {% load django_bootstrap_breadcrumbs %}
3 3
4 {% subject_permissions request.user topic.subject as has_subject_permissions %} 4 {% subject_permissions request.user topic.subject as has_subject_permissions %}
@@ -14,11 +14,15 @@ @@ -14,11 +14,15 @@
14 <input type="hidden" class="url_order" value="{% url 'topics:update_resource_order' %}" /> 14 <input type="hidden" class="url_order" value="{% url 'topics:update_resource_order' %}" />
15 15
16 <h4 class="pull-left list-group-item-heading"> 16 <h4 class="pull-left list-group-item-heading">
17 - 17 + {% if resource|class_name == 'link' %}
  18 + <a href="{{resource|resource_link}}" class="resource_link" target="_blank"> {{resource.name}}</a>
  19 + {% else %}
18 <a href="{% url resource.access_link resource.slug %}" class="resource_link" {% if resource.show_window %}target="_blank"{% endif %}> 20 <a href="{% url resource.access_link resource.slug %}" class="resource_link" {% if resource.show_window %}target="_blank"{% endif %}>
19 21
20 {{ resource.name }} 22 {{ resource.name }}
21 </a> 23 </a>
  24 + {% endif %}
  25 +
22 </h4> 26 </h4>
23 27
24 {% if has_subject_permissions %} 28 {% if has_subject_permissions %}
topics/templatetags/__init__.py 0 → 100644
topics/templatetags/class_filter.py 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +from django import template
  2 +from links.models import Link
  3 +register = template.Library()
  4 +
  5 +@register.filter('class_name')
  6 +def class_name(obj):
  7 + return obj._my_subclass
  8 +
  9 +@register.filter('resource_link')
  10 +def resource_link(resource):
  11 + link = Link.objects.get(id=resource.id)
  12 + return link.link_url
0 \ No newline at end of file 13 \ No newline at end of file