Completing tryfeed for social subscriptions. Can now follow social feeds you don't already follow from the feed itself.

This commit is contained in:
Samuel Clay 2012-03-15 14:00:44 -07:00
parent b4acea734b
commit d13e606ee1
3 changed files with 19 additions and 12 deletions

View file

@ -167,13 +167,17 @@ def load_social_page(request, user_id, username=None):
@json.json_view @json.json_view
def story_comments(request): def story_comments(request):
feed_id = int(request.POST['feed_id']) feed_id = int(request.REQUEST['feed_id'])
story_id = request.POST['story_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] 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 @ajax_login_required
@json.json_view @json.json_view

View file

@ -672,7 +672,7 @@ NEWSBLUR.AssetModel.Reader.prototype = {
}, },
add_social_feed: function(feed) { 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) { if (!social_feed) {
social_feed = new NEWSBLUR.Models.SocialSubscription(feed.attributes); social_feed = new NEWSBLUR.Models.SocialSubscription(feed.attributes);
this.social_feeds.add(social_feed); this.social_feeds.add(social_feed);
@ -1114,9 +1114,8 @@ NEWSBLUR.AssetModel.Reader.prototype = {
load_public_story_comments: function(story_id, feed_id, callback) { load_public_story_comments: function(story_id, feed_id, callback) {
this.make_request('/social/comments', { this.make_request('/social/comments', {
'story_id': story_id, 'story_id': story_id,
'feed_id': feed_id, 'feed_id': feed_id
'compact': true }, callback, callback, {request_type: 'GET'});
}, callback);
}, },
recalculate_story_scores: function(feed_id) { recalculate_story_scores: function(feed_id) {

View file

@ -1125,7 +1125,7 @@
}, this)); }, this));
}, },
make_social_feeds: function() { make_social_feeds: function(callback) {
var $social_feeds = this.$s.$social_feeds; var $social_feeds = this.$s.$social_feeds;
$social_feeds.empty(); $social_feeds.empty();
@ -1142,7 +1142,8 @@
}); });
$social_feeds.html($feeds); $social_feeds.html($feeds);
$social_feeds.animate({'opacity': 1}, {'duration': 700}); $social_feeds.animate({'opacity': 1}, {'duration': 700});
callback && callback();
}, },
load_router: function() { load_router: function() {
@ -6463,9 +6464,12 @@
}, },
follow_user_in_tryfeed: function(feed_id) { follow_user_in_tryfeed: function(feed_id) {
var self = this;
var socialsub = this.model.get_feed(feed_id); var socialsub = this.model.get_feed(feed_id);
this.model.follow_user(socialsub.get('user_id'), function(data) { this.model.follow_user(socialsub.user_id, function(data) {
NEWSBLUR.reader.make_social_feeds(); NEWSBLUR.reader.make_social_feeds(function() {
self.open_social_stories(feed_id);
});
}); });
}, },