diff options
author | CruiseDevice | 2020-04-13 17:27:49 +0530 |
---|---|---|
committer | CruiseDevice | 2020-04-13 17:27:49 +0530 |
commit | 2f9331717075b34534f2745706f57a98f7dce20d (patch) | |
tree | e942155f11e47299d7deb5447267c0055e49d4de /yaksh/views.py | |
parent | 0e6c7d589114450d5cd1bc581ee1692c235f1a73 (diff) | |
download | online_test-2f9331717075b34534f2745706f57a98f7dce20d.tar.gz online_test-2f9331717075b34534f2745706f57a98f7dce20d.tar.bz2 online_test-2f9331717075b34534f2745706f57a98f7dce20d.zip |
Add feature to hide thread or comments
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index afa21df..0567f3d 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -3198,7 +3198,7 @@ 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) - threads = course.thread.all().order_by('-modified_at') + threads = course.thread.filter(active=True).order_by('-modified_at') if request.method == "POST": form = ThreadForm(request.POST, request.FILES) if form.is_valid(): @@ -3214,13 +3214,15 @@ def course_forum(request, course_id): 'user': user, 'course': course, 'threads': threads, - 'form': form + 'form': form, + 'user': user }) @login_required @email_verified def thread_comments(request, course_id, uuid): + user = request.user thread = get_object_or_404(Thread, uid=uuid) comments = thread.comment.filter(active=True) form = CommentForm() @@ -3235,11 +3237,24 @@ def thread_comments(request, course_id, uuid): return render(request, 'yaksh/thread_comments.html', { 'thread': thread, 'comments': comments, - 'form': form + 'form': form, + 'user': user }) @login_required @email_verified -def delete_thread(request, course_id, uuid): +def hide_thread(request, course_id, uuid): thread = get_object_or_404(Thread, uid=uuid) + thread.comment.active = False + thread.active = False + thread.save() + return redirect('yaksh:course_forum', course_id) + + +def hide_comment(request, course_id, uuid): + comment = get_object_or_404(Comment, uid=uuid) + thread_uid = comment.thread_field.uid + comment.active = False + comment.save() + return redirect('yaksh:thread_comments', course_id, thread_uid) |