summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-03-06 23:07:21 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-03-06 23:07:21 -0300
commit58dbf1ada7aefd67dd27ff0229e376d9fff39688 (patch)
treedbd45ff46f7a84ec7bc6aa2eee27efb396dd88ed
parent7879741f10be3292b9fb76f3029535910941dbbc (diff)
downloadaskbot-58dbf1ada7aefd67dd27ff0229e376d9fff39688.tar.gz
askbot-58dbf1ada7aefd67dd27ff0229e376d9fff39688.tar.bz2
askbot-58dbf1ada7aefd67dd27ff0229e376d9fff39688.zip
delete activity with the stale content_type of the related content object
-rw-r--r--askbot/management/commands/delete_contextless_activities.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/askbot/management/commands/delete_contextless_activities.py b/askbot/management/commands/delete_contextless_activities.py
index e16a9957..553217bf 100644
--- a/askbot/management/commands/delete_contextless_activities.py
+++ b/askbot/management/commands/delete_contextless_activities.py
@@ -9,9 +9,14 @@ class Command(NoArgsCommand):
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:
+ try:
+ if act.object_id != None and act.content_object == None:
+ act.delete()
+ deleted_count += 1
+ except:
+ #this can happen if we have a stale content type
act.delete()
- deleted_count += 1
+
if deleted_count:
print "%d activity objects deleted" % deleted_count
else: