diff options
Diffstat (limited to 'forum')
-rw-r--r-- | forum/doc/INSTALL | 3 | ||||
-rw-r--r-- | forum/models/answer.py | 8 | ||||
-rw-r--r-- | forum/models/base.py | 11 | ||||
-rw-r--r-- | forum/models/content.py | 9 | ||||
-rw-r--r-- | forum/models/meta.py | 10 | ||||
-rw-r--r-- | forum/models/question.py | 9 | ||||
-rw-r--r-- | forum/tests.py | 6 |
7 files changed, 26 insertions, 30 deletions
diff --git a/forum/doc/INSTALL b/forum/doc/INSTALL index f1d1e498..55b8614d 100644 --- a/forum/doc/INSTALL +++ b/forum/doc/INSTALL @@ -52,11 +52,12 @@ http://github.com/dcramer/django-sphinx/tree/master/djangosphinx 8. sphinx search engine (optional, works together with djangosphinx) http://sphinxsearch.com/downloads.html -9. recaptcha_django +9. recaptcha_django (installed through svn) http://code.google.com/p/recaptcha-django/ 10. python recaptcha module http://code.google.com/p/recaptcha/ +easy_install recaptcha-client Notice that you will need to register with recaptcha.net and receive recaptcha public and private keys that need to be saved in your settings_local.py file diff --git a/forum/models/answer.py b/forum/models/answer.py index b4e8963e..e8ff2e50 100644 --- a/forum/models/answer.py +++ b/forum/models/answer.py @@ -5,7 +5,7 @@ from django.template.defaultfilters import slugify from django.core.urlresolvers import reverse from forum.models.base import AnonymousContent, DeletableContent from forum.models.base import ContentRevision -from forum.models.base import save_post, parse_post_text +from forum.models.base import parse_post_text, parse_and_save_post from forum.models import content from forum.models.question import Question from forum import const @@ -26,7 +26,7 @@ class AnswerManager(models.Manager): answer.last_edited_at = added_at answer.wikified_at = added_at - answer.save() + answer.parse_and_save() answer.add_revision( revised_by = author, @@ -91,8 +91,8 @@ class Answer(content.Content, DeletableContent): class Meta(content.Content.Meta): db_table = u'answer' - save = save_post parse = parse_post_text + parse_and_save = parse_and_save_post def get_updated_activity_data(self, created = False): #todo: simplify this to always return latest revision for the second @@ -117,7 +117,7 @@ class Answer(content.Content, DeletableContent): #self.html is denormalized in save() self.text = text #todo: bug wiki has no effect here - self.save() + self.parse_and_save() self.add_revision( revised_by=edited_by, diff --git a/forum/models/base.py b/forum/models/base.py index d832b71c..29d4fff3 100644 --- a/forum/models/base.py +++ b/forum/models/base.py @@ -4,7 +4,6 @@ from django.utils.html import strip_tags from django.contrib.auth.models import User from django.contrib.contenttypes import generic from django.contrib.contenttypes.models import ContentType -from django.contrib.sitemaps import ping_google #todo: maybe merge forum.utils.markup and forum.utils.html from forum.utils import markup from forum.utils.html import sanitize_html @@ -98,8 +97,9 @@ def parse_post_text(post): } return data -def save_post(post, **kwargs): - """generic save method to use with posts +def parse_and_save_post(post, **kwargs): + """generic method to use with posts to be used prior to saving + post edit or addition """ data = post.parse() @@ -123,6 +123,9 @@ def save_post(post, **kwargs): super(post.__class__, post).save(**kwargs) last_author = post.get_last_author() + + last_author = post.get_last_author() + #create new mentions for u in newly_mentioned_users: from forum.models.user import Activity @@ -148,7 +151,7 @@ def save_post(post, **kwargs): try: ping_google() except Exception: - logging.debug('problem pinging google did you register the sitemap with google?') + logging.debug('cannot ping google - did you register with them?') class UserContent(models.Model): user = models.ForeignKey(User, related_name='%(class)ss') diff --git a/forum/models/content.py b/forum/models/content.py index eb2b423e..ec7f26b8 100644 --- a/forum/models/content.py +++ b/forum/models/content.py @@ -44,13 +44,6 @@ class Content(models.Model): abstract = True app_label = 'forum' - def save(self,**kwargs): - super(Content,self).save(**kwargs) - try: - ping_google() - except Exception: - logging.debug('problem pinging google did you register you sitemap with google?') - def get_comments(self): comments = self.comments.all().order_by('id') return comments @@ -72,7 +65,7 @@ class Content(models.Model): user=user, added_at=added_at ) - comment.save() + comment.parse_and_save() self.comment_count = self.comment_count + 1 self.save() return comment diff --git a/forum/models/meta.py b/forum/models/meta.py index ee0d92ae..59becc24 100644 --- a/forum/models/meta.py +++ b/forum/models/meta.py @@ -89,6 +89,10 @@ class Comment(base.MetaContent, base.UserContent): ordering = ('-added_at',) db_table = u'comment' + #these two are methods + parse = base.parse_post_text + parse_and_save = base.parse_and_save_post + def get_origin_post(self): return self.content_object.get_origin_post() @@ -99,12 +103,6 @@ class Comment(base.MetaContent, base.UserContent): def set_text(self, text): self.comment = text - def parse(self): - return base.parse_post_text(self) - - def save(self,**kwargs): - base.save_post(self) - def get_updated_activity_data(self, created = False): if self.content_object.__class__.__name__ == 'Question': return const.TYPE_ACTIVITY_COMMENT_QUESTION, self diff --git a/forum/models/question.py b/forum/models/question.py index c6c16578..8e137e2e 100644 --- a/forum/models/question.py +++ b/forum/models/question.py @@ -12,7 +12,7 @@ from django.utils.translation import ugettext as _ from forum.models.tag import Tag, MarkedTag from forum.models import signals from forum.models.base import AnonymousContent, DeletableContent, ContentRevision -from forum.models.base import save_post, parse_post_text +from forum.models.base import parse_post_text, parse_and_save_post from forum.models import content from forum import const from forum.utils.lists import LazyList @@ -54,7 +54,7 @@ class QuestionManager(models.Manager): question.last_edited_at = added_at question.wikified_at = added_at - question.save() + question.parse_and_save() question.add_revision( author=author, @@ -319,6 +319,7 @@ class Question(content.Content, DeletableContent): db_table = u'question' parse = parse_post_text + parse_and_save = parse_and_save_post def delete(self): super(Question, self).delete() @@ -421,7 +422,7 @@ class Question(content.Content, DeletableContent): if self.wiki == False and wiki == True: self.wiki = True - self.save() + self.parse_and_save() # Update the Question tag associations if latest_revision.tagnames != tags: @@ -466,7 +467,7 @@ class Question(content.Content, DeletableContent): """ initial_addition = (self.pk is None) - save_post(self, **kwargs) + super(Question, self).save(**kwargs) if initial_addition: tags = Tag.objects.get_or_create_multiple( diff --git a/forum/tests.py b/forum/tests.py index c2e1765f..d93e7d4e 100644 --- a/forum/tests.py +++ b/forum/tests.py @@ -204,12 +204,12 @@ class UpdateNotificationTests(TestCase): ) def test_comments_to_post_authors(self): - self.reset_response_counts() self.question.apply_edit( edited_by = self.u14, text = 'now much better', comment = 'improved text' ) + self.reset_response_counts() time.sleep(1) timestamp = datetime.datetime.now() self.question.add_comment( @@ -250,7 +250,7 @@ class UpdateNotificationTests(TestCase): text = 'now much better', comment = 'improved text' ) - self.reset_repsonse_counters() + self.reset_response_counts() time.sleep(1) timestamp = datetime.datetime.now() self.answer1.add_comment( @@ -360,7 +360,7 @@ class UpdateNotificationTests(TestCase): ], [ 1, 1, 1, 1, - 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, ] ) |