Fixing bugs around follow information.

This commit is contained in:
Samuel Clay 2012-07-13 15:32:27 -07:00
parent cdf42f323e
commit 8d8514080f
6 changed files with 33 additions and 14 deletions

View file

@ -298,7 +298,8 @@ class MSocialProfile(mongo.Document):
domain = Site.objects.get_current().domain.replace('www', 'dev')
return 'http://' + domain + settings.MEDIA_URL + 'img/reader/default_profile_photo.png'
def to_json(self, compact=False, include_follows=False, common_follows_with_user=None, include_settings=False):
def to_json(self, compact=False, include_follows=False, common_follows_with_user=None,
include_settings=False, include_following_user=None):
# domain = Site.objects.get_current().domain
domain = Site.objects.get_current().domain.replace('www', 'dev')
params = {
@ -343,7 +344,11 @@ class MSocialProfile(mongo.Document):
params['followers_everybody'] = followers_everybody[:48]
params['following_youknow'] = following_youknow[:48]
params['following_everybody'] = following_everybody[:48]
params['following'] = self.is_followed_by_user(common_follows_with_user)
if include_following_user or common_follows_with_user:
if not include_following_user:
include_following_user = common_follows_with_user
params['followed_by_you'] = self.is_followed_by_user(include_following_user)
params['following_you'] = self.is_following_user(include_following_user)
return params

View file

@ -519,7 +519,6 @@ def shared_stories_public(request, username):
@json.json_view
def profile(request):
time.sleep(1)
user = get_user(request.user)
user_id = request.GET.get('user_id', user.pk)
include_activities_html = request.REQUEST.get('include_activities_html', None)
@ -603,11 +602,19 @@ def save_blurblog_settings(request):
@json.json_view
def load_user_friends(request):
user = get_user(request.user)
social_profile, _ = MSocialProfile.objects.get_or_create(user_id=user.pk)
social_profile, _ = MSocialProfile.objects.get_or_create(user_id=user.pk)
social_services, _ = MSocialServices.objects.get_or_create(user_id=user.pk)
following_profiles = MSocialProfile.profiles(social_profile.following_user_ids)
follower_profiles = MSocialProfile.profiles(social_profile.follower_user_ids)
recommended_users = social_profile.recommended_users()
follower_profiles = MSocialProfile.profiles(social_profile.follower_user_ids)
recommended_users = social_profile.recommended_users()
following_profiles = [p.to_json(include_following_user=user.pk) for p in following_profiles]
follower_profiles = [p.to_json(include_following_user=user.pk) for p in follower_profiles]
logging.user(request, "~BB~FRLoading Friends (%s following, %s followers)" % (
social_profile.following_count,
social_profile.follower_count,
))
return {
'services': social_services,

View file

@ -96,19 +96,18 @@ _.extend(NEWSBLUR.ReaderFriends.prototype, {
make_find_friends_and_services: function() {
$('.NB-modal-loading', this.$modal).removeClass('NB-active');
var $services = $('.NB-friends-services', this.$modal).empty();
var service_syncing = false;
_.each(['twitter', 'facebook'], _.bind(function(service) {
var $service;
if (this.services && this.services[service][service+'_uid']) {
var syncing = this.services[service].syncing;
if (syncing) service_syncing = true;
$service = $.make('div', { className: 'NB-friends-service NB-connected NB-friends-service-'+service + (this.services[service].syncing ? ' NB-friends-service-syncing' : '') }, [
$.make('div', { className: 'NB-friends-service-title' }, _.string.capitalize(service)),
$.make('div', { className: 'NB-friends-service-connect NB-modal-submit-button NB-modal-submit-grey' }, syncing ? 'Fetching...' : 'Disconnect')
]);
if (syncing) {
_.delay(_.bind(this.check_services_sync_status, this), 3000);
}
} else {
$service = $.make('div', { className: 'NB-friends-service NB-friends-service-'+service }, [
$.make('div', { className: 'NB-friends-service-title' }, _.string.capitalize(service)),
@ -151,6 +150,10 @@ _.extend(NEWSBLUR.ReaderFriends.prototype, {
var $ghost = $.make('div', { className: 'NB-ghost' }, 'Nobody left to recommend. Good job!');
$findlist.append($ghost);
}
if (service_syncing) {
_.delay(_.bind(this.check_services_sync_status, this), 3000);
}
},
make_profile_section: function() {

View file

@ -179,6 +179,7 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
make_find_friends_and_services: function() {
$('.NB-modal-loading', this.$modal).removeClass('NB-active');
var $services = $('.NB-intro-services', this.$modal).empty();
var service_syncing = false;
_.each(['twitter', 'facebook'], _.bind(function(service) {
var $service;
@ -193,6 +194,8 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
} else {
var syncing = this.services && this.services[service] && this.services[service].syncing;
if (syncing) service_syncing = true;
$service = $.make('div', { className: 'NB-friends-service NB-friends-service-'+service + (syncing ? ' NB-friends-service-syncing' : '') }, [
$.make('div', { className: 'NB-friends-service-title' }, _.string.capitalize(service)),
$.make('div', { className: 'NB-friends-service-connect NB-modal-submit-button ' + (syncing ? 'NB-modal-submit-grey' : 'NB-modal-submit-green') }, [
@ -200,9 +203,6 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
(syncing ? 'Fetching...' : 'Find ' + _.string.capitalize(service) + ' Friends')
])
]);
if (syncing) {
_.delay(_.bind(this.fetch_friends, this), 3000);
}
}
$services.append($service);
}, this));
@ -233,6 +233,10 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
$services.append($stats);
$('.NB-tutorial-next-page-text', this.$modal).text('Next step ');
}
if (service_syncing) {
_.delay(_.bind(this.fetch_friends, this), 3000);
}
},
connect: function(service) {

View file

@ -72,7 +72,7 @@ NEWSBLUR.Views.SocialProfileBadge = Backbone.View.extend({
(!profile.get('shared_stories_count') ? 'NB-disabled' : '')
}, 'Edit Profile'))
]);
} else if (profile.get('following')) {
} else if (profile.get('followed_by_you')) {
$actions = $.make('div', {
className: 'NB-profile-badge-action-unfollow NB-profile-badge-action-buttons NB-modal-submit-button NB-modal-submit-grey'
}, 'Following');

View file

@ -54,7 +54,7 @@ def user(u, msg):
time_elapsed = "[%.4ss] " % (now - request.start_time)
premium = '*' if u.is_authenticated() and u.profile.is_premium else ''
username = cipher(unicode(u)) if settings.CIPHER_USERNAMES else u
info(' ---> [~FB~SN%-6s~SB] [%s%s] %s%s' % (platform, time_elapsed, username, premium, msg))
info(' ---> [~FB~SN%-6s~SB] %s[%s%s] %s' % (platform, time_elapsed, username, premium, msg))
def cipher(msg):
shift = len(msg)