|
[
Permlink
| « Hide
]
Borys Musielak added a comment - 22/Feb/10 11:50 AM
The number of comments should be updated when adding new comment or deleting comment straight in ThreadedComment's model class, to make sure it's always in sync with the actual number of comments.
I think you linked to a wrong changeset - the one linked is a merge.
BTW, are we already using this comments field anywhere? And is it being updated every time a new comment is added / removed? A link to the code would be useful. Sorry this link is proper http://bitbucket.org/filmaster/filmaster-test/changeset/8d62afa6ea6e/ Yes we are using this filed activities templates at dev server. As you can see in the link above I've overwritten save and delete methods to update number_of_comments. The only problem was in default delete action in admin interface because it doesn't use overwritten delete method from model so I've to write new one.
Cool. Very nice.
Please write a simple test for this that: 1. Creates a blog post, 2. Adds a few comments 3. Then checks that the number_of_comments fields is equal to the number of comments. 4. Then deletes one of the comments 5. Then checks the number_of_comments again. You can use test_watching.py as a template. Also, remove the prints like
print "NUM OF COM BEFORE " + str(self.content_object.number_of_comments) from film20/threadedcomments/models.py - they may cause problems on apache |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||