From c31e36bd07070f59ca33538fab08f128f9903013 Mon Sep 17 00:00:00 2001 From: ailsoncgt Date: Mon, 17 Oct 2016 16:09:41 -0300 Subject: [PATCH] Template tag to list files #183 --- courses/templates/topic/list_file.html | 12 ++++++++++++ courses/templates/topic/list_file_edit.html | 12 ++++++++++++ courses/templatetags/list_topic_foruns.py | 23 +++++++++++++++++++++++ 3 files changed, 47 insertions(+), 0 deletions(-) create mode 100644 courses/templates/topic/list_file.html create mode 100644 courses/templates/topic/list_file_edit.html diff --git a/courses/templates/topic/list_file.html b/courses/templates/topic/list_file.html new file mode 100644 index 0000000..b4a97dd --- /dev/null +++ b/courses/templates/topic/list_file.html @@ -0,0 +1,12 @@ +{% load static i18n permission_tags%} + +
+ {% for file in files %} +
  • {{ file.file_type.icon }} {{ file.name }}
  • + {% endfor %} +
    + + +
    + +
    diff --git a/courses/templates/topic/list_file_edit.html b/courses/templates/topic/list_file_edit.html new file mode 100644 index 0000000..33785b9 --- /dev/null +++ b/courses/templates/topic/list_file_edit.html @@ -0,0 +1,12 @@ +{% load static i18n permission_tags%} + +
    + {% for file in files %} +
  • +
  • {{ file.file_type.icon }} {{ file.name }}
  • + {% endfor %} +
    + +
    + +
    \ No newline at end of file diff --git a/courses/templatetags/list_topic_foruns.py b/courses/templatetags/list_topic_foruns.py index 3ebd0e9..4cbf245 100644 --- a/courses/templatetags/list_topic_foruns.py +++ b/courses/templatetags/list_topic_foruns.py @@ -2,6 +2,7 @@ from django import template from forum.models import Forum from poll.models import Poll +from files.models import TopicFile register = template.Library() """ @@ -28,3 +29,25 @@ def list_topic_poll(request, topic): context['topic'] = topic return context + +@register.inclusion_tag('topic/list_file.html') +def list_topic_file(request, topic): + context = { + 'request': request, + } + + context['files'] = TopicFile.objects.filter(topic = topic) + context['topic'] = topic + + return context + +@register.inclusion_tag('topic/list_file_edit.html') +def list_topic_file_edit(request, topic): + context = { + 'request': request, + } + + context['files'] = TopicFile.objects.filter(topic = topic) + context['topic'] = topic + + return context -- libgit2 0.21.2