From 2f9331717075b34534f2745706f57a98f7dce20d Mon Sep 17 00:00:00 2001
From: CruiseDevice
Date: Mon, 13 Apr 2020 17:27:49 +0530
Subject: Add feature to hide thread or comments
---
yaksh/models.py | 2 +-
yaksh/templates/yaksh/course_forum.html | 4 +++-
yaksh/templates/yaksh/thread_comments.html | 12 ++++++++++--
yaksh/urls.py | 6 ++++--
yaksh/views.py | 23 +++++++++++++++++++----
5 files changed, 37 insertions(+), 10 deletions(-)
(limited to 'yaksh')
diff --git a/yaksh/models.py b/yaksh/models.py
index f9878e4..d76d6aa 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -2670,7 +2670,7 @@ class Thread(ForumBase):
return self.comment.last()
def get_comments_count(self):
- return self.comment.count()
+ return self.comment.filter(active=True).count()
class Comment(ForumBase):
diff --git a/yaksh/templates/yaksh/course_forum.html b/yaksh/templates/yaksh/course_forum.html
index 4741ae0..41dbd7b 100644
--- a/yaksh/templates/yaksh/course_forum.html
+++ b/yaksh/templates/yaksh/course_forum.html
@@ -57,7 +57,9 @@
{% with thread.get_last_comment as last_comment %}
{% if thread.creator.profile.is_moderator %} INSTRUCTOR CREATED {% endif %} Last Post by: {{last_comment.creator}} . {{last_comment.modified_at|naturaltime}}
{% endwith %}
- Delete
+ {% if user.profile.is_moderator %}
+ Delete
+ {% endif %}
diff --git a/yaksh/templates/yaksh/thread_comments.html b/yaksh/templates/yaksh/thread_comments.html
index ab0ade9..f614b7a 100644
--- a/yaksh/templates/yaksh/thread_comments.html
+++ b/yaksh/templates/yaksh/thread_comments.html
@@ -11,7 +11,12 @@
{{thread.description}}
@@ -29,7 +34,10 @@ {% endif %}{{comment.description}}
- by: {{comment.user.username}} . {{comment.created_at}} + + by: {{comment.creator.username}} . {{comment.created_at}} + {% if user.profile.is_moderator %}Delete{% endif %} +