diff options
author | CruiseDevice | 2020-09-17 13:32:12 +0530 |
---|---|---|
committer | ankitjavalkar | 2020-10-08 10:42:51 +0530 |
commit | 31e258a9d2e253691fd548d47aaab3cfee756322 (patch) | |
tree | 496d815a2df967d515d09030108324d7a7d5a998 | |
parent | 5e49406420207123afec88a1ca7138e7a58c2acc (diff) | |
download | online_test-31e258a9d2e253691fd548d47aaab3cfee756322.tar.gz online_test-31e258a9d2e253691fd548d47aaab3cfee756322.tar.bz2 online_test-31e258a9d2e253691fd548d47aaab3cfee756322.zip |
Fix tests and minor changes
-rw-r--r-- | yaksh/models.py | 4 | ||||
-rw-r--r-- | yaksh/templates/yaksh/course_forum.html | 42 | ||||
-rw-r--r-- | yaksh/templates/yaksh/lessons_forum.html | 12 | ||||
-rw-r--r-- | yaksh/templatetags/custom_filters.py | 1 | ||||
-rw-r--r-- | yaksh/test_views.py | 4 | ||||
-rw-r--r-- | yaksh/views.py | 4 |
6 files changed, 35 insertions, 32 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index df70fc1..2ed03ed 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1102,7 +1102,7 @@ class Course(models.Model): learning_units.extend(module.get_learning_units()) return learning_units - def get_lesson_posts(self, user): + def get_lesson_posts(self): learning_units = self.get_learning_units() comments = [] for unit in learning_units: @@ -1113,7 +1113,7 @@ class Course(models.Model): post = Post.objects.get( target_ct=lesson_ct, target_id=unit.lesson.id, - active=True, title=title, creator=user + active=True, title=title ) except Post.DoesNotExist: post = None diff --git a/yaksh/templates/yaksh/course_forum.html b/yaksh/templates/yaksh/course_forum.html index a9bda6f..0346121 100644 --- a/yaksh/templates/yaksh/course_forum.html +++ b/yaksh/templates/yaksh/course_forum.html @@ -55,28 +55,28 @@ </div> </div> <br> - <div class="row justify-content-center"> - <div class="col-md-6"> - <form class="my-2 my-lg-0" action="" method="GET"> - <div class="input-group"> - <input type="search" placeholder="Search Post" name="search_post" class="form-control"> - <span class="input-group-append"> - <button class="btn btn-outline-info"> - <i class="fa fa-search"></i> Search - </button> - </span> - </div> - </form> - </div> - <div class="col-md-4"> - <a class="btn btn-outline-danger" href="{% url 'yaksh:course_forum' course.id %}"> - <i class="fa fa-times"></i> Clear Search - </a> - </div> - </div> - <br> {% with objects as posts %} {% if posts %} + <div class="row justify-content-center"> + <div class="col-md-6"> + <form class="my-2 my-lg-0" action="" method="GET"> + <div class="input-group"> + <input type="search" placeholder="Search Post" name="search_post" class="form-control"> + <span class="input-group-append"> + <button class="btn btn-outline-info"> + <i class="fa fa-search"></i> Search + </button> + </span> + </div> + </form> + </div> + <div class="col-md-4"> + <a class="btn btn-outline-danger" href="{% url 'yaksh:course_forum' course.id %}"> + <i class="fa fa-times"></i> Clear Search + </a> + </div> + </div> + <br> {% include "yaksh/paginator.html" %} <br> <table id="posts_table" class="tablesorter table"> @@ -120,7 +120,7 @@ <br> {% include "yaksh/paginator.html" %} {% else %} - No discussion posts are there yet. Create one to start discussing. + <center>No discussion posts are there yet. Create one to start discussing.</center> {% endif %} {% endwith %} </div> diff --git a/yaksh/templates/yaksh/lessons_forum.html b/yaksh/templates/yaksh/lessons_forum.html index a4fd23b..ee65074 100644 --- a/yaksh/templates/yaksh/lessons_forum.html +++ b/yaksh/templates/yaksh/lessons_forum.html @@ -7,10 +7,6 @@ <div id="wrapper" class="d-flex"> {% include "yaksh/sidebar.html" %} <div class="container" id="page-content-wrapper"> - <div> - <h2><center>{{course.name}}</center></h2> - <center>Discussion Forum</center> - </div> <div class="d-flex p-2 bd-highlight"> <div class="col-md-4"> {% if moderator %} @@ -25,6 +21,10 @@ </div> </div> {% if posts %} + <div> + <h2><center>{{course.name}}</center></h2> + <center>Discussion Forum</center> + </div> <table class="table"> <thead class="thread-inverse"> <tr> @@ -63,6 +63,10 @@ {% endfor %} </tbody> </table> + {% else %} + <div> + <center>No Lesson posts here. They will appear when someone comments on video lessons.</center> + </div> {% endif %} </div> </div> diff --git a/yaksh/templatetags/custom_filters.py b/yaksh/templatetags/custom_filters.py index f297598..57ec7dd 100644 --- a/yaksh/templatetags/custom_filters.py +++ b/yaksh/templatetags/custom_filters.py @@ -1,7 +1,6 @@ from django import template from django.template.defaultfilters import stringfilter from django.forms.fields import CheckboxInput -from django.contrib.contenttypes.models import ContentType from ast import literal_eval import os try: diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 906f2e3..206120e 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -6808,7 +6808,7 @@ class TestPost(TestCase): }) response = self.client.get(url, follow=True) self.assertEqual(response.status_code, 200) - redirection_url = '/exam/login/?next=/exam/forum/{0}/'.format( + redirection_url = '/exam/login/?next=/exam/forum/course_forum/{0}/'.format( str(self.course.id) ) self.assertRedirects(response, redirection_url) @@ -6839,7 +6839,7 @@ class TestPost(TestCase): self.assertEquals(response.status_code, 404) def test_course_forum_url_resolves_course_forum_view(self): - view = resolve('/exam/forum/1/') + view = resolve('/exam/forum/course_forum/1/') self.assertEqual(view.func, course_forum) def test_course_forum_contains_link_to_post_comments_page(self): diff --git a/yaksh/views.py b/yaksh/views.py index 084ec1e..e465369 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -2810,7 +2810,7 @@ def show_lesson(request, lesson_id, module_id, course_id): try: post = Post.objects.get( target_ct=lesson_ct, target_id=learn_unit.lesson.id, - active=True, title=title, creator=user, + active=True, title=title ) except Post.DoesNotExist: post = Post.objects.create( @@ -3527,7 +3527,7 @@ def lessons_forum(request, course_id): 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) + lesson_posts = course.get_lesson_posts() return render(request, 'yaksh/lessons_forum.html', { 'user': user, 'base_template': base_template, |