summaryrefslogtreecommitdiffstats
path: root/forum/managers.py
diff options
context:
space:
mode:
Diffstat (limited to 'forum/managers.py')
-rw-r--r--forum/managers.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/forum/managers.py b/forum/managers.py
index aa155415..e05aed53 100644
--- a/forum/managers.py
+++ b/forum/managers.py
@@ -18,9 +18,13 @@ class QuestionManager(models.Manager):
def get_questions_by_tag(self, tagname, orderby):
questions = self.filter(deleted=False, tags__name = unquote(tagname)).order_by(orderby)
return questions
+
+ def get_questions_by_category(self, categoryname, orderby):
+ questions = self.filter(category__name = categoryname).order_by(orderby)
+ return questions
def get_unanswered_questions(self, orderby):
- questions = self.filter(deleted=False, answer_count=0).order_by(orderby)
+ questions = self.filter(deleted=False, answer_accepted=False).order_by(orderby)
return questions
def get_questions(self, orderby):
@@ -93,11 +97,11 @@ class QuestionManager(models.Manager):
"""
#print datetime.datetime.now()
from forum.models import Question
- questions = list(Question.objects.filter(tagnames = question.tagnames).all())
+ questions = list(Question.objects.filter(tagnames = question.tagnames).exclude(id=question.id).all())
tags_list = question.tags.all()
for tag in tags_list:
- extend_questions = Question.objects.filter(tags__id = tag.id)[:50]
+ extend_questions = Question.objects.filter(tags__id = tag.id).exclude(id=question.id)[:50]
for item in extend_questions:
if item not in questions and len(questions) < 10:
questions.append(item)