diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-06-07 00:54:39 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-06-07 00:54:39 -0400 |
commit | 57033196f904477631c397fab50681f0d1aa7834 (patch) | |
tree | 59b49b40680af03ef5c0a31782c19737e404257b /forum/models | |
parent | 430ce40aea1fddd086640bbd54242e6832478e49 (diff) | |
download | askbot-57033196f904477631c397fab50681f0d1aa7834.tar.gz askbot-57033196f904477631c397fab50681f0d1aa7834.tar.bz2 askbot-57033196f904477631c397fab50681f0d1aa7834.zip |
notification records are correct but response counters are exxagerated. added unit tests for response counters
Diffstat (limited to 'forum/models')
-rw-r--r-- | forum/models/answer.py | 3 | ||||
-rw-r--r-- | forum/models/base.py | 11 | ||||
-rw-r--r-- | forum/models/content.py | 1 | ||||
-rw-r--r-- | forum/models/question.py | 2 |
4 files changed, 11 insertions, 6 deletions
diff --git a/forum/models/answer.py b/forum/models/answer.py index 48b1c464..b4e8963e 100644 --- a/forum/models/answer.py +++ b/forum/models/answer.py @@ -172,6 +172,9 @@ class Answer(content.Content, DeletableContent): include_comments = True ) ) + for answer in self.question.answers.all(): + receiving_users.update(answer.get_author_list()) + receiving_users -= set(exclude_list) return list(receiving_users) diff --git a/forum/models/base.py b/forum/models/base.py index 964c6142..d832b71c 100644 --- a/forum/models/base.py +++ b/forum/models/base.py @@ -126,11 +126,12 @@ def save_post(post, **kwargs): #create new mentions for u in newly_mentioned_users: from forum.models.user import Activity - Activity.objects.create_new_mention( - mentioned_whom = u, - mentioned_in = post, - mentioned_by = last_author - ) + if u != last_author: + Activity.objects.create_new_mention( + mentioned_whom = u, + mentioned_in = post, + mentioned_by = last_author + ) #todo: this is handled in signal because models for posts #are too spread out diff --git a/forum/models/content.py b/forum/models/content.py index 441f7133..eb2b423e 100644 --- a/forum/models/content.py +++ b/forum/models/content.py @@ -75,6 +75,7 @@ class Content(models.Model): comment.save() self.comment_count = self.comment_count + 1 self.save() + return comment def get_instant_notification_subscribers( self, diff --git a/forum/models/question.py b/forum/models/question.py index 88f01e4f..c6c16578 100644 --- a/forum/models/question.py +++ b/forum/models/question.py @@ -437,7 +437,7 @@ class Question(content.Content, DeletableContent): def add_revision(self,author=None, text=None, comment=None, revised_at=None): if None in (author, text, comment): - raise Exception('author, text and revised_at are required arguments') + raise Exception('author, text and comment are required arguments') rev_no = self.revisions.all().count() + 1 if comment in (None, ''): if rev_no == 1: |