Permalink
Browse files

Preventing dupe favorites from showing up in activities and interacti…

…ons.
  • Loading branch information...
1 parent dffdfa7 commit ff439834c564dadec4012db0ed11a880d9b90543 @samuelclay committed Jul 28, 2012
Showing with 28 additions and 20 deletions.
  1. +18 −20 apps/social/models.py
  2. +1 −0 settings.py
  3. +9 −0 utils/request_introspection_middleware.py
View
@@ -1967,16 +1967,15 @@ def new_comment_reply(cls, user_id, reply_user_id, reply_content, social_feed_id
@classmethod
def new_comment_like(cls, liking_user_id, comment_user_id, social_feed_id, story_id, story_title, comments):
- params = {
- 'user_id': comment_user_id,
- 'with_user_id': liking_user_id,
- 'category': 'comment_like',
- 'feed_id': social_feed_id,
- 'content_id': story_id,
- 'title': story_title,
- 'content': comments,
- }
- cls.objects.create(**params)
+ cls.objects.get_or_create(user_id=comment_user_id,
+ with_user_id=liking_user_id,
+ category="comment_like",
+ feed_id=social_feed_id,
+ content_id=story_id,
+ defaults={
+ "title": story_title,
+ "content": comments,
+ })
@classmethod
def new_reply_reply(cls, user_id, reply_user_id, reply_content, social_feed_id, story_id, story_title=None, original_message=None):
@@ -2146,16 +2145,15 @@ def new_comment_reply(cls, user_id, comment_user_id, reply_content, story_feed_i
@classmethod
def new_comment_like(cls, liking_user_id, comment_user_id, social_feed_id, story_id, story_title, comments):
- params = {
- 'user_id': comment_user_id,
- 'with_user_id': liking_user_id,
- 'category': 'comment_like',
- 'feed_id': social_feed_id,
- 'content_id': story_id,
- 'title': story_title,
- 'content': comments,
- }
- cls.objects.create(**params)
+ cls.objects.get_or_create(user_id=comment_user_id,
+ with_user_id=liking_user_id,
+ category="comment_like",
+ feed_id=social_feed_id,
+ content_id=story_id,
+ defaults={
+ "title": story_title,
+ "content": comments,
+ })
@classmethod
def new_shared_story(cls, user_id, story_title, comments, story_feed_id, story_id, share_date=None):
View
@@ -436,4 +436,5 @@ def custom_show_toolbar(request):
if DEBUG:
MIDDLEWARE_CLASSES += ('utils.mongo_raw_log_middleware.SqldumpMiddleware',)
MIDDLEWARE_CLASSES += ('utils.redis_raw_log_middleware.SqldumpMiddleware',)
+ MIDDLEWARE_CLASSES += ('utils.request_introspection_middleware.DumpRequestMiddleware',)
@@ -0,0 +1,9 @@
+from django.conf import settings
+from utils import log as logging
+
+class DumpRequestMiddleware:
+ def process_request(self, request):
+ if settings.DEBUG:
+ request_items = request.REQUEST.items()
+ if request_items:
+ logging.debug("~BC~FK%s" % dict(request_items))

0 comments on commit ff43983

Please sign in to comment.