summaryrefslogtreecommitdiffstats
path: root/forum/managers.py
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2009-07-10 19:11:34 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2009-07-10 19:11:34 -0400
commitbb801f2bbd9f26bebca846b71e8947a1951f86a5 (patch)
treecd4f7417cdbabc6834aeb45f73f09208a738ac2d /forum/managers.py
parentd3b7efc1eba6f38fba8d5110c7155f477d1459e6 (diff)
downloadaskbot-bb801f2bbd9f26bebca846b71e8947a1951f86a5.tar.gz
askbot-bb801f2bbd9f26bebca846b71e8947a1951f86a5.tar.bz2
askbot-bb801f2bbd9f26bebca846b71e8947a1951f86a5.zip
english translation
Diffstat (limited to 'forum/managers.py')
-rw-r--r--forum/managers.py55
1 files changed, 2 insertions, 53 deletions
diff --git a/forum/managers.py b/forum/managers.py
index 0f22c59c..94f58ea7 100644
--- a/forum/managers.py
+++ b/forum/managers.py
@@ -4,29 +4,8 @@ from django.contrib.auth.models import User, UserManager
from django.db import connection, models, transaction
from django.db.models import Q
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_count=0).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):
"""
Updates Tag associations for a question to match the given
@@ -113,12 +92,7 @@ class TagManager(models.Manager):
'WHERE tag_id = tag.id'
') '
'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]
- return tags
-
+
def get_or_create_multiple(self, names, user):
"""
Fetches a list of Tags with the given names, creating any Tags
@@ -149,19 +123,6 @@ class TagManager(models.Manager):
query = self.UPDATE_USED_COUNTS_QUERY % ','.join(['%s'] * len(tags))
cursor.execute(query, [tag.id for tag in tags])
transaction.commit_unless_managed()
-
- def get_tags_by_questions(self, questions):
- question_ids = []
- for question in questions:
- question_ids.append(question.id)
-
- question_ids_str = ','.join([str(id) for id in question_ids])
- related_tags = self.extra(
- tables=['tag', 'question_tags'],
- where=["tag.id = question_tags.tag_id AND question_tags.question_id IN (" + question_ids_str + ")"]
- ).distinct()
-
- return related_tags
class AnswerManager(models.Manager):
GET_ANSWERS_FROM_USER_QUESTIONS = u'SELECT answer.* FROM answer INNER JOIN question ON answer.question_id = question.id WHERE question.author_id =%s AND answer.author_id <> %s'
@@ -244,16 +205,4 @@ class ReputeManager(models.Manager):
return row[0]
else:
- return 0
-class AwardManager(models.Manager):
- def get_recent_awards(self):
- awards = super(AwardManager, self).extra(
- select={'badge_id': 'badge.id', 'badge_name':'badge.name',
- 'badge_description': 'badge.description', 'badge_type': 'badge.type',
- 'user_id': 'auth_user.id', 'user_name': 'auth_user.username'
- },
- tables=['award', 'badge', 'auth_user'],
- order_by=['-awarded_at'],
- where=['auth_user.id=award.user_id AND badge_id=badge.id'],
- ).values('badge_id', 'badge_name', 'badge_description', 'badge_type', 'user_id', 'user_name')
- return awards
+ return 0 \ No newline at end of file