@@ -28,7 +28,7 @@ def user_details(strategy, details, user=None, *args, **kwargs):
2828 """Update user details using data from provider."""
2929 if user :
3030 if not UnifiUser .objects .filter (user = user ).exists ():
31- print "user_details:UserProfile NOT exist, creating.."
31+ print ( "user_details:UserProfile NOT exist, creating.." )
3232 changed = False # flag to track changes
3333 protected = ('username' , 'id' , 'pk' , 'email' ) + \
3434 tuple (strategy .setting ('PROTECTED_USER_FIELDS' , []))
@@ -43,9 +43,9 @@ def user_details(strategy, details, user=None, *args, **kwargs):
4343 current_value = getattr (user , name , None )
4444 if not current_value or name not in protected :
4545 changed |= current_value != value
46- # print "user_details::name", name
47- value = value .replace ("'" , " " )[0 :29 ];
48- # print "user_details::value", value; #FIX - crash con nomi superiori ai 30 caratteri
46+ # print( "user_details::name", name)
47+ value = value .replace ("'" , " " )[0 :29 ]
48+ # print( "user_details::value", value) #FIX - crash con nomi superiori ai 30 caratteri
4949
5050 setattr (user , name , value )
5151
@@ -60,28 +60,28 @@ def save_profile(backend, user, response, *args, **kwargs):
6060
6161 if backend .name == 'facebook' :
6262 try :
63- profile = UnifiUser .objects .get (user = user );
63+ profile = UnifiUser .objects .get (user = user )
6464 except UnifiUser .DoesNotExist :
6565 profile = UnifiUser ()
66- profile .user = user ;
67- profile .save ();
66+ profile .user = user
67+ profile .save ()
6868
69- profile .gender = response .get ('gender' );
69+ profile .gender = response .get ('gender' )
7070 profile .about = response .get ('about' )
7171 profile .city = response .get ('hometown' )
7272 profile .user .email = response .get ('email' )
7373
74- birthday_date = None ;
74+ birthday_date = None
7575 try :
7676 birthday = response .get ('birthday' )
7777 birthday_date = datetime .strptime (birthday , '%m/%d/%Y' )
7878 except Exception as eb :
79- pass ;
79+ pass
8080 profile .dob = birthday_date
8181
8282 fbuid = response .get ('id' )
8383 profile .user .username = fbuid # la mail e' troppo grande
84- profile .user .save ();
84+ profile .user .save ()
8585
8686 try :
8787 image_name = 'fb_avatar_%s.jpg' % fbuid
@@ -93,48 +93,48 @@ def save_profile(backend, user, response, *args, **kwargs):
9393 ContentFile (image_stream .read ()),
9494 )
9595 except Exception as e :
96- pass ;
96+ pass
9797
9898 # INIT - 14-12-2016
99- print "FACEBOOK:seleziono lingua"
99+ print ( "FACEBOOK:seleziono lingua" )
100100 try :
101- fb_access_token = response .get ('access_token' );
102- fb_locale_url = "https://graph.facebook.com/v2.9/" + "/me?fields=locale,location" + "&access_token=" + fb_access_token ;
103- print fb_locale_url
101+ fb_access_token = response .get ('access_token' )
102+ fb_locale_url = "https://graph.facebook.com/v2.9/" + "/me?fields=locale,location" + "&access_token=" + fb_access_token
103+ print ( fb_locale_url )
104104 r = requests .get (fb_locale_url )
105105
106106 if r .status_code == 200 :
107107 fb_response = json .loads (str (r .text .encode ("utf-8" )))
108- print "fb response :" , fb_response
108+ print ( "fb response :" , fb_response )
109109
110110 # language
111111 try :
112- print "***LANG :" , fb_response .get ('locale' )[0 :2 ]
112+ print ( "***LANG :" , fb_response .get ('locale' )[0 :2 ])
113113 profile .language = fb_response .get ('locale' )[0 :2 ]
114114 except :
115- pass ;
115+ pass
116116
117117 # city
118118 try :
119- print "***LOCATION :" , fb_response .get ('location' )
119+ print ( "***LOCATION :" , fb_response .get ('location' ) )
120120 profile .city = fb_response .get ('location' )['name' ]
121121 except :
122- pass ;
122+ pass
123123
124124 except Exception as e :
125- print "FB Exception with locale " + str (e )
125+ print ( "FB Exception with locale " + str (e ) )
126126 pass ;
127127 profile .last_backend_login = backend .name ;
128- profile .save ();
128+ profile .save ()
129129 else :
130130 # in questo caso sto solo richiedendo una nuova associazione social
131- print "UserProfile already exist..nothing..."
131+ print ( "UserProfile already exist..nothing..." )
132132
133133 # questo e' il caso di un utente che ha cancellato l'account
134134 # e' poi ritornato successivamente
135- profile = UnifiUser .objects .get (user = user );
136- profile .user .is_active = True ;
137- profile .user .save ();
135+ profile = UnifiUser .objects .get (user = user )
136+ profile .user .is_active = True
137+ profile .user .save ()
138138
139139
140140def manage_auth_already_associated (backend , uid , user = None , * args , ** kwargs ):
0 commit comments