diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-03-06 21:29:19 -0300 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-03-06 21:29:19 -0300 |
commit | aee6fa767e4475d6c3d2293ce48683b2f61397f6 (patch) | |
tree | 6a446f4448c7e7ada88f1ed10dabd881aa8e610a | |
parent | 408153397de074b7fc7f13e14468559016877160 (diff) | |
download | askbot-aee6fa767e4475d6c3d2293ce48683b2f61397f6.tar.gz askbot-aee6fa767e4475d6c3d2293ce48683b2f61397f6.tar.bz2 askbot-aee6fa767e4475d6c3d2293ce48683b2f61397f6.zip |
added management command delete_contextless_activities
-rw-r--r-- | askbot/doc/source/changelog.rst | 1 | ||||
-rw-r--r-- | askbot/doc/source/management-commands.rst | 4 | ||||
-rw-r--r-- | askbot/management/commands/delete_contextless_activities.py | 18 |
3 files changed, 23 insertions, 0 deletions
diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index b6880d37..a8e695a6 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -19,6 +19,7 @@ Development version (not released yet) * Fixed a file upload issue in FF and IE found by jerry_gzy (Evgeny) * Added test on maximum length of title working for utf-8 text (Evgeny) * Added caching and invalidation to the question page (Evgeny) +* Added a management command delete_contextless_activities (Evgeny) 0.7.39 (Jan 11, 2012) --------------------- diff --git a/askbot/doc/source/management-commands.rst b/askbot/doc/source/management-commands.rst index b857d6f0..f6c5beec 100644 --- a/askbot/doc/source/management-commands.rst +++ b/askbot/doc/source/management-commands.rst @@ -84,6 +84,10 @@ The bulk of the management commands fall into this group and will probably be th | | Deletes Activity objects of type badge award where the | | | related context object is lost. | +---------------------------------+-------------------------------------------------------------+ +| `delete_contextless_activities` | Same as above, but works in a broader sense - when the | +| | related context object does not exist, but the generic | +| | foreign key to that object is still present. | ++---------------------------------+-------------------------------------------------------------+ .. _email-related-commands: diff --git a/askbot/management/commands/delete_contextless_activities.py b/askbot/management/commands/delete_contextless_activities.py new file mode 100644 index 00000000..e16a9957 --- /dev/null +++ b/askbot/management/commands/delete_contextless_activities.py @@ -0,0 +1,18 @@ +from django.core.management.base import NoArgsCommand +from askbot.utils.console import ProgressBar +from askbot.models import Activity +from askbot import const + +class Command(NoArgsCommand): + def handle_noargs(self, **options): + acts = Activity.objects.all() + deleted_count = 0 + message = "Searching for context-less activity objects:" + for act in ProgressBar(acts.iterator(), acts.count(), message): + if act.object_id != None and act.content_object == None: + act.delete() + deleted_count += 1 + if deleted_count: + print "%d activity objects deleted" % deleted_count + else: + print "None found" |