A stub signal for Transaction.post_save() event
parent
68b0d4b73a
commit
2e28139c00
|
@ -7,7 +7,10 @@ from social_auth.signals import pre_update
|
||||||
from social_auth.backends.facebook import FacebookBackend
|
from social_auth.backends.facebook import FacebookBackend
|
||||||
from tastypie.models import create_api_key
|
from tastypie.models import create_api_key
|
||||||
|
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# get email from Facebook registration
|
||||||
def facebook_extra_values(sender, user, response, details, **kwargs):
|
def facebook_extra_values(sender, user, response, details, **kwargs):
|
||||||
if response.get('email') is not None:
|
if response.get('email') is not None:
|
||||||
user.email = response.get('email')
|
user.email = response.get('email')
|
||||||
|
@ -15,6 +18,8 @@ def facebook_extra_values(sender, user, response, details, **kwargs):
|
||||||
|
|
||||||
pre_update.connect(facebook_extra_values, sender=FacebookBackend)
|
pre_update.connect(facebook_extra_values, sender=FacebookBackend)
|
||||||
|
|
||||||
|
|
||||||
|
# create Wishlist and UserProfile to associate with User
|
||||||
def create_user_objects(sender, created, instance, **kwargs):
|
def create_user_objects(sender, created, instance, **kwargs):
|
||||||
# use get_model to avoid circular import problem with models
|
# use get_model to avoid circular import problem with models
|
||||||
try:
|
try:
|
||||||
|
@ -29,4 +34,19 @@ def create_user_objects(sender, created, instance, **kwargs):
|
||||||
return
|
return
|
||||||
|
|
||||||
post_save.connect(create_user_objects, sender=User)
|
post_save.connect(create_user_objects, sender=User)
|
||||||
|
|
||||||
|
|
||||||
|
# create API key for new User
|
||||||
post_save.connect(create_api_key, sender=User)
|
post_save.connect(create_api_key, sender=User)
|
||||||
|
|
||||||
|
# handle any save, updates to a payment.Transaction
|
||||||
|
|
||||||
|
def handle_transaction_change(sender, instance, created, **kwargs):
|
||||||
|
try:
|
||||||
|
campaign = instance.campaign
|
||||||
|
logger.info('Got the signal for Transaction %s w/ Campaign %s ', instance.id, campaign.id)
|
||||||
|
return True
|
||||||
|
except Exception, e:
|
||||||
|
return False
|
||||||
|
|
||||||
|
post_save.connect(handle_transaction_change,sender=get_model('payment','Transaction'))
|
||||||
|
|
Loading…
Reference in New Issue