diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-06-07 01:12:40 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-06-07 01:12:40 -0400 |
commit | 84e1fc6f99879ede88f2d51df2b2730b5df6ff41 (patch) | |
tree | d06516ead1f2b23cf0ad2394a2bd7cd2871933ba /askbot/management | |
parent | 6bfe9a140475ecd6b2dea5364a347206f8e2370e (diff) | |
parent | 276eac48cc6ebeb4786eed34d13faa995321982d (diff) | |
download | askbot-84e1fc6f99879ede88f2d51df2b2730b5df6ff41.tar.gz askbot-84e1fc6f99879ede88f2d51df2b2730b5df6ff41.tar.bz2 askbot-84e1fc6f99879ede88f2d51df2b2730b5df6ff41.zip |
Merge branch 'master' into user-groups
Diffstat (limited to 'askbot/management')
-rw-r--r-- | askbot/management/commands/fix_answer_counts.py | 5 | ||||
-rw-r--r-- | askbot/management/commands/fix_question_tags.py | 30 | ||||
-rw-r--r-- | askbot/management/commands/fix_revisionless_posts.py | 7 |
3 files changed, 20 insertions, 22 deletions
diff --git a/askbot/management/commands/fix_answer_counts.py b/askbot/management/commands/fix_answer_counts.py index 959e37b6..9f22422e 100644 --- a/askbot/management/commands/fix_answer_counts.py +++ b/askbot/management/commands/fix_answer_counts.py @@ -23,6 +23,5 @@ class Command(NoArgsCommand): """function that handles the command job """ self.remove_save_signals() - questions = models.Question.objects.all() - for question in questions: - question.thread.update_answer_count() + for thread in models.Thread.objects.all(): + thread.update_answer_count() diff --git a/askbot/management/commands/fix_question_tags.py b/askbot/management/commands/fix_question_tags.py index 9858e397..d575e651 100644 --- a/askbot/management/commands/fix_question_tags.py +++ b/askbot/management/commands/fix_question_tags.py @@ -39,33 +39,33 @@ class Command(NoArgsCommand): transaction.commit() #go through questions and fix tag records on each - questions = models.Question.objects.all() + threads = models.Thread.objects.all() checked_count = 0 found_count = 0 - total_count = questions.count() + total_count = threads.count() print "Searching for questions with inconsistent tag records:", - for question in questions: - tags = question.thread.tags.all() - denorm_tag_set = set(question.get_tag_names()) - norm_tag_set = set(question.thread.tags.values_list('name', flat=True)) + for thread in threads: + tags = thread.tags.all() + denorm_tag_set = set(thread.get_tag_names()) + norm_tag_set = set(thread.tags.values_list('name', flat=True)) if norm_tag_set != denorm_tag_set: - if question.last_edited_by: - user = question.last_edited_by - timestamp = question.last_edited_at + if thread.last_edited_by: + user = thread.last_edited_by + timestamp = thread.last_edited_at else: - user = question.author - timestamp = question.added_at + user = thread.author + timestamp = thread.added_at - tagnames = forms.TagNamesField().clean(question.tagnames) + tagnames = forms.TagNamesField().clean(thread.tagnames) - question.thread.update_tags( + thread.update_tags( tagnames = tagnames, user = user, timestamp = timestamp ) - question.thread.tagnames = tagnames - question.thread.save() + thread.tagnames = tagnames + thread.save() found_count += 1 transaction.commit() diff --git a/askbot/management/commands/fix_revisionless_posts.py b/askbot/management/commands/fix_revisionless_posts.py index 92c03425..9535bef3 100644 --- a/askbot/management/commands/fix_revisionless_posts.py +++ b/askbot/management/commands/fix_revisionless_posts.py @@ -7,11 +7,11 @@ from django.db.models import signals, Count from askbot import models from askbot import const -def fix_revisionless_posts(post_class, post_name): +def fix_revisionless_posts(post_class): posts = post_class.objects.annotate( rev_count = Count('revisions') ).filter(rev_count = 0) - print 'have %d corrupted %ss' % (len(posts), post_name) + print 'have %d corrupted posts' % len(posts) for post in posts: post.add_revision( author = post.author, @@ -39,5 +39,4 @@ class Command(NoArgsCommand): """function that handles the command job """ self.remove_save_signals() - fix_revisionless_posts(models.Question, 'question') - fix_revisionless_posts(models.Answer, 'answer') + fix_revisionless_posts(models.Post) |