@task(ignore_result=True)
def email_membership_change(group_pk, user_pk, old_status, new_status):
 from mozillians.groups.models import Group, GroupMembership
 group = Group.objects.get(pk=group_pk)
 user = User.objects.get(pk=user_pk)
 activate('en-us')
 if (old_status in [GroupMembership.PENDING, GroupMembership.PENDING_TERMS]):
  if (new_status == GroupMembership.MEMBER):
   subject = (_('Accepted to Mozillians group "%s"') % group.name)
   template_name = 'groups/email/accepted.txt'
  elif (new_status is None):
   subject = (_('Not accepted to Mozillians group "%s"') % group.name)
   template_name = 'groups/email/rejected.txt'
  else:
   raise ValueError('BAD ARGS TO email_membership_change')
 else:
  raise ValueError('BAD ARGS TO email_membership_change')
 context = {'group': group, 'user': user}
 template = get_template(template_name)
 body = template.render(context)
 send_mail(subject, body, settings.FROM_NOREPLY, [user.email], fail_silently=False)

@ task ( ignore_result = True ) def email_membership_change ( group_pk , user_pk , old_status , new_status ) : from mozillians . groups . models import Group , GroupMembership group = Group . objects . get ( pk = group_pk ) user = User . objects . get ( pk = user_pk ) activate ( 'en-us' ) if ( old_status in [ GroupMembership . PENDING , GroupMembership . PENDING_TERMS ] ) : if ( new_status == GroupMembership . MEMBER ) : subject = ( _ ( 'Accepted to Mozillians group "%s"' ) % group . name ) template_name = 'groups/email/accepted.txt' elif ( new_status is None ) : subject = ( _ ( 'Not accepted to Mozillians group "%s"' ) % group . name ) template_name = 'groups/email/rejected.txt' else : raise ValueError ( 'BAD ARGS TO email_membership_change' ) else : raise ValueError ( 'BAD ARGS TO email_membership_change' ) context = { 'group' : group , 'user' : user } template = get_template ( template_name ) body = template . render ( context ) send_mail ( subject , body , settings . FROM_NOREPLY , [ user . email ] , fail_silently = False )
email user that their group membership status has changed .