From d13e606ee18e91f0d87d6b7cb707535e28dd4bc0 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Thu, 15 Mar 2012 14:00:44 -0700 Subject: [PATCH] Completing tryfeed for social subscriptions. Can now follow social feeds you don't already follow from the feed itself. --- apps/social/views.py | 12 ++++++++---- media/js/newsblur/common/assetmodel.js | 7 +++---- media/js/newsblur/reader/reader.js | 12 ++++++++---- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/apps/social/views.py b/apps/social/views.py index bccaf19fc..a340ab154 100644 --- a/apps/social/views.py +++ b/apps/social/views.py @@ -167,13 +167,17 @@ def load_social_page(request, user_id, username=None): @json.json_view def story_comments(request): - feed_id = int(request.POST['feed_id']) - story_id = request.POST['story_id'] + feed_id = int(request.REQUEST['feed_id']) + story_id = request.REQUEST['story_id'] - shared_stories = MSharedStory.objects.filter(story_feed_id=feed_id, story_guid=story_id) + shared_stories = MSharedStory.objects.filter(story_feed_id=feed_id, story_guid=story_id, has_comments=True) comments = [s.comments_with_author() for s in shared_stories] + + profile_user_ids = [c['user_id'] for c in comments] + profiles = MSocialProfile.objects.filter(user_id__in=list(profile_user_ids)) + profiles = [profile.to_json(compact=True) for profile in profiles] - return {'comments': comments} + return {'comments': comments, 'profiles': profiles} @ajax_login_required @json.json_view diff --git a/media/js/newsblur/common/assetmodel.js b/media/js/newsblur/common/assetmodel.js index 8988b34bf..fd799b4c5 100644 --- a/media/js/newsblur/common/assetmodel.js +++ b/media/js/newsblur/common/assetmodel.js @@ -672,7 +672,7 @@ NEWSBLUR.AssetModel.Reader.prototype = { }, add_social_feed: function(feed) { - var social_feed = this.social_feeds.get(feed.get('user_id')); + var social_feed = this.social_feeds.get(feed); if (!social_feed) { social_feed = new NEWSBLUR.Models.SocialSubscription(feed.attributes); this.social_feeds.add(social_feed); @@ -1114,9 +1114,8 @@ NEWSBLUR.AssetModel.Reader.prototype = { load_public_story_comments: function(story_id, feed_id, callback) { this.make_request('/social/comments', { 'story_id': story_id, - 'feed_id': feed_id, - 'compact': true - }, callback); + 'feed_id': feed_id + }, callback, callback, {request_type: 'GET'}); }, recalculate_story_scores: function(feed_id) { diff --git a/media/js/newsblur/reader/reader.js b/media/js/newsblur/reader/reader.js index 844f4a990..e71d7f8ed 100644 --- a/media/js/newsblur/reader/reader.js +++ b/media/js/newsblur/reader/reader.js @@ -1125,7 +1125,7 @@ }, this)); }, - make_social_feeds: function() { + make_social_feeds: function(callback) { var $social_feeds = this.$s.$social_feeds; $social_feeds.empty(); @@ -1142,7 +1142,8 @@ }); $social_feeds.html($feeds); $social_feeds.animate({'opacity': 1}, {'duration': 700}); - + + callback && callback(); }, load_router: function() { @@ -6463,9 +6464,12 @@ }, follow_user_in_tryfeed: function(feed_id) { + var self = this; var socialsub = this.model.get_feed(feed_id); - this.model.follow_user(socialsub.get('user_id'), function(data) { - NEWSBLUR.reader.make_social_feeds(); + this.model.follow_user(socialsub.user_id, function(data) { + NEWSBLUR.reader.make_social_feeds(function() { + self.open_social_stories(feed_id); + }); }); },