@shared_task()
def subscribe_user_to_basket(instance_id, newsletters=[]):
 from mozillians.users.models import UserProfile
 try:
  instance = UserProfile.objects.get(pk=instance_id)
 except UserProfile.DoesNotExist:
  instance = None
 if ((not BASKET_ENABLED) or (not instance) or (not newsletters) or (not waffle.switch_is_active('BASKET_SWITCH_ENABLED'))):
  return
 lookup_subtask = lookup_user_task.subtask((instance.user.email,))
 subscribe_subtask = subscribe_user_task.subtask((instance.user.email, newsletters))
 chain((lookup_subtask | subscribe_subtask))()

@ shared_task ( ) def subscribe_user_to_basket ( instance_id , newsletters = [ ] ) : from mozillians . users . models import UserProfile try : instance = UserProfile . objects . get ( pk = instance_id ) except UserProfile . DoesNotExist : instance = None if ( ( not BASKET_ENABLED ) or ( not instance ) or ( not newsletters ) or ( not waffle . switch_is_active ( 'BASKET_SWITCH_ENABLED' ) ) ) : return lookup_subtask = lookup_user_task . subtask ( ( instance . user . email , ) ) subscribe_subtask = subscribe_user_task . subtask ( ( instance . user . email , newsletters ) ) chain ( ( lookup_subtask | subscribe_subtask ) ) ( )
subscribe a user to basket .