summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorCruiseDevice2020-09-16 07:23:36 +0530
committerankitjavalkar2020-10-08 10:42:50 +0530
commit5e49406420207123afec88a1ca7138e7a58c2acc (patch)
tree9680cf23a1aa28f8947ca66f270c4bd48e288bbe /yaksh/models.py
parent05ecae144ba161ee88ae98ff4313c9e5480bb604 (diff)
downloadonline_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/models.py')
-rw-r--r--yaksh/models.py19
1 files changed, 19 insertions, 0 deletions
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: