diff --git a/courses/models.py b/courses/models.py index 3bf697f..4b490ab 100644 --- a/courses/models.py +++ b/courses/models.py @@ -100,9 +100,6 @@ class Material(Resource): topic = models.ForeignKey(Topic, verbose_name = _('Topic')) student = models.ForeignKey(User, verbose_name = _('student')) - - - """ It is a category for each subject. """ diff --git a/courses/templates/subject/form_view_teacher.html b/courses/templates/subject/form_view_teacher.html index 22311e2..0528bef 100644 --- a/courses/templates/subject/form_view_teacher.html +++ b/courses/templates/subject/form_view_teacher.html @@ -1,4 +1,4 @@ -{% load static i18n %} +{% load static i18n list_topic_foruns %} {% block javascript %} @@ -19,7 +19,7 @@

{{ topic.description|linebreaks }}

- Forum + {% list_topic_foruns request topic %}
@@ -31,14 +31,17 @@ + + {% endfor %} {% endif %} \ No newline at end of file diff --git a/forum/templatetags/__init__.py b/forum/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/forum/templatetags/__init__.py diff --git a/forum/templatetags/list_post.py b/forum/templatetags/list_post.py new file mode 100644 index 0000000..b35bed9 --- /dev/null +++ b/forum/templatetags/list_post.py @@ -0,0 +1,19 @@ +from django import template + +from forum.models import Post + +register = template.Library() + +""" + Template tag to load all the posts of a post +""" + +@register.inclusion_tag('post/post_list.html') +def list_posts(request, forum): + context = { + 'request': request, + } + + context['posts'] = Post.objects.filter(forum = forum) + + return context \ No newline at end of file diff --git a/forum/templatetags/list_post_answer.py b/forum/templatetags/list_post_answer.py new file mode 100644 index 0000000..e50b1a0 --- /dev/null +++ b/forum/templatetags/list_post_answer.py @@ -0,0 +1,19 @@ +from django import template + +from forum.models import PostAnswer + +register = template.Library() + +""" + Template tag to load all the posts of a post +""" + +@register.inclusion_tag('post_answers/post_answer_list.html') +def list_post_answer(request, post): + context = { + 'request': request, + } + + context['answers'] = PostAnswer.objects.filter(post = post) + + return context \ No newline at end of file diff --git a/forum/views.py b/forum/views.py index 77a6f1a..54380de 100644 --- a/forum/views.py +++ b/forum/views.py @@ -14,12 +14,12 @@ class ForumIndex(LoginRequiredMixin, generic.ListView): redirect_field_name = 'next' template_name = "forum/forum_list.html" - context_object_name = 'foruns' + context_object_name = 'forum' def get_queryset(self): - topic = get_object_or_404(Topic, slug = self.request.GET.get('topic', '')) + forum_id = self.request.GET.get('forum_id', 0) - context = Forum.objects.filter(topic = topic) + context = Forum.objects.get(id = forum_id) return context -- libgit2 0.21.2