resolve conficts in merge from master

pull/1/head
eric 2013-03-29 12:03:15 -04:00
commit 097127ab7c
24 changed files with 413 additions and 120 deletions

54
core/auth.py Normal file
View File

@ -0,0 +1,54 @@
import logging
from social_auth.backends.pipeline.social import social_auth_user, load_extra_data
from social_auth.models import UserSocialAuth
from regluit.core.models import TWITTER, FACEBOOK
logger = logging.getLogger(__name__)
def selectively_associate(backend, uid, user=None, *args, **kwargs):
"""Not using Facebook or Twitter to authenticate a user.
"""
social_user = UserSocialAuth.get_social_auth(backend.name, uid)
if backend.name in ('twitter', 'facebook'):
# not for authentication
return {'social_user': social_user}
return social_auth_user(backend, uid, user=None, *args, **kwargs)
def facebook_extra_values( user, extra_data):
try:
facebook_id = extra_data.get('id')
user.profile.facebook_id = facebook_id
if user.profile.avatar_source is None:
user.profile.avatar_source = FACEBOOK
user.profile.save()
return True
except Exception,e:
logger.error(e)
return False
def twitter_extra_values( user, extra_data):
try:
twitter_id = extra_data.get('screen_name')
profile_image_url = extra_data.get('profile_image_url_https')
user.profile.twitter_id = twitter_id
if user.profile.avatar_source is None or user.profile.avatar_source is TWITTER:
user.profile.pic_url = profile_image_url
if user.profile.avatar_source is None:
user.profile.avatar_source = TWITTER
user.profile.save()
return True
except Exception,e:
logger.error(e)
return False
def deliver_extra_data(backend, details, response, uid, user, social_user=None,
*args, **kwargs):
pipeline_data = load_extra_data(backend, details, response, uid, user, social_user=None,
*args, **kwargs)
if backend.name is 'twitter':
twitter_extra_values( user, social_user.extra_data)
if backend.name is 'facebook':
facebook_extra_values( user, social_user.extra_data)

View File

@ -0,0 +1,235 @@
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'UserProfile.avatar_source'
db.add_column('core_userprofile', 'avatar_source',
self.gf('django.db.models.fields.PositiveSmallIntegerField')(null=True),
keep_default=False)
def backwards(self, orm):
# Deleting field 'UserProfile.avatar_source'
db.delete_column('core_userprofile', 'avatar_source')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'core.author': {
'Meta': {'object_name': 'Author'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'editions': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'authors'", 'symmetrical': 'False', 'to': "orm['core.Edition']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '500'})
},
'core.badge': {
'Meta': {'object_name': 'Badge'},
'description': ('django.db.models.fields.TextField', [], {'default': "''", 'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '72', 'blank': 'True'})
},
'core.campaign': {
'Meta': {'object_name': 'Campaign'},
'activated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'amazon_receiver': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'deadline': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}),
'description': ('ckeditor.fields.RichTextField', [], {'null': 'True'}),
'details': ('ckeditor.fields.RichTextField', [], {'null': 'True', 'blank': 'True'}),
'edition': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'campaigns'", 'null': 'True', 'to': "orm['core.Edition']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'left': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '14', 'decimal_places': '2'}),
'license': ('django.db.models.fields.CharField', [], {'default': "'CC BY-NC-ND'", 'max_length': '255'}),
'managers': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'campaigns'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True'}),
'paypal_receiver': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'status': ('django.db.models.fields.CharField', [], {'default': "'INITIALIZED'", 'max_length': '15', 'null': 'True'}),
'target': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '14', 'decimal_places': '2'}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'campaigns'", 'to': "orm['core.Work']"})
},
'core.campaignaction': {
'Meta': {'object_name': 'CampaignAction'},
'campaign': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actions'", 'to': "orm['core.Campaign']"}),
'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'timestamp': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '15'})
},
'core.celerytask': {
'Meta': {'object_name': 'CeleryTask'},
'active': ('django.db.models.fields.NullBooleanField', [], {'default': 'True', 'null': 'True', 'blank': 'True'}),
'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2013, 3, 14, 0, 0)', 'auto_now_add': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True'}),
'function_args': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
'function_name': ('django.db.models.fields.CharField', [], {'max_length': '1024'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'task_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tasks'", 'null': 'True', 'to': "orm['auth.User']"})
},
'core.claim': {
'Meta': {'object_name': 'Claim'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'rights_holder': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'claim'", 'to': "orm['core.RightsHolder']"}),
'status': ('django.db.models.fields.CharField', [], {'default': "'pending'", 'max_length': '7'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'claim'", 'to': "orm['auth.User']"}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'claim'", 'to': "orm['core.Work']"})
},
'core.ebook': {
'Meta': {'object_name': 'Ebook'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'edition': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'ebooks'", 'to': "orm['core.Edition']"}),
'format': ('django.db.models.fields.CharField', [], {'max_length': '25'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'provider': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'rights': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'db_index': 'True'}),
'url': ('django.db.models.fields.URLField', [], {'max_length': '1024'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'})
},
'core.edition': {
'Meta': {'object_name': 'Edition'},
'cover_image': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'public_domain': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
'publication_date': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
'publisher': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'null': 'True', 'blank': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}),
'unglued': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'editions'", 'null': 'True', 'to': "orm['core.Work']"})
},
'core.identifier': {
'Meta': {'unique_together': "(('type', 'value'),)", 'object_name': 'Identifier'},
'edition': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'identifiers'", 'null': 'True', 'to': "orm['core.Edition']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '4'}),
'value': ('django.db.models.fields.CharField', [], {'max_length': '31'}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'identifiers'", 'to': "orm['core.Work']"})
},
'core.key': {
'Meta': {'object_name': 'Key'},
'encrypted_value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
},
'core.premium': {
'Meta': {'object_name': 'Premium'},
'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '0'}),
'campaign': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'premiums'", 'null': 'True', 'to': "orm['core.Campaign']"}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'limit': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '2'})
},
'core.rightsholder': {
'Meta': {'object_name': 'RightsHolder'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'email': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'rights_holder'", 'to': "orm['auth.User']"}),
'rights_holder_name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'core.subject': {
'Meta': {'ordering': "['name']", 'object_name': 'Subject'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '200'}),
'works': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'subjects'", 'symmetrical': 'False', 'to': "orm['core.Work']"})
},
'core.userprofile': {
'Meta': {'object_name': 'UserProfile'},
'avatar_source': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
'badges': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'holders'", 'symmetrical': 'False', 'to': "orm['core.Badge']"}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'facebook_id': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
'goodreads_auth_secret': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'goodreads_auth_token': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'goodreads_user_id': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
'goodreads_user_link': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'goodreads_user_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'home_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'librarything_id': ('django.db.models.fields.CharField', [], {'max_length': '31', 'blank': 'True'}),
'pic_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
'tagline': ('django.db.models.fields.CharField', [], {'max_length': '140', 'blank': 'True'}),
'twitter_id': ('django.db.models.fields.CharField', [], {'max_length': '15', 'blank': 'True'}),
'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': "orm['auth.User']"})
},
'core.waswork': {
'Meta': {'object_name': 'WasWork'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'moved': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
'was': ('django.db.models.fields.IntegerField', [], {'unique': 'True'}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Work']"})
},
'core.wishes': {
'Meta': {'object_name': 'Wishes', 'db_table': "'core_wishlist_works'"},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'source': ('django.db.models.fields.CharField', [], {'max_length': '15', 'blank': 'True'}),
'wishlist': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Wishlist']"}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'wishes'", 'to': "orm['core.Work']"})
},
'core.wishlist': {
'Meta': {'object_name': 'Wishlist'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'wishlist'", 'unique': 'True', 'to': "orm['auth.User']"}),
'works': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'wishlists'", 'symmetrical': 'False', 'through': "orm['core.Wishes']", 'to': "orm['core.Work']"})
},
'core.work': {
'Meta': {'ordering': "['title']", 'object_name': 'Work'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'default': "''", 'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language': ('django.db.models.fields.CharField', [], {'default': "'en'", 'max_length': '2'}),
'num_wishes': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}),
'openlibrary_lookup': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'})
}
}
complete_apps = ['core']

View File

@ -1,6 +1,11 @@
import re import re
import random import random
import logging import logging
import urllib
import hashlib
from regluit.utils.localdatetime import now, date_today from regluit.utils.localdatetime import now, date_today
from regluit.utils import crypto from regluit.utils import crypto
from datetime import timedelta from datetime import timedelta
@ -1057,6 +1062,10 @@ def pledger2():
return pledger2.instance return pledger2.instance
pledger2.instance=None pledger2.instance=None
ANONYMOUS_AVATAR = '/static/images/header/avatar.png'
(NO_AVATAR, GRAVATAR, TWITTER, FACEBOOK) = (0, 1, 2, 3)
class UserProfile(models.Model): class UserProfile(models.Model):
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)
user = models.OneToOneField(User, related_name='profile') user = models.OneToOneField(User, related_name='profile')
@ -1067,13 +1076,17 @@ class UserProfile(models.Model):
facebook_id = models.PositiveIntegerField(null=True) facebook_id = models.PositiveIntegerField(null=True)
librarything_id = models.CharField(max_length=31, blank=True) librarything_id = models.CharField(max_length=31, blank=True)
badges = models.ManyToManyField('Badge', related_name='holders') badges = models.ManyToManyField('Badge', related_name='holders')
goodreads_user_id = models.CharField(max_length=32, null=True, blank=True) goodreads_user_id = models.CharField(max_length=32, null=True, blank=True)
goodreads_user_name = models.CharField(max_length=200, null=True, blank=True) goodreads_user_name = models.CharField(max_length=200, null=True, blank=True)
goodreads_auth_token = models.TextField(null=True, blank=True) goodreads_auth_token = models.TextField(null=True, blank=True)
goodreads_auth_secret = models.TextField(null=True, blank=True) goodreads_auth_secret = models.TextField(null=True, blank=True)
goodreads_user_link = models.CharField(max_length=200, null=True, blank=True) goodreads_user_link = models.CharField(max_length=200, null=True, blank=True)
avatar_source = models.PositiveSmallIntegerField(null = True, default = GRAVATAR,
choices=((NO_AVATAR,'No Avatar, Please'),(GRAVATAR,'Gravatar'),(TWITTER,'Twitter'),(FACEBOOK,'Facebook')))
def reset_pledge_badge(self): def reset_pledge_badge(self):
#count user pledges #count user pledges
n_pledges = self.pledge_count n_pledges = self.pledge_count
@ -1164,6 +1177,27 @@ class UserProfile(models.Model):
except Exception, e: except Exception, e:
logger.error("error unsubscribing from mailchimp list %s" % (e)) logger.error("error unsubscribing from mailchimp list %s" % (e))
return False return False
def gravatar(self):
# construct the url
gravatar_url = "https://www.gravatar.com/avatar/" + hashlib.md5(self.user.email.lower()).hexdigest() + "?"
gravatar_url += urllib.urlencode({'d':'wavatar', 's':'50'})
return gravatar_url
@property
def avatar_url(self):
if self.avatar_source is None or self.avatar_source is TWITTER:
if self.pic_url:
return self.pic_url
else:
return ANONYMOUS_AVATAR
elif self.avatar_source == GRAVATAR:
return self.gravatar()
elif self.avatar_source == FACEBOOK and self.facebook_id != None:
return 'https://graph.facebook.com/' + str(self.facebook_id) + '/picture'
else:
return ANONYMOUS_AVATAR
@property @property
def social_auths(self): def social_auths(self):
@ -1173,45 +1207,8 @@ class UserProfile(models.Model):
auths[social.provider]=True auths[social.provider]=True
return auths return auths
#class CampaignSurveyResponse(models.Model):
# # generic
# campaign = models.ForeignKey("Campaign", related_name="surveyresponse", null=False)
# user = models.OneToOneField(User, related_name='surveyresponse')
# transaction = models.ForeignKey("payment.Transaction", null=True)
# # for OLA only
# premium = models.ForeignKey("Premium", null=True)
# anonymous = models.BooleanField(null=False)
# # relevant to all campaigns since these arise from acknowledgement requirements from generic premiums
# name = models.CharField(max_length=140, blank=True)
# url = models.URLField(blank=True)
# tagline = models.CharField(max_length=140, blank=True)
# # do we need to collect address for Rupert or will he do that once he has emails?
# this was causing a circular import problem and we do not seem to be using # this was causing a circular import problem and we do not seem to be using
# anything from regluit.core.signals after this line # anything from regluit.core.signals after this line
# from regluit.core import signals # from regluit.core import signals
from regluit.payment.manager import PaymentManager from regluit.payment.manager import PaymentManager
from social_auth.signals import pre_update
from social_auth.backends.facebook import FacebookBackend
from social_auth.backends.twitter import TwitterBackend
def facebook_extra_values(sender, user, response, details, **kwargs):
facebook_id = response.get('id')
user.profile.facebook_id = facebook_id
user.profile.pic_url = 'https://graph.facebook.com/' + facebook_id + '/picture'
user.profile.save()
return True
def twitter_extra_values(sender, user, response, details, **kwargs):
import requests, urllib
twitter_id = response.get('screen_name')
profile_image_url = response.get('profile_image_url_https')
user.profile.twitter_id = twitter_id
user.profile.pic_url = profile_image_url
user.profile.save()
return True
pre_update.connect(facebook_extra_values, sender=FacebookBackend)
pre_update.connect(twitter_extra_values, sender=TwitterBackend)

View File

@ -15,6 +15,7 @@ from selectable.forms import AutoCompleteSelectMultipleWidget,AutoCompleteSelect
from selectable.forms import AutoCompleteSelectWidget,AutoCompleteSelectField from selectable.forms import AutoCompleteSelectWidget,AutoCompleteSelectField
from regluit.core.models import UserProfile, RightsHolder, Claim, Campaign, Premium, Ebook, Edition, PledgeExtra, Work from regluit.core.models import UserProfile, RightsHolder, Claim, Campaign, Premium, Ebook, Edition, PledgeExtra, Work
from regluit.core.models import TWITTER, FACEBOOK, GRAVATAR
from regluit.core.lookups import OwnerLookup, WorkLookup from regluit.core.lookups import OwnerLookup, WorkLookup
from regluit.utils.localdatetime import now from regluit.utils.localdatetime import now
@ -123,18 +124,41 @@ class RightsHolderForm(forms.ModelForm):
except RightsHolder.DoesNotExist: except RightsHolder.DoesNotExist:
return rights_holder_name return rights_holder_name
raise forms.ValidationError(_("Another rights holder with that name already exists.")) raise forms.ValidationError(_("Another rights holder with that name already exists."))
class ProfileForm(forms.ModelForm): class ProfileForm(forms.ModelForm):
clear_facebook=forms.BooleanField(required=False) clear_facebook=forms.BooleanField(required=False)
clear_twitter=forms.BooleanField(required=False) clear_twitter=forms.BooleanField(required=False)
clear_goodreads=forms.BooleanField(required=False) clear_goodreads=forms.BooleanField(required=False)
class Meta: class Meta:
model = UserProfile model = UserProfile
fields = 'tagline', 'librarything_id', 'home_url', 'clear_facebook', 'clear_twitter', 'clear_goodreads' fields = 'tagline', 'librarything_id', 'home_url', 'clear_facebook', 'clear_twitter', 'clear_goodreads', 'avatar_source'
widgets = { widgets = {
'tagline': forms.Textarea(attrs={'rows': 5, 'onKeyUp': "counter(this, 140)", 'onBlur': "counter(this, 140)"}), 'tagline': forms.Textarea(attrs={'rows': 5, 'onKeyUp': "counter(this, 140)", 'onBlur': "counter(this, 140)"}),
} }
def __init__(self, *args, **kwargs):
profile = kwargs.get('instance')
super(ProfileForm, self).__init__(*args, **kwargs)
choices = []
for choice in self.fields['avatar_source'].choices :
if choice[0] == FACEBOOK and not profile.facebook_id:
pass
elif choice[0] == TWITTER and not profile.twitter_id:
pass
else:
choices.append(choice)
self.fields['avatar_source'].choices = choices
def clean(self):
# check that if a social net is cleared, we're not using it a avatar source
if self.cleaned_data.get("clear_facebook", False) and self.cleaned_data.get("avatar_source", None)==FACEBOOK:
self.cleaned_data["avatar_source"]==GRAVATAR
if self.cleaned_data.get("clear_twitter", False) and self.cleaned_data.get("avatar_source", None)==TWITTER:
self.cleaned_data["avatar_source"]==GRAVATAR
return self.cleaned_data
class UserData(forms.Form): class UserData(forms.Form):
username = forms.RegexField( username = forms.RegexField(
label=_("New Username"), label=_("New Username"),

View File

@ -79,18 +79,14 @@
<a href="#"><span id="welcome">Hi, {{ user.username }}</span></a> <a href="#"><span id="welcome">Hi, {{ user.username }}</span></a>
</li> </li>
<li> <li>
{% if user.profile.pic_url %} <img class="user-avatar" src="{{ user.profile.avatar_url }}" height=36 width="36" alt="Avatar for {{ user.username }}" title="{{ user.username }}" />
<img class="user-avatar" src="{{ user.profile.pic_url }}" height=36 width="36" alt="Picture of {{ user.username }}" title="{{ user.username }}" />
{% else %}
<img class="user-avatar" src="/static/images/header/avatar.png" height="36" width="36" alt="Generic Ungluer Avatar" title="Ungluer" />
{% endif %}
{% if unseen_count %} {% if unseen_count %}
<a href="/notification"><span id="i_haz_notifications_badge">{{ unseen_count }}</span></a> <a href="/notification"><span id="i_haz_notifications_badge">{{ unseen_count }}</span></a>
{% endif %} {% endif %}
</li> </li>
</ul> </ul>
<ul id="user_menu"> <ul id="user_menu">
<li><a href="{% url supporter supporter_username=user.username %}">Wishlist</a></li> <li><a href="{% url supporter user %}">Wishlist</a></li>
<li> <li>
<a href="/notification"><span>Messages</span> <a href="/notification"><span>Messages</span>
{% if unseen_count %} {% if unseen_count %}
@ -100,7 +96,7 @@
{% endif %} {% endif %}
</a> </a>
</li> </li>
<li><a href="{% url supporter supporter_username=user.username %}#edit" id="profile_edit"><span>Profile Settings</span></a></li> <li><a href="{% url supporter user %}#edit" id="profile_edit"><span>Profile Settings</span></a></li>
<li><a href="{% url manage_account %}"><span>Account &amp; Pledges</span></a></li> <li><a href="{% url manage_account %}"><span>Account &amp; Pledges</span></a></li>
<li><a href="{% url auth_logout %}"><span>Sign Out</span></a></li> <li><a href="{% url auth_logout %}"><span>Sign Out</span></a></li>
</ul> </ul>

View File

@ -58,18 +58,14 @@
<div class="image"> <div class="image">
<a href="{% url work id %}?tab=2"><img src="{{ comment.content_object.cover_image_thumbnail }}" alt="cover image" /></a> <a href="{% url work id %}?tab=2"><img src="{{ comment.content_object.cover_image_thumbnail }}" alt="cover image" /></a>
</div> </div>
<span><a href="{% url supporter supporter_username=user %}">{{ comment.user.username }}</a> on <a href="{% url work id %}?tab=2">{{ comment.content_object.title }}</a></span><br /> <span><a href="{% url supporter comment.user %}">{{ comment.user.username }}</a> on <a href="{% url work id %}?tab=2">{{ comment.content_object.title }}</a></span><br />
<span class="text">{{ comment.comment|linebreaksbr }}</span> <span class="text">{{ comment.comment|linebreaksbr }}</span>
</div> </div>
<div class="avatar"> <div class="avatar">
<a href="{% url supporter supporter_username=user %}"> <a href="{% url supporter comment.user %}">
{% if supporter.profile.pic_url %} <img class="user-avatar" src="{{ comment.user.profile.avatar_url }}" height="50" width="50" alt="Avatar for {{ comment.user }}" title="{{ comment.user }}" />
<img class="user-avatar" src="{{ comment.user.profile.pic_url }}" height="50" width="50" alt="Picture of {{ comment.user }}" title="{{ comment.user }}" />
{% else %}
<img class="user-avatar" src="/static/images/header/avatar.png" height="50" width="50" alt="Generic Ungluer Avatar" title="Ungluer" />
{% endif %}
</a> </a>
</div> </div>
</div> </div>

View File

@ -3,13 +3,9 @@
<div itemprop="comment" itemscope itemtype="http://schema.org/UserComments" class="work_supporter {% if comment.content_object.last_campaign and comment.user in comment.content_object.last_campaign.managers.all %}official{% endif %}"> <div itemprop="comment" itemscope itemtype="http://schema.org/UserComments" class="work_supporter {% if comment.content_object.last_campaign and comment.user in comment.content_object.last_campaign.managers.all %}official{% endif %}">
<span itemprop="creator" itemscope itemtype="http://schema.org/Person"> <span itemprop="creator" itemscope itemtype="http://schema.org/Person">
<a itemprop="url" href="{% url supporter supporter_username=comment.user.username %}"> <a itemprop="url" href="{% url supporter comment.user %}">
<span class="work_supporter_avatar"> <span class="work_supporter_avatar">
{% if comment.user.profile.pic_url %} <img class="user-avatar" src="{{ comment.user.profile.avatar_url }}" height="50" width="50" alt="Avatar for {{ comment.user }}" title="{{ comment.user }}" />
<img class="user-avatar" src="{{ comment.user.profile.pic_url }}" height="50" width="50" alt="Picture of {{ comment.user }}" title="{{ comment.user }}" />
{% else %}
<img class="user-avatar" src="/static/images/header/avatar.png" height="50" width="50" alt="Generic Ungluer Avatar" title="Ungluer" />
{% endif %}
</span> </span>
<span class="comment_username">{{comment.user.username }}</span> <span class="comment_username">{{comment.user.username }}</span>
</a> </a>

View File

@ -20,17 +20,16 @@
{% else %} {% else %}
<h1>{% trans "Preview your comment" %}</h1> <h1>{% trans "Preview your comment" %}</h1>
<div class="work_supporter {% if content_object.last_campaign and user in content_object.last_campaign.managers.all %}official{% endif %}"> <div class="work_supporter {% if content_object.last_campaign and user in content_object.last_campaign.managers.all %}official{% endif %}">
<a href="{% url supporter supporter_username=user.username %}"> <a href="{% url supporter user %}">
<span class="work_supporter_avatar"> <span class="work_supporter_avatar">
{% if user.profile.pic_url %} <img class="user-avatar" src="{{ user.profile.avatar_url }}" height="50" width="50" alt="Avatar for {{ user }}" title="{{ user }}" />
<img class="user-avatar" src="{{ user.profile.pic_url }}" height="50" width="50" alt="Picture of {{ user }}" title="{{ user }}" /> </span>
{% else %} <span class="comment_username">{{user.username }}</span>
<img class="user-avatar" src="/static/images/header/avatar.png" height="50" width="50" alt="Generic Ungluer Avatar" title="Ungluer" /> </a>
{% endif %} <span>( [today's date] )</span> <br />
</span> <span class="comment">{{ comment|linebreaksbr }}<br /></span>
<span class="comment_username">{{user.username }}</span></a> <span>( [today's date] )</span> <br /><span class="comment">{{ comment|linebreaksbr }}<br /></span> </div>
</div> <br /><br /><br />
<br /><br /><br />
<p> <p>
{% trans "and" %} <input type="submit" name="submit" class="submit-post" value="{% trans "Post your comment" %}" id="submit" /> {% trans "or make changes" %}: {% trans "and" %} <input type="submit" name="submit" class="submit-post" value="{% trans "Post your comment" %}" id="submit" /> {% trans "or make changes" %}:
</p> </p>

View File

@ -46,13 +46,9 @@
<span>Ungluers</span> <span>Ungluers</span>
<ul class="menu level2"> <ul class="menu level2">
{% for ungluer in ungluers %} {% for ungluer in ungluers %}
<li class="first"><a href="{% url supporter supporter_username=ungluer %}"> <li class="first"><a href="{% url supporter ungluer %}">
{% if ungluer.profile.pic_url %} <img src="{{ungluer.profile.avatar_url}}" height="30" width="30" alt="Avatar for {{ungluer}}" title="{{ungluer}}" /></a>
<img src="{{ungluer.profile.pic_url}}" height="30" width="30" alt="{{ungluer}}" title="{{ungluer}}" /></a> <a href="{% url supporter ungluer %}"><span class="ungluer-name">{{ungluer|truncatechars:20}}</span>
{% else %}
<img src="/static/images/header/avatar.png" height="30" width="30" alt="Generic Ungluer Avatar" /></a>
{% endif %}
<a href="{% url supporter supporter_username=ungluer %}"><span class="ungluer-name">{{ungluer|truncatechars:20}}</span>
</a></li> </a></li>
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -77,7 +77,7 @@ function put_un_in_cookie2(){
</div> </div>
{% else %} {% else %}
<div> <div>
You are logged in as <a href="{% url supporter supporter_username=request.user.username %}">{{ request.user.username }}</a>. You are logged in as <a href="{% url supporter request.user %}">{{ request.user.username }}</a>.
</div> </div>
{% endif %} {% endif %}
@ -154,7 +154,7 @@ function put_un_in_cookie2(){
</div> </div>
{% else %} {% else %}
<div> <div>
You are logged in as <a href="{% url supporter supporter_username=request.user.username %}">{{ request.user.username }}</a>. You are logged in as <a href="{% url supporter request.user %}">{{ request.user.username }}</a>.
</div> </div>
{% endif %} {% endif %}

View File

@ -20,14 +20,10 @@ tweet, FB, email sharing show up. Include a {% url work your.local.work.id as w
This is where you put your headline. This is where you put your headline.
Brief text, graphics-oriented info like user avatars and campaign status icons. Brief text, graphics-oriented info like user avatars and campaign status icons.
e.g.: e.g.:
<a href="{% url supporter supporter %}"> <a href="{% url supporter comment.user %}">
{% if supporter.profile.pic_url %} <img class="user-avatar" src="{{ comment.user.profile.avatar_url }}" height="50" width="50" alt="Avatar for {{ comment.user }}" title="{{ comment.user }}" />
<img class="user-avatar" src="{{ comment.user.profile.pic_url }}" height="50" width="50" alt="Picture of {{ comment.user }}" title="{{ comment.user }}" />
{% else %}
<img class="user-avatar" src="/static/images/header/avatar.png" height="50" width="50" alt="Generic Ungluer Avatar" title="Ungluer" />
{% endif %}
</a> </a>
<span><a href="{% url supporter supporter %}">{{ comment.user.username }}</a> on <a href="{{ work_url }}?tab=2">{{ comment.content_object.title }}</a></span>{% endcomment %}{% endblock %} <span><a href="{% url supporter comment.user %}">{{ comment.user.username }}</a> on <a href="{{ work_url }}?tab=2">{{ comment.content_object.title }}</a></span>{% endcomment %}{% endblock %}
<br /><i>{% now "M d Y, h:i A"%}</i><br /> <br /><i>{% now "M d Y, h:i A"%}</i><br />
</span> </span>
<hr /> <hr />

View File

@ -6,11 +6,7 @@
{% endblock %} {% endblock %}
{% block comments_graphical %} {% block comments_graphical %}
<a href="{% url supporter sender %}"> <a href="{% url supporter sender %}">
{% if sender.profile.pic_url %} <img class="user-avatar" src="{{ sender.profile.avatar_url }}" height="50" width="50" alt="Avatar for {{ sender }}" title="{{ sender }}" />
<img class="user-avatar" src="{{ sender.profile.pic_url }}" height="50" width="50" alt="Picture of {{ sender }}" title="{{ sender }}" />
{% else %}
<img class="user-avatar" src="/static/images/header/avatar.png" height="50" width="50" alt="Generic Ungluer Avatar" title="Ungluer" />
{% endif %}
</a> </a>
<span>Message from <a href="{% url supporter sender %}">{{ sender.username }}</a> {% if sender.is_staff %} (Unglue.it staff) {% endif %} on <a href="{% url work work.id %}">{{ work.title }}</a></span> <span>Message from <a href="{% url supporter sender %}">{{ sender.username }}</a> {% if sender.is_staff %} (Unglue.it staff) {% endif %} on <a href="{% url work work.id %}">{{ work.title }}</a></span>
{% endblock %} {% endblock %}

View File

@ -8,6 +8,6 @@
<p><b>Tagline:</b> {{ profile.tagline }}</p> <p><b>Tagline:</b> {{ profile.tagline }}</p>
<p><a href="/profiles/edit/">Edit Again</a></p> <p><a href="/profiles/edit/">Edit Again</a></p>
<p><a href="{% url supporter supporter_username=user %}/">{{user}}'s Unglue.it Page</a></p> <p><a href="{% url supporter user %}/">{{user}}'s Unglue.it Page</a></p>
</div> </div>
{% endblock content %} {% endblock content %}

View File

@ -9,7 +9,7 @@ Oops &ndash; it seems that your activation key is invalid. Please check the url
{% endif %} {% endif %}
{% else %} {% else %}
<div> <div>
You are logged in as <a href="{% url supporter supporter_username=request.user.username %}">{{ request.user.username }}</a>. You are logged in as <a href="{% url supporter request.user %}">{{ request.user.username }}</a>.
</div> </div>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -14,7 +14,7 @@
</div> </div>
{% else %} {% else %}
<div> <div>
You are already logged in as <a href="{% url supporter supporter_username=user.username %}">{{ user.username }}</a>. You are already logged in as <a href="{% url supporter user.username %}">{{ user.username }}</a>.
</div> </div>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -27,7 +27,7 @@ Make sure the username box has your <b>username, not your email</b> -- some brow
</div> </div>
{% else %} {% else %}
<div> <div>
You are already logged in as <a href="{% url supporter supporter_username=user.username %}">{{ user.username }}</a>. You are already logged in as <a href="{% url supporter user %}">{{ user.username }}</a>.
</div> </div>
{% endif %} {% endif %}
</div> </div>

View File

@ -15,7 +15,7 @@ An account activation email has been sent. Please check your email and click on
{% endif %} {% endif %}
{% else %} {% else %}
<div> <div>
You are logged in as <a href="{% url supporter supporter_username=request.user.username %}">{{ request.user.username }}</a>. You are logged in as <a href="{% url supporter request.user %}">{{ request.user.username }}</a>.
</div> </div>
{% endif %} {% endif %}

View File

@ -27,7 +27,7 @@ function put_un_in_cookie(){
</div> </div>
{% else %} {% else %}
<div> <div>
You are already logged in as <a href="{% url supporter supporter_username=user.username %}">{{ user.username }}</a>. You are already logged in as <a href="{% url supporter user %}">{{ user.username }}</a>.
</div> </div>
{% endif %} {% endif %}

View File

@ -24,7 +24,7 @@
<dt>{{ rights_holder.rights_holder_name }}</dt> <dt>{{ rights_holder.rights_holder_name }}</dt>
<dd>PSA #: {{ rights_holder.id }} <dd>PSA #: {{ rights_holder.id }}
<br />email: {{ rights_holder.email }} <br />email: {{ rights_holder.email }}
<br />owner: <a href="{% url supporter supporter_username=rights_holder.owner %}">{{ rights_holder.owner }}</a></dd> <br />owner: <a href="{% url supporter rights_holder.owner %}">{{ rights_holder.owner }}</a></dd>
{% empty %} {% empty %}
<p>No rights holders have been accepted yet</p> <p>No rights holders have been accepted yet</p>
{% endfor %} {% endfor %}

View File

@ -97,7 +97,7 @@ $j(document).ready(function() {
</div> </div>
<div id="content-block-content"><div id="results"> <div id="content-block-content"><div id="results">
{% for work in results %} {% for work in results %}
{% if not work.campaigns %} {% if not work.last_campaign %}
<div class="{% cycle 'row1' 'row2' %} book"> <div class="{% cycle 'row1' 'row2' %} book">
{% with work.googlebooks_id as googlebooks_id %} {% with work.googlebooks_id as googlebooks_id %}
{% with 'yes' as on_search_page %} {% with 'yes' as on_search_page %}

View File

@ -98,11 +98,7 @@ there's no tab for seeing ALL my books, only the filters! huh.
<div class="user-block" itemscope itemtype="http://schema.org/Person"> <div class="user-block" itemscope itemtype="http://schema.org/Person">
<div id="user-block1"> <div id="user-block1">
<div class="block-inner"> <div class="block-inner">
{% if supporter.profile.pic_url %} <img class="user-avatar" src="{{ supporter.profile.avatar_url }}" height="50" width="50" alt="Avatar for {{ supporter }}" title="Avatar" />
<img class="user-avatar" src="{{ supporter.profile.pic_url }}" height="50" width="50" alt="Picture of {{ supporter }}" title="{{ supporter }}" />
{% else %}
<img class="user-avatar" src="/static/images/header/avatar.png" height="50" width="50" alt="Generic Ungluer Avatar" title="Ungluer" />
{% endif %}
<span class="user-name"> <span class="user-name">
<a href="#"><span itemprop="name">{{ supporter.username }}</span></a> <a href="#"><span itemprop="name">{{ supporter.username }}</span></a>
</span> </span>
@ -176,7 +172,11 @@ there's no tab for seeing ALL my books, only the filters! huh.
{% csrf_token %} {% csrf_token %}
<div class="block block1"> <div class="block block1">
<div class="block-inner"> <div class="block-inner">
<h3 class="title">Your Tagline</h3> {{ profile_form.avatar_source.errors }}
Your profile pic: {{ profile_form.avatar_source }} {% ifequal supporter.profile.avatar_source 1 %} <br /><a href="http://en.gravatar.com/">Set your Gravatar</a><br /><br />{% endifequal %}
</div>
<div class="block-inner">
<p>Your Tagline</p>
{{ profile_form.tagline.errors }} {{ profile_form.tagline.errors }}
{{ profile_form.tagline }}<br /> {{ profile_form.tagline }}<br />
<span id="count_display">140</span> characters remaining<br /><br /> <span id="count_display">140</span> characters remaining<br /><br />
@ -186,7 +186,7 @@ there's no tab for seeing ALL my books, only the filters! huh.
</div> </div>
<div class="block block2"> <div class="block block2">
<h3 class="title">Links</h3> <h3 class="title">Your Links</h3>
<div class="check-list"> <div class="check-list">
<label> {% if supporter.profile.home_url %}Change{% else %}Add{% endif %} your homepage URL:</label> <label> {% if supporter.profile.home_url %}Change{% else %}Add{% endif %} your homepage URL:</label>
{{ profile_form.home_url }}{{ profile_form.home_url.errors }} {{ profile_form.home_url }}{{ profile_form.home_url.errors }}

View File

@ -217,13 +217,9 @@
{% for wish in work.wishes.all reversed %} {% for wish in work.wishes.all reversed %}
{% with wish.wishlist.user as supporter %} {% with wish.wishlist.user as supporter %}
<div class="work_supporter_wide"> <div class="work_supporter_wide">
<a href="{% url supporter supporter_username=supporter.username %}"> <a href="{% url supporter supporter %}">
<span class="work_supporter_avatar"> <span class="work_supporter_avatar">
{% if supporter.profile.pic_url %} <img class="user-avatar" src="{{ supporter.profile.avatar_url }}" height="50" width="50" alt="Avatar for {{ supporter }}" title="{{ supporter }}" />
<img class="user-avatar" src="{{ supporter.profile.pic_url }}" height="50" width="50" alt="Picture of {{ supporter }}" title="{{ supporter }}" />
{% else %}
<img class="user-avatar" src="/static/images/header/avatar.png" height="50" width="50" alt="Generic Ungluer Avatar" title="Ungluer" />
{% endif %}
</span> </span>
</a> </a>
<div class="show_supporter_contact_form" > <div class="show_supporter_contact_form" >
@ -245,13 +241,9 @@
{% for wish in work.wishes.all reversed %} {% for wish in work.wishes.all reversed %}
{% with wish.wishlist.user as supporter %} {% with wish.wishlist.user as supporter %}
<div class="work_supporter_nocomment" itemscope itemtype="http://schema.org/Person"> <div class="work_supporter_nocomment" itemscope itemtype="http://schema.org/Person">
<a itemprop="url" href="{% url supporter supporter_username=supporter.username %}"> <a itemprop="url" href="{% url supporter supporter %}">
<span class="work_supporter_avatar"> <span class="work_supporter_avatar">
{% if supporter.profile.pic_url %} <img class="user-avatar" src="{{ supporter.profile.avatar_url }}" height="50" width="50" alt="Avatar for {{ supporter }}" title="{{ supporter }}" />
<img class="user-avatar" src="{{ supporter.profile.pic_url }}" height="50" width="50" alt="Picture of {{ supporter }}" title="{{ supporter }}" />
{% else %}
<img class="user-avatar" src="/static/images/header/avatar.png" height="50" width="50" alt="Generic Ungluer Avatar" title="Ungluer" />
{% endif %}
</span> </span>
<span class="work_supporter_name">{{ supporter }}</span> <span class="work_supporter_name">{{ supporter }}</span>
</a> </a>

View File

@ -1459,8 +1459,12 @@ def supporter(request, supporter_username, template_name):
if profile_form.cleaned_data['clear_facebook'] or profile_form.cleaned_data['clear_twitter'] or profile_form.cleaned_data['clear_goodreads'] : if profile_form.cleaned_data['clear_facebook'] or profile_form.cleaned_data['clear_twitter'] or profile_form.cleaned_data['clear_goodreads'] :
if profile_form.cleaned_data['clear_facebook']: if profile_form.cleaned_data['clear_facebook']:
profile_obj.facebook_id=0 profile_obj.facebook_id=0
if profile_obj.avatar_source == models.FACEBOOK:
profile_obj.avatar_source = models.GRAVATAR
if profile_form.cleaned_data['clear_twitter']: if profile_form.cleaned_data['clear_twitter']:
profile_obj.twitter_id="" profile_obj.twitter_id=""
if profile_obj.avatar_source == models.TWITTER:
profile_obj.avatar_source = models.GRAVATAR
if profile_form.cleaned_data['clear_goodreads']: if profile_form.cleaned_data['clear_goodreads']:
profile_obj.goodreads_user_id = None profile_obj.goodreads_user_id = None
profile_obj.goodreads_user_name = None profile_obj.goodreads_user_name = None

View File

@ -211,8 +211,10 @@ AUTHENTICATION_BACKENDS = (
) )
SOCIAL_AUTH_ENABLED_BACKENDS = ['google', 'facebook', 'twitter'] SOCIAL_AUTH_ENABLED_BACKENDS = ['google', 'facebook', 'twitter']
SOCIAL_AUTH_ASSOCIATE_BY_MAIL = True #SOCIAL_AUTH_ASSOCIATE_BY_MAIL = True
SOCIAL_AUTH_NEW_USER_REDIRECT_URL = '/' SOCIAL_AUTH_NEW_USER_REDIRECT_URL = '/'
FACEBOOK_SOCIAL_AUTH_BACKEND_ERROR_URL = '/'
SOCIAL_AUTH_SLUGIFY_USERNAMES = True
# following is needed because of length limitations in a unique constrain for MySQL # following is needed because of length limitations in a unique constrain for MySQL
# see https://github.com/omab/django-social-auth/issues/539 # see https://github.com/omab/django-social-auth/issues/539
SOCIAL_AUTH_UID_LENGTH = 222 SOCIAL_AUTH_UID_LENGTH = 222
@ -220,7 +222,17 @@ SOCIAL_AUTH_NONCE_SERVER_URL_LENGTH = 200
SOCIAL_AUTH_ASSOCIATION_SERVER_URL_LENGTH = 135 SOCIAL_AUTH_ASSOCIATION_SERVER_URL_LENGTH = 135
SOCIAL_AUTH_ASSOCIATION_HANDLE_LENGTH = 125 SOCIAL_AUTH_ASSOCIATION_HANDLE_LENGTH = 125
TWITTER_EXTRA_DATA = [('profile_image_url', 'profile_image_url')] SOCIAL_AUTH_PIPELINE = (
'regluit.core.auth.selectively_associate',
'social_auth.backends.pipeline.associate.associate_by_email',
'social_auth.backends.pipeline.user.get_username',
'social_auth.backends.pipeline.user.create_user',
'social_auth.backends.pipeline.social.associate_user',
'regluit.core.auth.deliver_extra_data',
'social_auth.backends.pipeline.user.update_user_details'
)
TWITTER_EXTRA_DATA = [('profile_image_url_https', 'profile_image_url_https'),('screen_name','screen_name')]
LOGIN_URL = "/accounts/superlogin/" LOGIN_URL = "/accounts/superlogin/"
LOGIN_REDIRECT_URL = "/" LOGIN_REDIRECT_URL = "/"