@task(ignore_result=True)
def send_pending_membership_emails():
 from mozillians.groups.models import Group, GroupMembership
 groups = Group.objects.exclude(curators__isnull=True)
 groups = groups.filter(groupmembership__status=GroupMembership.PENDING).distinct()
 for group in groups:
  pending_memberships = group.groupmembership_set.filter(status=GroupMembership.PENDING)
  max_pk = pending_memberships.aggregate(max_pk=Max('pk'))['max_pk']
  if (max_pk > group.max_reminder):
   activate('en-us')
   count = pending_memberships.count()
   subject = (ungettext('%(count)d outstanding request to join Mozillians group "%(name)s"', '%(count)d outstanding requests to join Mozillians group "%(name)s"', count) % {'count': count, 'name': group.name})
   body = render_to_string('groups/email/memberships_pending.txt', {'group': group, 'count': count})
   send_mail(subject, body, settings.FROM_NOREPLY, [profile.user.email for profile in group.curators.all()], fail_silently=False)
   group.max_reminder = max_pk
   group.save()

@ task ( ignore_result = True ) def send_pending_membership_emails ( ) : from mozillians . groups . models import Group , GroupMembership groups = Group . objects . exclude ( curators__isnull = True ) groups = groups . filter ( groupmembership__status = GroupMembership . PENDING ) . distinct ( ) for group in groups : pending_memberships = group . groupmembership_set . filter ( status = GroupMembership . PENDING ) max_pk = pending_memberships . aggregate ( max_pk = Max ( 'pk' ) ) [ 'max_pk' ] if ( max_pk > group . max_reminder ) : activate ( 'en-us' ) count = pending_memberships . count ( ) subject = ( ungettext ( '%(count)d outstanding request to join Mozillians group "%(name)s"' , '%(count)d outstanding requests to join Mozillians group "%(name)s"' , count ) % { 'count' : count , 'name' : group . name } ) body = render_to_string ( 'groups/email/memberships_pending.txt' , { 'group' : group , 'count' : count } ) send_mail ( subject , body , settings . FROM_NOREPLY , [ profile . user . email for profile in group . curators . all ( ) ] , fail_silently = False ) group . max_reminder = max_pk group . save ( )
for each curated group that has pending memberships that the curators have not yet been emailed about .