summaryrefslogtreecommitdiffstats
path: root/askbot/management
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-07-02 12:43:09 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-07-02 12:43:09 -0400
commit3ed4d6c37552cc97464444a65074f3b8ddf7d9f5 (patch)
tree5d8be200da5fcd3bc1d77f81f17e3b527622e960 /askbot/management
parent17ee9fe0f5de3489d35577a783748eb84602fa86 (diff)
parent33fb5deb70373f251788b257e9fa0cbe16849b95 (diff)
downloadaskbot-3ed4d6c37552cc97464444a65074f3b8ddf7d9f5.tar.gz
askbot-3ed4d6c37552cc97464444a65074f3b8ddf7d9f5.tar.bz2
askbot-3ed4d6c37552cc97464444a65074f3b8ddf7d9f5.zip
merged with the master and tag-editor branches
Diffstat (limited to 'askbot/management')
-rw-r--r--askbot/management/commands/send_email_alerts.py29
1 files changed, 13 insertions, 16 deletions
diff --git a/askbot/management/commands/send_email_alerts.py b/askbot/management/commands/send_email_alerts.py
index e890452d..26f475a1 100644
--- a/askbot/management/commands/send_email_alerts.py
+++ b/askbot/management/commands/send_email_alerts.py
@@ -84,7 +84,7 @@ class Command(NoArgsCommand):
finally:
connection.close()
- def get_updated_questions_for_user(self,user):
+ def get_updated_questions_for_user(self, user):
"""
retreive relevant question updates for the user
according to their subscriptions and recorded question
@@ -338,11 +338,7 @@ class Command(NoArgsCommand):
#collect info on all sorts of news that happened after
#the most recent emailing to the user about this question
- q_rev = PostRevision.objects.question_revisions().filter(
- post=q,
- revised_at__gt=emailed_at
- )
-
+ q_rev = q.revisions.filter(revised_at__gt=emailed_at)
q_rev = q_rev.exclude(author=user)
#now update all sorts of metadata per question
@@ -353,22 +349,23 @@ class Command(NoArgsCommand):
else:
meta_data['new_q'] = False
- new_ans = Post.objects.get_answers().filter(
+ new_ans = Post.objects.get_answers(user).filter(
thread=q.thread,
added_at__gt=emailed_at,
deleted=False,
)
-
new_ans = new_ans.exclude(author=user)
meta_data['new_ans'] = len(new_ans)
- ans_rev = PostRevision.objects.answer_revisions().filter(
- # answer__question = q
- post__thread=q.thread,
-
- post__deleted = False,
- revised_at__gt = emailed_at
- ).distinct()
- ans_rev = ans_rev.exclude(author=user)
+
+ ans_ids = Post.objects.get_answers(user).filter(
+ thread=q.thread,
+ added_at__gt=emailed_at,
+ deleted=False,
+ ).values_list(
+ 'id', flat = True
+ )
+ ans_rev = PostRevision.objects.filter(post__id__in = ans_ids)
+ ans_rev = ans_rev.exclude(author=user).distinct()
meta_data['ans_rev'] = len(ans_rev)
comments = meta_data.get('comments', 0)