From 5e49406420207123afec88a1ca7138e7a58c2acc Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Wed, 16 Sep 2020 07:23:36 +0530 Subject: 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. --- yaksh/models.py | 19 +++ yaksh/static/yaksh/css/custom.css | 49 ++++++- yaksh/templates/yaksh/course_forum.html | 224 ++++++++++++++++--------------- yaksh/templates/yaksh/lessons_forum.html | 70 ++++++++++ yaksh/templates/yaksh/post_comments.html | 6 +- yaksh/templates/yaksh/show_video.html | 2 +- yaksh/templates/yaksh/sidebar.html | 8 ++ yaksh/urls.py | 4 +- yaksh/views.py | 29 +++- 9 files changed, 286 insertions(+), 125 deletions(-) create mode 100644 yaksh/templates/yaksh/lessons_forum.html create mode 100644 yaksh/templates/yaksh/sidebar.html (limited to 'yaksh') diff --git a/yaksh/models.py b/yaksh/models.py index 67f981e..df70fc1 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1102,6 +1102,25 @@ class Course(models.Model): learning_units.extend(module.get_learning_units()) return learning_units + def get_lesson_posts(self, user): + learning_units = self.get_learning_units() + comments = [] + for unit in learning_units: + if unit.lesson is not None: + lesson_ct = ContentType.objects.get_for_model(unit.lesson) + title = unit.lesson.name + try: + post = Post.objects.get( + target_ct=lesson_ct, + target_id=unit.lesson.id, + active=True, title=title, creator=user + ) + except Post.DoesNotExist: + post = None + if post is not None: + comments.append(post) + return comments + def remove_trial_modules(self): learning_modules = self.learning_module.all() for module in learning_modules: diff --git a/yaksh/static/yaksh/css/custom.css b/yaksh/static/yaksh/css/custom.css index 26efbed..edb9530 100644 --- a/yaksh/static/yaksh/css/custom.css +++ b/yaksh/static/yaksh/css/custom.css @@ -109,12 +109,49 @@ body, .dropdown-menu { FORUM STYLE ----------------------------------------------------- */ -.brown-light { - background: #f4a460; - padding-left: 0.3em; - padding-right: 0.3em; - padding-top: 0.2em; - padding-bottom: 0.2em; + #wrapper { + overflow-x: hidden; + } + +#sidebar-wrapper { + min-height: 100vh; + margin-left: -15rem; + -webkit-transition: margin .25s ease-out; + -moz-transition: margin .25s ease-out; + -o-transition: margin .25s ease-out; + transition: margin .25s ease-out; +} + +#sidebar-wrapper .sidebar-heading { + padding: 0.875rem 1.25rem; + font-size: 1.2rem; +} + +#sidebar-wrapper .list-group { + width: 15rem; +} + +#page-content-wrapper { + min-width: 100vw; +} + +#wrapper.toggled #sidebar-wrapper { + margin-left: 0; +} + +@media (min-width: 768px) { + #sidebar-wrapper { + margin-left: 0; + } + + #page-content-wrapper { + min-width: 0; + width: 100%; + } + + #wrapper.toggled #sidebar-wrapper { + margin-left: -15rem; + } } .post_image, .comment_image { diff --git a/yaksh/templates/yaksh/course_forum.html b/yaksh/templates/yaksh/course_forum.html index 4724981..a9bda6f 100644 --- a/yaksh/templates/yaksh/course_forum.html +++ b/yaksh/templates/yaksh/course_forum.html @@ -4,124 +4,126 @@ {{course.name}}: Discussion Forum {% endblock title %} {% block content %} -
Posts | -Created by | -Replies | -Last reply | -- |
---|---|---|---|---|
- {{post.title}} - {{ post.description|truncatewords:30 }} - Last updated: {{post.modified_at}} - | -{{post.creator.username}} | -{{post.get_comments_count}} | -- {% with post.get_last_comment as last_comment %} - {% if last_comment %} - {{last_comment.creator}} - {% else %} - None - {% endif %} - {% endwith %} - | -- {% if user.profile.is_moderator %} - Delete - {% endif %} - | -
Posts | +Created by | +Replies | +Last reply | ++ |
---|---|---|---|---|
+ {{post.title}} + {{ post.description|truncatewords:30 }} + Last updated: {{post.modified_at}} + | +{{post.creator.username}} | +{{post.get_comments_count}} | ++ {% with post.get_last_comment as last_comment %} + {% if last_comment %} + {{last_comment.creator}} + {% else %} + None + {% endif %} + {% endwith %} + | ++ {% if user.profile.is_moderator %} + + {% endif %} + | +
Posts | +Created by | +Replies | +Last reply | ++ |
---|---|---|---|---|
+ {{post.title}} + {{ post.description|truncatewords:30 }} + Last updated: {{post.modified_at}} + | +{{post.creator.username}} | +{{post.get_comments_count}} | ++ {% with post.get_last_comment as last_comment %} + {% if last_comment %} + {{last_comment.creator}} + {% else %} + None + {% endif %} + {% endwith %} + | ++ {% if user.profile.is_moderator %} + + {% endif %} + | +
{{comment.description}}
diff --git a/yaksh/templates/yaksh/show_video.html b/yaksh/templates/yaksh/show_video.html index 76a48d4..ef6f459 100644 --- a/yaksh/templates/yaksh/show_video.html +++ b/yaksh/templates/yaksh/show_video.html @@ -236,7 +236,7 @@ {{comment.creator.username}}{{comment.description}}
diff --git a/yaksh/templates/yaksh/sidebar.html b/yaksh/templates/yaksh/sidebar.html new file mode 100644 index 0000000..7d0ac74 --- /dev/null +++ b/yaksh/templates/yaksh/sidebar.html @@ -0,0 +1,8 @@ + +