You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.0 KiB
28 lines
1.0 KiB
from django.shortcuts import redirect, render_to_response
|
|
|
|
from social.pipeline.partial import partial
|
|
|
|
@partial
|
|
def test_contractor(backend, details, response, is_new=False, *args, **kwargs):
|
|
import code; code.interact(local=dict(globals(), **locals()))
|
|
|
|
|
|
@partial
|
|
def add_email_for_user(backend, details, response, is_new=False, *args, **kwargs):
|
|
data = backend.strategy.request_data()
|
|
# import code; code.interact(local=dict(globals(), **locals()))
|
|
if not details.get('email'):
|
|
if 'email' in kwargs['request']:
|
|
return {'email': kwargs['request']['email']}
|
|
else:
|
|
return render_to_response('add_email_form.html')
|
|
@partial
|
|
def require_email(strategy, details, user=None, is_new=False, *args, **kwargs):
|
|
if kwargs.get('ajax') or user and user.email:
|
|
return
|
|
elif is_new and not details.get('email'):
|
|
email = strategy.request_data().get('email')
|
|
if email:
|
|
details['email'] = email
|
|
else:
|
|
return redirect('require_email')
|
|
|