diff options
author | CruiseDevice | 2020-09-16 07:23:36 +0530 |
---|---|---|
committer | ankitjavalkar | 2020-10-08 10:42:50 +0530 |
commit | 5e49406420207123afec88a1ca7138e7a58c2acc (patch) | |
tree | 9680cf23a1aa28f8947ca66f270c4bd48e288bbe /yaksh/views.py | |
parent | 05ecae144ba161ee88ae98ff4313c9e5480bb604 (diff) | |
download | online_test-5e49406420207123afec88a1ca7138e7a58c2acc.tar.gz online_test-5e49406420207123afec88a1ca7138e7a58c2acc.tar.bz2 online_test-5e49406420207123afec88a1ca7138e7a58c2acc.zip |
Show Lesson post and comments in discussion forum
- Use trash icon instead of DELETE button
- Sidebar to navigate between course forum and lesson forum
- Course forum displays all the questions (posts) linked with the
course model, and Lesson forum displays all the questions (posts)
linked with the Lesson model.
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index ae00fc6..084ec1e 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -2811,7 +2811,6 @@ def show_lesson(request, lesson_id, module_id, course_id): post = Post.objects.get( target_ct=lesson_ct, target_id=learn_unit.lesson.id, active=True, title=title, creator=user, - description=f'Discussion on {title} lesson', ) except Post.DoesNotExist: post = Post.objects.create( @@ -3519,6 +3518,27 @@ def course_forum(request, course_id): @login_required @email_verified +def lessons_forum(request, course_id): + user = request.user + base_template = 'user.html' + moderator = False + if is_moderator(user): + base_template = 'manage.html' + moderator = True + course = get_object_or_404(Course, id=course_id) + course_ct = ContentType.objects.get_for_model(course) + lesson_posts = course.get_lesson_posts(user) + return render(request, 'yaksh/lessons_forum.html', { + 'user': user, + 'base_template': base_template, + 'moderator': moderator, + 'course': course, + 'posts': lesson_posts, + }) + + +@login_required +@email_verified def post_comments(request, course_id, uuid): user = request.user base_template = 'user.html' @@ -3545,6 +3565,7 @@ def post_comments(request, course_id, uuid): 'base_template': base_template, 'form': form, 'user': user, + 'course': course }) @@ -3554,7 +3575,9 @@ 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)): - raise Http404(f'Only a course creator or a teacher can delete the post.') + raise Http404( + 'Only a course creator or a teacher can delete the post.' + ) post = get_object_or_404(Post, uid=uuid) post.comment.active = False post.active = False @@ -3570,7 +3593,7 @@ def hide_comment(request, course_id, uuid): course = get_object_or_404(Course, id=course_id) if (not course.is_creator(user) or not course.is_teacher(user)): raise Http404( - f'Only a course creator or a teacher can delete the comments' + 'Only a course creator or a teacher can delete the comments' ) comment = get_object_or_404(Comment, uid=uuid) post_uid = comment.post_field.uid |