summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authorCruiseDevice2020-04-15 21:19:09 +0530
committerCruiseDevice2020-04-15 21:19:09 +0530
commit169228186d8c9ad880ee33c5190e49203d2c5243 (patch)
tree4638c2069208b259375429a635b3f40545d75419 /yaksh
parent508e0e78bb0bd3e8ebbad81e948f13de5c01b20f (diff)
downloadonline_test-169228186d8c9ad880ee33c5190e49203d2c5243.tar.gz
online_test-169228186d8c9ad880ee33c5190e49203d2c5243.tar.bz2
online_test-169228186d8c9ad880ee33c5190e49203d2c5243.zip
Resolve comments
- Fix "'image' attribute has no file associated with it" issue. - Don't allow users who are not part of a course to see the discussion forum of that course. - Add Discussion forum link in moderator interface under course_details page. - Remove custom css for post and comments in Discussion forum. Use bootstrap 'img-fluid' class instead. 'img-fluid' fills the height and width of the card. - Use instance.uid instead of just instance in get_image_dir.
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/models.py2
-rw-r--r--yaksh/static/yaksh/css/custom.css9
-rw-r--r--yaksh/templates/yaksh/course_detail_options.html5
-rw-r--r--yaksh/templates/yaksh/course_forum.html5
-rw-r--r--yaksh/templates/yaksh/post_comments.html10
-rw-r--r--yaksh/views.py15
6 files changed, 28 insertions, 18 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 424e2f5..4a7c4ba 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -243,7 +243,7 @@ def validate_image(image):
def get_image_dir(instance, filename):
return os.sep.join((
- 'post_%s' % (instance), filename
+ 'post_%s' % (instance.uid), filename
))
diff --git a/yaksh/static/yaksh/css/custom.css b/yaksh/static/yaksh/css/custom.css
index d6b9bdc..63ee455 100644
--- a/yaksh/static/yaksh/css/custom.css
+++ b/yaksh/static/yaksh/css/custom.css
@@ -97,12 +97,3 @@ body, .dropdown-menu {
min-height: 100vh;
transition: all 0.3s;
}
-
-/* ---------------------------------------------------
- Forum STYLE
------------------------------------------------------ */
-
-.comment_image {
- width: 350px;
- height: 350px;
-} \ No newline at end of file
diff --git a/yaksh/templates/yaksh/course_detail_options.html b/yaksh/templates/yaksh/course_detail_options.html
index 90662d6..4dd4dda 100644
--- a/yaksh/templates/yaksh/course_detail_options.html
+++ b/yaksh/templates/yaksh/course_detail_options.html
@@ -30,6 +30,11 @@
</a>
</li>
<li class="nav-item">
+ <a href="{% url 'yaksh:course_forum' course.id %}" class="nav-link list-group-item" title="Discussion forum of this course" data-placement="top" data-toggle="tooltip">
+ Discussion Forum
+ </a>
+ </li>
+ <li class="nav-item">
<a class="nav-link list-group-item {% if is_add_teacher %} active {% endif %}" href="{% url 'yaksh:search_teacher' course.id %}" data-toggle="tooltip" title="Add Teachers/TAs to this course" data-placement="top">
Add Teachers/TAs
</a>
diff --git a/yaksh/templates/yaksh/course_forum.html b/yaksh/templates/yaksh/course_forum.html
index 407296f..3e4d07b 100644
--- a/yaksh/templates/yaksh/course_forum.html
+++ b/yaksh/templates/yaksh/course_forum.html
@@ -41,16 +41,13 @@
<br>
<br>
<div>
- <h3>Posts:</h3>
{% if posts %}
+ <h3>Posts:</h3>
{% for post in posts %}
<div class="card">
<div class="card-body">
<a href="{% url "yaksh:post_comments" course.id post.uid %}">{{post.title}}</a>
<br>
- {% if post.image %}
- <img src="{{post.image.url}}" class="post_image">
- {% endif %}
<p class="pull-right"><small>{{post.get_comments_count}}{% if post.get_comments_count > 1 %} replies{% else %} reply{% endif %}</small></p>
</div>
<div class="card-footer">
diff --git a/yaksh/templates/yaksh/post_comments.html b/yaksh/templates/yaksh/post_comments.html
index 89f0762..f5cc771 100644
--- a/yaksh/templates/yaksh/post_comments.html
+++ b/yaksh/templates/yaksh/post_comments.html
@@ -20,9 +20,11 @@
</div>
<div class="card-body">
<p>{{post.description}}</p>
- <a href="{{post.image.url}}" target="_blank">
- <img src="{{post.image.url}}" alt="">
- </a>
+ {% if post.image %}
+ <a href="{{post.image.url}}" target="_blank">
+ <img src="{{post.image.url}}" class="img-fluid" alt="">
+ </a>
+ {% endif %}
</div>
</div>
<br>
@@ -33,7 +35,7 @@
<div class="card-body">
{% if comment.image %}
<a href="{{comment.image.url}}" target="_blank">
- <img src="{{comment.image.url}}" class='comment_image'>
+ <img src="{{comment.image.url}}" class='img-fluid'>
</a>
{% endif %}
<p>{{comment.description}}</p>
diff --git a/yaksh/views.py b/yaksh/views.py
index 197891c..c154d4e 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -3198,6 +3198,9 @@ def download_course_progress(request, course_id):
def course_forum(request, course_id):
user = request.user
course = get_object_or_404(Course, id=course_id)
+ if (not course.is_creator(user) and not course.is_teacher(user)
+ and not course.is_student(user)):
+ raise Http404('You are not enrolled in {0} course'.format(course.name))
posts = course.post.filter(active=True).order_by('-modified_at')
if request.method == "POST":
form = PostForm(request.POST, request.FILES)
@@ -3225,6 +3228,10 @@ def post_comments(request, course_id, uuid):
user = request.user
post = get_object_or_404(Post, uid=uuid)
comments = post.comment.filter(active=True)
+ course = get_object_or_404(Course, id=course_id)
+ if (not course.is_creator(user) and not course.is_teacher(user)
+ and not course.is_student(user)):
+ raise Http404('You are not enrolled in {0} course'.format(course.name))
form = CommentForm()
if request.method == "POST":
form = CommentForm(request.POST, request.FILES)
@@ -3245,6 +3252,10 @@ def post_comments(request, course_id, uuid):
@login_required
@email_verified
def hide_post(request, course_id, uuid):
+ course = get_object_or_404(Course, id=course_id)
+ if (not course.is_creator(user) and not course.is_teacher(user)
+ and not course.is_student(user)):
+ raise Http404('You are not enrolled in {0} course'.format(course.name))
post = get_object_or_404(Post, uid=uuid)
post.comment.active = False
post.active = False
@@ -3253,6 +3264,10 @@ def hide_post(request, course_id, uuid):
def hide_comment(request, course_id, uuid):
+ course = get_object_or_404(Course, id=course_id)
+ if (not course.is_creator(user) and not course.is_teacher(user)
+ and not course.is_student(user)):
+ raise Http404('You are not enrolled in {0} course'.format(course.name))
comment = get_object_or_404(Comment, uid=uuid)
post_uid = comment.post_field.uid
comment.active = False