summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-03-11 17:48:25 -0500
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-03-11 17:48:37 -0500
commit1e1877f8a0e6d90a90a1c8ab2b5b758635c5a993 (patch)
tree0c2b9915627b7f326e3f582cf30abb528afa1dba
parentab56197683103df302dab889a432eb65595743af (diff)
downloadaskbot-1e1877f8a0e6d90a90a1c8ab2b5b758635c5a993.tar.gz
askbot-1e1877f8a0e6d90a90a1c8ab2b5b758635c5a993.tar.bz2
askbot-1e1877f8a0e6d90a90a1c8ab2b5b758635c5a993.zip
fixed a problem of badges that are assigned to deleted content
-rw-r--r--askbot/models/post.py6
-rw-r--r--askbot/views/users.py12
2 files changed, 13 insertions, 5 deletions
diff --git a/askbot/models/post.py b/askbot/models/post.py
index d9cd9a5e..2b78e7a1 100644
--- a/askbot/models/post.py
+++ b/askbot/models/post.py
@@ -486,8 +486,8 @@ class Post(models.Model):
if self.is_comment():
#todo: implement a custom delete method on these
#all this should pack into Activity.responses.filter( somehow ).delete()
- activity_types = const.RESPONSE_ACTIVITY_TYPES_FOR_DISPLAY
- activity_types += (const.TYPE_ACTIVITY_MENTION,)
+ #activity_types = const.RESPONSE_ACTIVITY_TYPES_FOR_DISPLAY
+ #activity_types += (const.TYPE_ACTIVITY_MENTION,)
#todo: not very good import in models of other models
#todo: potentially a circular import
from askbot.models.user import Activity
@@ -495,7 +495,7 @@ class Post(models.Model):
activities = Activity.objects.filter(
content_type = comment_content_type,
object_id = self.id,
- activity_type__in = activity_types
+ #activity_type__in = activity_types
)
recipients = set()
diff --git a/askbot/views/users.py b/askbot/views/users.py
index 154df7d8..c625aeab 100644
--- a/askbot/views/users.py
+++ b/askbot/views/users.py
@@ -354,8 +354,16 @@ def user_stats(request, user, context):
for award in user_awards:
# Fetch content object
if award.content_type_id == post_type.id:
- award.content_object = awarded_posts_map[award.object_id]
- award.content_object_is_post = True
+ #here we go around a possibility of awards
+ #losing the content objects when the content
+ #objects are deleted for some reason
+ awarded_post = awarded_posts_map.get(award.object_id, None)
+ if awarded_post is not None:
+ #protect from awards that are associated with deleted posts
+ award.content_object = awarded_post
+ award.content_object_is_post = True
+ else:
+ award.content_object_is_post = False
else:
award.content_object_is_post = False