From b0e18756a7d5b02bd6f2896eec04430b72f74693 Mon Sep 17 00:00:00 2001 From: Zambom Date: Thu, 22 Sep 2016 19:10:08 -0300 Subject: [PATCH] Adding post answers visualization [Issue: #73] --- core/static/css/base/amadeus.css | 3 +++ courses/templates/subject/form_view_teacher.html | 19 +++++++++++++++++++ forum/models.py | 2 +- forum/templates/post_answer_list.html | 34 ++++++++++++++++++++++++++++++++++ forum/templates/post_list.html | 40 +++++++++++++++++++++++----------------- forum/urls.py | 1 + forum/views.py | 16 +++++++++++++++- 7 files changed, 96 insertions(+), 19 deletions(-) diff --git a/core/static/css/base/amadeus.css b/core/static/css/base/amadeus.css index a5cf89e..d9408ad 100644 --- a/core/static/css/base/amadeus.css +++ b/core/static/css/base/amadeus.css @@ -287,6 +287,9 @@ a.alert_message:hover{color : grey} -webkit-padding-start: 0px !important; width: 100%; } +.timeline.post a { + color: #000; +} .timeline.post li { padding: 10px; border-bottom: 1px solid #fff; diff --git a/courses/templates/subject/form_view_teacher.html b/courses/templates/subject/form_view_teacher.html index 2bc067a..71c0666 100644 --- a/courses/templates/subject/form_view_teacher.html +++ b/courses/templates/subject/form_view_teacher.html @@ -46,6 +46,25 @@ $("#collapse" + forum).collapse('show'); } } + + var postsAnswerUrl = '{% url "forum:post_answers" %}'; + var formPostsAnswersUrl = ''; + + function showPostsAnswers(post) { + if ($("#collapse" + post).hasClass('in')) { + $("#collapse" + post).collapse('hide'); + } else { + $.ajax({ + url: postsAnswerUrl, + data: {'post': post}, + success: function(data) { + $("#collapse" + post).find(".well").html(data); + } + }); + + $("#collapse" + post).collapse('show'); + } + } {% endblock %} diff --git a/forum/models.py b/forum/models.py index 1d39781..e15678d 100644 --- a/forum/models.py +++ b/forum/models.py @@ -50,4 +50,4 @@ class PostAnswer(models.Model): verbose_name_plural = _('Post Answers') def __str__(self): - return ''.join([self.user.name, " / ", self.answer_date]) \ No newline at end of file + return ''.join([self.user.name, " / ", str(self.answer_date)]) \ No newline at end of file diff --git a/forum/templates/post_answer_list.html b/forum/templates/post_answer_list.html index e69de29..f8c79b7 100644 --- a/forum/templates/post_answer_list.html +++ b/forum/templates/post_answer_list.html @@ -0,0 +1,34 @@ +{% load i18n %} + +{% if answers|length > 0 %} + +{% else %} +

{% trans 'Nobody answered this post yet.' %}

+{% endif %} \ No newline at end of file diff --git a/forum/templates/post_list.html b/forum/templates/post_list.html index e183a9a..28f8793 100644 --- a/forum/templates/post_list.html +++ b/forum/templates/post_list.html @@ -4,27 +4,33 @@