diff options
author | Adolfo Fitoria <fitoria@fitoria-laptop.(none)> | 2010-02-09 14:12:05 -0600 |
---|---|---|
committer | Adolfo Fitoria <fitoria@fitoria-laptop.(none)> | 2010-02-09 14:12:05 -0600 |
commit | 8de2b9131ddcef647799cf8e1e79921284523073 (patch) | |
tree | 81e17d84530990e35a0accba3a7886266a601482 /forum/managers.py | |
parent | 7e95e6481d1e81e43d4b442cbcf3fe37f20d89cc (diff) | |
parent | 9d1fb9890b97beb55461ca34f9757bc685461130 (diff) | |
download | askbot-8de2b9131ddcef647799cf8e1e79921284523073.tar.gz askbot-8de2b9131ddcef647799cf8e1e79921284523073.tar.bz2 askbot-8de2b9131ddcef647799cf8e1e79921284523073.zip |
Merge branch 'evgenyfadeev/master'
Conflicts:
.gitignore
INSTALL
TODO
cnprog.wsgi
django_authopenid/urls.py
django_authopenid/views.py
drop-all-tables.sh
forum/auth.py
forum/managers.py
forum/models.py
forum/templatetags/extra_tags.py
forum/views.py
locale/es/LC_MESSAGES/django.mo
locale/es/LC_MESSAGES/django.po
settings.py
settings_local.py.dist
sql_scripts/update_2009_01_25_001.sql
sql_scripts/update_2009_02_26_001.sql
sql_scripts/update_2009_04_10_001.sql
templates/authopenid/confirm_email.txt
templates/authopenid/sendpw_email.txt
templates/content/js/compress.bat
templates/content/js/flot-build.bat
templates/content/style/style.css
templates/footer.html
templates/question.html
templates/user_reputation.html
templates/user_stats.html
templates/user_votes.html
templates/users_questions.html
urls.py
Diffstat (limited to 'forum/managers.py')
-rw-r--r-- | forum/managers.py | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/forum/managers.py b/forum/managers.py index 31528428..1504491a 100644 --- a/forum/managers.py +++ b/forum/managers.py @@ -7,25 +7,6 @@ from forum.models import * from urllib import quote, unquote class QuestionManager(models.Manager): - def get_translation_questions(self, orderby, page_size): - questions = self.filter(deleted=False, author__id__in=[28,29]).order_by(orderby)[:page_size] - return questions - - def get_questions_by_pagesize(self, orderby, page_size): - questions = self.filter(deleted=False).order_by(orderby)[:page_size] - return questions - - def get_questions_by_tag(self, tagname, orderby): - questions = self.filter(deleted=False, tags__name = unquote(tagname)).order_by(orderby) - return questions - - def get_unanswered_questions(self, orderby): - questions = self.filter(deleted=False, answer_accepted=False).order_by(orderby) - return questions - - def get_questions(self, orderby): - questions = self.filter(deleted=False).order_by(orderby) - return questions def update_tags(self, question, tagnames, user): """ @@ -70,7 +51,7 @@ class QuestionManager(models.Manager): # although we have imported all classes from models on top. from forum.models import Answer self.filter(id=question.id).update( - answer_count=Answer.objects.get_answers_from_question(question).count()) + answer_count=Answer.objects.get_answers_from_question(question).filter(deleted=False).count()) def update_view_count(self, question): """ @@ -93,11 +74,11 @@ class QuestionManager(models.Manager): """ #print datetime.datetime.now() from forum.models import Question - questions = list(Question.objects.filter(tagnames = question.tagnames).exclude(id=question.id).all()) + questions = list(self.filter(tagnames = question.tagnames, deleted=False).all()) tags_list = question.tags.all() for tag in tags_list: - extend_questions = Question.objects.filter(tags__id = tag.id).exclude(id=question.id)[:50] + extend_questions = self.filter(tags__id = tag.id, deleted=False)[:50] for item in extend_questions: if item not in questions and len(questions) < 10: questions.append(item) @@ -110,10 +91,11 @@ class TagManager(models.Manager): 'UPDATE tag ' 'SET used_count = (' 'SELECT COUNT(*) FROM question_tags ' - 'WHERE tag_id = tag.id' + 'INNER JOIN question ON question_id=question.id ' + 'WHERE tag_id = tag.id AND question.deleted=0' ') ' 'WHERE id IN (%s)') - + def get_valid_tags(self, page_size): from forum.models import Tag tags = Tag.objects.all().filter(deleted=False).exclude(used_count=0).order_by("-id")[:page_size] |