summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yaksh/templates/yaksh/course_forum.html16
-rw-r--r--yaksh/templates/yaksh/lessons_forum.html2
-rw-r--r--yaksh/templates/yaksh/post_comments.html18
-rw-r--r--yaksh/templates/yaksh/show_video.html33
-rw-r--r--yaksh/views.py4
5 files changed, 52 insertions, 21 deletions
diff --git a/yaksh/templates/yaksh/course_forum.html b/yaksh/templates/yaksh/course_forum.html
index 0346121..3190245 100644
--- a/yaksh/templates/yaksh/course_forum.html
+++ b/yaksh/templates/yaksh/course_forum.html
@@ -29,6 +29,20 @@
</button>
</div>
</div>
+ {% if messages %}
+ <div>
+ <center>
+ {% for message in messages %}
+ <div class="alert alert-dismissible alert-{{ message.tags }}">
+ <button type="button" class="close" data-dismiss="alert">
+ <i class="fa fa-close"></i>
+ </button>
+ <strong>{{ message }}</strong>
+ </div>
+ {% endfor %}
+ </center>
+ </div>
+ {% endif %}
<!-- Modal -->
<div id="newPostModal" class="modal fade" role="dialog">
<div class="modal-dialog">
@@ -109,7 +123,7 @@
{% endwith %}
</td>
<td>
- {% if user.profile.is_moderator %}
+ {% if user == course.creator %}
<small><a href="{% url 'yaksh:hide_post' course.id post.uid %}" class="pull-right fa fa-trash"></i></a></small>
{% endif %}
</td>
diff --git a/yaksh/templates/yaksh/lessons_forum.html b/yaksh/templates/yaksh/lessons_forum.html
index ee65074..f8d1912 100644
--- a/yaksh/templates/yaksh/lessons_forum.html
+++ b/yaksh/templates/yaksh/lessons_forum.html
@@ -55,7 +55,7 @@
{% endwith %}
</td>
<td>
- {% if user.profile.is_moderator %}
+ {% if user == course.creator %}
<small><a href="{% url 'yaksh:hide_post' course.id post.uid %}" class="pull-right fa fa-trash"></i></a></small>
{% endif %}
</td>
diff --git a/yaksh/templates/yaksh/post_comments.html b/yaksh/templates/yaksh/post_comments.html
index 6051b6e..4038afb 100644
--- a/yaksh/templates/yaksh/post_comments.html
+++ b/yaksh/templates/yaksh/post_comments.html
@@ -11,6 +11,20 @@
</a>
<br>
<br>
+ {% if messages %}
+ <div>
+ <center>
+ {% for message in messages %}
+ <div class="alert alert-dismissible alert-{{ message.tags }}">
+ <button type="button" class="close" data-dismiss="alert">
+ <i class="fa fa-close"></i>
+ </button>
+ <strong>{{ message }}</strong>
+ </div>
+ {% endfor %}
+ </center>
+ </div>
+ {% endif %}
<div class="card mb-2 border-dark">
<div class="card-header text-white bg-dark py-2 px-3">
{{post.title}}
@@ -18,7 +32,7 @@
<small>
<strong>{{post.creator.username}}</strong>
{{post.created_at}}
- {% if user.profile.is_moderator %}<a href="{% url 'yaksh:hide_post' post.target.id post.uid %}" class="pull-right fa fa-trash"></a>{% endif %}
+ {% if user == course.creator %}<a href="{% url 'yaksh:hide_post' post.target.id post.uid %}" class="pull-right fa fa-trash"></a>{% endif %}
</small>
</div>
@@ -41,7 +55,7 @@
<strong class="text-muted">{{comment.creator.username}}</strong>
</div>
<div class="col-6 text-right">
- <small class="text-muted">{{comment.created_at}} {% if user.profile.is_moderator %} <a href="{% url 'yaksh:hide_comment' post.target.id comment.uid %}" class="fa fa-trash"></a>{% endif %}</small>
+ <small class="text-muted">{{comment.created_at}} {% if user == course.creator %} <a href="{% url 'yaksh:hide_comment' post.target.id comment.uid %}" class="fa fa-trash"></a>{% endif %}</small>
</div>
</div>
<p class="card-text description">{{comment.description}}</p>
diff --git a/yaksh/templates/yaksh/show_video.html b/yaksh/templates/yaksh/show_video.html
index ef6f459..022ba9c 100644
--- a/yaksh/templates/yaksh/show_video.html
+++ b/yaksh/templates/yaksh/show_video.html
@@ -227,6 +227,19 @@
</div>
</div>
{% endif %}
+ {% if state == 'lesson' %}
+ <div>
+ <b><u>Add comment:</u></b>
+ <form action="" method="POST" enctype='multipart/form-data'>
+ <div class="form-group">
+ {% csrf_token %}
+ {{form}}
+ </div>
+ <input type="submit" value="Submit" class="btn btn-success">
+ </form>
+ </div>
+ {% endif %}
+ <br>
{% if comments %}
{% for comment in comments %}
<div class="card mb-2">
@@ -235,9 +248,11 @@
<div class="col-6">
<strong class="text-muted">{{comment.creator.username}}</strong>
</div>
- <div class="col-6 text-right">
- <small class="text-muted">{{comment.created_at}} {% if user.profile.is_moderator %} <a href="{% url 'yaksh:hide_comment' course.id comment.uid %}" class="fa fa-trash"></a>{% endif %}</small>
- </div>
+ {% if user == course.creator %}
+ <div class="col-6 text-right">
+ <small class="text-muted">{{comment.created_at}} {% if user.profile.is_moderator %} <a href="{% url 'yaksh:hide_comment' course.id comment.uid %}" class="fa fa-trash"></a>{% endif %}</small>
+ </div>
+ {% endif %}
</div>
<p class="card-text description">{{comment.description}}</p>
<div>
@@ -251,18 +266,6 @@
</div>
{% endfor %}
{% endif %}
- {% if state == 'lesson' %}
- <div>
- <b><u>Add comment:</u></b>
- <form action="" method="POST" enctype='multipart/form-data'>
- <div class="form-group">
- {% csrf_token %}
- {{form}}
- </div>
- <input type="submit" value="Submit" class="btn btn-success">
- </form>
- </div>
- {% endif %}
</div>
</div>
<div id="dialog"></div>
diff --git a/yaksh/views.py b/yaksh/views.py
index e465369..8c9a9e4 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -3574,7 +3574,7 @@ def post_comments(request, course_id, uuid):
def hide_post(request, course_id, uuid):
user = request.user
course = get_object_or_404(Course, id=course_id)
- if (not course.is_creator(user) or not course.is_teacher(user)):
+ if (not course.is_creator(user) and not course.is_teacher(user)):
raise Http404(
'Only a course creator or a teacher can delete the post.'
)
@@ -3591,7 +3591,7 @@ def hide_comment(request, course_id, uuid):
user = request.user
if course_id:
course = get_object_or_404(Course, id=course_id)
- if (not course.is_creator(user) or not course.is_teacher(user)):
+ if (not course.is_creator(user) and not course.is_teacher(user)):
raise Http404(
'Only a course creator or a teacher can delete the comments'
)