From bcdc986552c66639606ed5e7e9956822b5136801 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Thu, 6 Oct 2011 17:27:41 -0300 Subject: moved mention savings to the celery job and now many test cases for email alerts fail --- askbot/models/base.py | 10 ---------- askbot/tasks.py | 16 +++++++++++++++- askbot/tests/on_screen_notification_tests.py | 2 ++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/askbot/models/base.py b/askbot/models/base.py index 80572b86..b456bca8 100644 --- a/askbot/models/base.py +++ b/askbot/models/base.py @@ -134,16 +134,6 @@ def parse_and_save_post(post, author = None, **kwargs): timestamp = post.get_time_of_last_edit() - #create new mentions - for u in newly_mentioned_users: - from askbot.models.user import Activity - Activity.objects.create_new_mention( - mentioned_whom = u, - mentioned_in = post, - mentioned_by = author, - mentioned_at = timestamp - ) - #todo: this is handled in signal because models for posts #are too spread out from askbot.models import signals diff --git a/askbot/tasks.py b/askbot/tasks.py index b0ac5356..0a238df1 100644 --- a/askbot/tasks.py +++ b/askbot/tasks.py @@ -100,7 +100,21 @@ def record_post_update( exclude_list = [updated_by, ] ) - update_activity.add_recipients(recipients) + #create new mentions + for u in newly_mentioned_users: + from askbot.models.user import Activity + Activity.objects.create_new_mention( + mentioned_whom = u, + mentioned_in = post, + mentioned_by = updated_by, + mentioned_at = timestamp + ) + + #we don't want to save a mention and a separate notification + #about the response + update_activity.add_recipients( + recipients# - set(newly_mentioned_users) + ) assert(updated_by not in recipients) diff --git a/askbot/tests/on_screen_notification_tests.py b/askbot/tests/on_screen_notification_tests.py index 574f4e5e..0d668542 100644 --- a/askbot/tests/on_screen_notification_tests.py +++ b/askbot/tests/on_screen_notification_tests.py @@ -244,6 +244,8 @@ class OnScreenUpdateNotificationTests(TestCase): ) def test_self_comments(self): + """poster of the question or answer adds a comment + under the corresponding question or answer""" self.reset_response_counts() time.sleep(1) timestamp = datetime.datetime.now() -- cgit v1.2.3-1-g7c22