prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  TP creation email should use BCC
  Let's BCC by default when Pootle is communicating to lists of people.  When you create a TP all relevant people are listed in the To field.
  
  
  </issue>
  <code>
  [start of pootle/core/mail.py]
  1 # -*- coding: utf-8 -*-
  2 #
  3 # Copyright (C) Pootle contributors.
  4 #
  5 # This file is a part of the Pootle project. It is distributed under the GPL3
  6 # or later license. See the LICENSE file for a copy of the license and the
  7 # AUTHORS file for copyright and authorship information.
  8 
  9 from django.core.mail import EmailMultiAlternatives, get_connection
  10 
  11 
  12 def send_mail(subject, message, from_email, recipient_list,
  13               fail_silently=False, auth_user=None, auth_password=None,
  14               connection=None, html_message=None, headers=None):
  15     """Override django send_mail function to allow use of custom email headers.
  16     """
  17 
  18     connection = connection or get_connection(username=auth_user,
  19                                               password=auth_password,
  20                                               fail_silently=fail_silently)
  21 
  22     mail = EmailMultiAlternatives(subject, message,
  23                                   from_email, recipient_list,
  24                                   connection=connection, headers=headers)
  25 
  26     if html_message:
  27         mail.attach_alternative(html_message, 'text/html')
  28 
  29     return mail.send()
  30
  [end of pootle/core/mail.py]
  [start of pootle/apps/pootle_translationproject/receivers.py]
  1 #!/usr/bin/env python
  2 # -*- coding: utf-8 -*-
  3 #
  4 # Copyright (C) Pootle contributors.
  5 #
  6 # This file is a part of the Pootle project. It is distributed under the GPL3
  7 # or later license. See the LICENSE file for a copy of the license and the
  8 # AUTHORS file for copyright and authorship information.
  9 
  10 from django.contrib.auth import get_user_model
  11 from django.core.mail import send_mail
  12 from django.db.models import Q
  13 from django.dispatch import receiver
  14 from django.template.loader import render_to_string
  15 from django.utils.translation import ugettext_lazy as _
  16 
  17 from pootle.core.url_helpers import urljoin
  18 
  19 from .models import TranslationProject
  20 from .signals import tp_init_failed_async, tp_inited_async
  21 
  22 
  23 def get_recipients(project):
  24     User = get_user_model()
  25     return list(set(User.objects.filter(
  26         Q(permissionset__positive_permissions__codename="administrate",
  27           permissionset__directory__pootle_path=project.pootle_path) |
  28         Q(is_superuser=True)).values_list("email", flat=True)))
  29 
  30 
  31 @receiver(tp_inited_async, sender=TranslationProject)
  32 def tp_inited_async(instance, response_url, **kwargs):
  33     ctx = {"tp": instance,
  34            "url": urljoin(response_url, instance.get_absolute_url())}
  35     message = render_to_string(
  36         'projects/admin/email/translation_project_created.txt', ctx)
  37     subject = _(u"Translation project (%s) created" % instance)
  38     recipients = get_recipients(instance.project)
  39     send_mail(subject, message, from_email=None,
  40               recipient_list=recipients, fail_silently=True)
  41 
  42 
  43 @receiver(tp_init_failed_async, sender=TranslationProject)
  44 def tp_init_failed_async(instance, **kwargs):
  45     ctx = {"tp": instance}
  46     message = render_to_string(
  47         'projects/admin/email/translation_project_creation_failed.txt', ctx)
  48     subject = _(u"Translation project (%s) creation failed" % instance)
  49     recipients = get_recipients(instance.project)
  50     send_mail(subject, message, from_email=None,
  51               recipient_list=recipients, fail_silently=True)
  52
  [end of pootle/apps/pootle_translationproject/receivers.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pootle/apps/pootle_translationproject/receivers.py b/pootle/apps/pootle_translationproject/receivers.py
  --- a/pootle/apps/pootle_translationproject/receivers.py
  +++ b/pootle/apps/pootle_translationproject/receivers.py
  @@ -8,12 +8,12 @@
   # AUTHORS file for copyright and authorship information.
   
   from django.contrib.auth import get_user_model
  -from django.core.mail import send_mail
   from django.db.models import Q
   from django.dispatch import receiver
   from django.template.loader import render_to_string
   from django.utils.translation import ugettext_lazy as _
   
  +from pootle.core.mail import send_mail
   from pootle.core.url_helpers import urljoin
   
   from .models import TranslationProject
  @@ -37,7 +37,7 @@
       subject = _(u"Translation project (%s) created" % instance)
       recipients = get_recipients(instance.project)
       send_mail(subject, message, from_email=None,
  -              recipient_list=recipients, fail_silently=True)
  +              recipient_list=[], fail_silently=True, bcc=recipients)
   
   
   @receiver(tp_init_failed_async, sender=TranslationProject)
  @@ -48,4 +48,4 @@
       subject = _(u"Translation project (%s) creation failed" % instance)
       recipients = get_recipients(instance.project)
       send_mail(subject, message, from_email=None,
  -              recipient_list=recipients, fail_silently=True)
  +              recipient_list=[], fail_silently=True, bcc=recipients)
  diff --git a/pootle/core/mail.py b/pootle/core/mail.py
  --- a/pootle/core/mail.py
  +++ b/pootle/core/mail.py
  @@ -11,7 +11,8 @@
   
   def send_mail(subject, message, from_email, recipient_list,
                 fail_silently=False, auth_user=None, auth_password=None,
  -              connection=None, html_message=None, headers=None):
  +              connection=None, html_message=None, headers=None,
  +              cc=None, bcc=None):
       """Override django send_mail function to allow use of custom email headers.
       """
   
  @@ -21,7 +22,8 @@
   
       mail = EmailMultiAlternatives(subject, message,
                                     from_email, recipient_list,
  -                                  connection=connection, headers=headers)
  +                                  connection=connection, headers=headers,
  +                                  cc=cc, bcc=bcc)
   
       if html_message:
           mail.attach_alternative(html_message, 'text/html')
  
verification_info: {"golden_diff": "diff --git a/pootle/apps/pootle_translationproject/receivers.py b/pootle/apps/pootle_translationproject/receivers.py\n--- a/pootle/apps/pootle_translationproject/receivers.py\n+++ b/pootle/apps/pootle_translationproject/receivers.py\n@@ -8,12 +8,12 @@\n # AUTHORS file for copyright and authorship information.\n \n from django.contrib.auth import get_user_model\n-from django.core.mail import send_mail\n from django.db.models import Q\n from django.dispatch import receiver\n from django.template.loader import render_to_string\n from django.utils.translation import ugettext_lazy as _\n \n+from pootle.core.mail import send_mail\n from pootle.core.url_helpers import urljoin\n \n from .models import TranslationProject\n@@ -37,7 +37,7 @@\n     subject = _(u\"Translation project (%s) created\" % instance)\n     recipients = get_recipients(instance.project)\n     send_mail(subject, message, from_email=None,\n-              recipient_list=recipients, fail_silently=True)\n+              recipient_list=[], fail_silently=True, bcc=recipients)\n \n \n @receiver(tp_init_failed_async, sender=TranslationProject)\n@@ -48,4 +48,4 @@\n     subject = _(u\"Translation project (%s) creation failed\" % instance)\n     recipients = get_recipients(instance.project)\n     send_mail(subject, message, from_email=None,\n-              recipient_list=recipients, fail_silently=True)\n+              recipient_list=[], fail_silently=True, bcc=recipients)\ndiff --git a/pootle/core/mail.py b/pootle/core/mail.py\n--- a/pootle/core/mail.py\n+++ b/pootle/core/mail.py\n@@ -11,7 +11,8 @@\n \n def send_mail(subject, message, from_email, recipient_list,\n               fail_silently=False, auth_user=None, auth_password=None,\n-              connection=None, html_message=None, headers=None):\n+              connection=None, html_message=None, headers=None,\n+              cc=None, bcc=None):\n     \"\"\"Override django send_mail function to allow use of custom email headers.\n     \"\"\"\n \n@@ -21,7 +22,8 @@\n \n     mail = EmailMultiAlternatives(subject, message,\n                                   from_email, recipient_list,\n-                                  connection=connection, headers=headers)\n+                                  connection=connection, headers=headers,\n+                                  cc=cc, bcc=bcc)\n \n     if html_message:\n         mail.attach_alternative(html_message, 'text/html')\n", "issue": "TP creation email should use BCC\nLet's BCC by default when Pootle is communicating to lists of people.  When you create a TP all relevant people are listed in the To field.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nfrom django.core.mail import EmailMultiAlternatives, get_connection\n\n\ndef send_mail(subject, message, from_email, recipient_list,\n              fail_silently=False, auth_user=None, auth_password=None,\n              connection=None, html_message=None, headers=None):\n    \"\"\"Override django send_mail function to allow use of custom email headers.\n    \"\"\"\n\n    connection = connection or get_connection(username=auth_user,\n                                              password=auth_password,\n                                              fail_silently=fail_silently)\n\n    mail = EmailMultiAlternatives(subject, message,\n                                  from_email, recipient_list,\n                                  connection=connection, headers=headers)\n\n    if html_message:\n        mail.attach_alternative(html_message, 'text/html')\n\n    return mail.send()\n", "path": "pootle/core/mail.py"}, {"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nfrom django.contrib.auth import get_user_model\nfrom django.core.mail import send_mail\nfrom django.db.models import Q\nfrom django.dispatch import receiver\nfrom django.template.loader import render_to_string\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom pootle.core.url_helpers import urljoin\n\nfrom .models import TranslationProject\nfrom .signals import tp_init_failed_async, tp_inited_async\n\n\ndef get_recipients(project):\n    User = get_user_model()\n    return list(set(User.objects.filter(\n        Q(permissionset__positive_permissions__codename=\"administrate\",\n          permissionset__directory__pootle_path=project.pootle_path) |\n        Q(is_superuser=True)).values_list(\"email\", flat=True)))\n\n\n@receiver(tp_inited_async, sender=TranslationProject)\ndef tp_inited_async(instance, response_url, **kwargs):\n    ctx = {\"tp\": instance,\n           \"url\": urljoin(response_url, instance.get_absolute_url())}\n    message = render_to_string(\n        'projects/admin/email/translation_project_created.txt', ctx)\n    subject = _(u\"Translation project (%s) created\" % instance)\n    recipients = get_recipients(instance.project)\n    send_mail(subject, message, from_email=None,\n              recipient_list=recipients, fail_silently=True)\n\n\n@receiver(tp_init_failed_async, sender=TranslationProject)\ndef tp_init_failed_async(instance, **kwargs):\n    ctx = {\"tp\": instance}\n    message = render_to_string(\n        'projects/admin/email/translation_project_creation_failed.txt', ctx)\n    subject = _(u\"Translation project (%s) creation failed\" % instance)\n    recipients = get_recipients(instance.project)\n    send_mail(subject, message, from_email=None,\n              recipient_list=recipients, fail_silently=True)\n", "path": "pootle/apps/pootle_translationproject/receivers.py"}]}