prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Refactorings for welcome HTML email 
  Based on https://github.com/mdn/kuma/pull/7866 
  we'll drop the `utm` query string things and we'll get rid of the plain text email template. 
  
  </issue>
  <code>
  [start of kuma/users/tasks.py]
  1 import logging
  2 
  3 from celery import task
  4 from django.conf import settings
  5 from django.contrib.auth import get_user_model
  6 from django.utils import translation
  7 from django.utils.translation import gettext_lazy as _
  8 
  9 from kuma.core.decorators import skip_in_maintenance_mode
  10 from kuma.core.email_utils import render_email
  11 from kuma.core.utils import (
  12     EmailMultiAlternativesRetrying,
  13     send_mail_retrying,
  14     strings_are_translated,
  15 )
  16 
  17 log = logging.getLogger("kuma.users.tasks")
  18 
  19 
  20 WELCOME_EMAIL_STRINGS = [
  21     "Like words?",
  22     "Don't be shy, if you have any doubt, problems, questions: contact us! We are here to help.",
  23 ]
  24 
  25 
  26 @task
  27 @skip_in_maintenance_mode
  28 def send_recovery_email(user_pk, email, locale=None):
  29     user = get_user_model().objects.get(pk=user_pk)
  30     locale = locale or settings.WIKI_DEFAULT_LANGUAGE
  31     url = settings.SITE_URL + user.get_recovery_url()
  32     context = {"recovery_url": url, "username": user.username}
  33     with translation.override(locale):
  34         subject = render_email("users/email/recovery/subject.ltxt", context)
  35         # Email subject *must not* contain newlines
  36         subject = "".join(subject.splitlines())
  37         plain = render_email("users/email/recovery/plain.ltxt", context)
  38         send_mail_retrying(subject, plain, settings.DEFAULT_FROM_EMAIL, [email])
  39 
  40 
  41 @task
  42 @skip_in_maintenance_mode
  43 def send_welcome_email(user_pk, locale):
  44     user = get_user_model().objects.get(pk=user_pk)
  45     if locale == settings.WIKI_DEFAULT_LANGUAGE or strings_are_translated(
  46         WELCOME_EMAIL_STRINGS, locale
  47     ):
  48         context = {"username": user.username}
  49         log.debug("Using the locale %s to send the welcome email", locale)
  50         with translation.override(locale):
  51             content_plain = render_email("users/email/welcome/plain.ltxt", context)
  52             content_html = render_email("users/email/welcome/html.ltxt", context)
  53 
  54             email = EmailMultiAlternativesRetrying(
  55                 _("Getting started with your new MDN account"),
  56                 content_plain,
  57                 settings.WELCOME_EMAIL_FROM,
  58                 [user.email],
  59             )
  60             email.attach_alternative(content_html, "text/html")
  61             email.send()
  62
  [end of kuma/users/tasks.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/kuma/users/tasks.py b/kuma/users/tasks.py
  --- a/kuma/users/tasks.py
  +++ b/kuma/users/tasks.py
  @@ -5,6 +5,7 @@
   from django.contrib.auth import get_user_model
   from django.utils import translation
   from django.utils.translation import gettext_lazy as _
  +from pyquery import PyQuery as pq
   
   from kuma.core.decorators import skip_in_maintenance_mode
   from kuma.core.email_utils import render_email
  @@ -48,8 +49,18 @@
           context = {"username": user.username}
           log.debug("Using the locale %s to send the welcome email", locale)
           with translation.override(locale):
  -            content_plain = render_email("users/email/welcome/plain.ltxt", context)
               content_html = render_email("users/email/welcome/html.ltxt", context)
  +            doc = pq(content_html)
  +            urls = []
  +            for i, link in enumerate(doc("body a[href]").items()):
  +                link.text(f"{link.text()}[{i + 1}]")
  +                urls.append((i + 1, link.attr("href")))
  +
  +            content_plain = doc("body").text().replace("\n", "\n\n")
  +            if urls:
  +                content_plain += "\n\n"
  +                for i, url in urls:
  +                    content_plain += f"[{i}] {url}\n"
   
               email = EmailMultiAlternativesRetrying(
                   _("Getting started with your new MDN account"),
  
verification_info: {"golden_diff": "diff --git a/kuma/users/tasks.py b/kuma/users/tasks.py\n--- a/kuma/users/tasks.py\n+++ b/kuma/users/tasks.py\n@@ -5,6 +5,7 @@\n from django.contrib.auth import get_user_model\n from django.utils import translation\n from django.utils.translation import gettext_lazy as _\n+from pyquery import PyQuery as pq\n \n from kuma.core.decorators import skip_in_maintenance_mode\n from kuma.core.email_utils import render_email\n@@ -48,8 +49,18 @@\n         context = {\"username\": user.username}\n         log.debug(\"Using the locale %s to send the welcome email\", locale)\n         with translation.override(locale):\n-            content_plain = render_email(\"users/email/welcome/plain.ltxt\", context)\n             content_html = render_email(\"users/email/welcome/html.ltxt\", context)\n+            doc = pq(content_html)\n+            urls = []\n+            for i, link in enumerate(doc(\"body a[href]\").items()):\n+                link.text(f\"{link.text()}[{i + 1}]\")\n+                urls.append((i + 1, link.attr(\"href\")))\n+\n+            content_plain = doc(\"body\").text().replace(\"\\n\", \"\\n\\n\")\n+            if urls:\n+                content_plain += \"\\n\\n\"\n+                for i, url in urls:\n+                    content_plain += f\"[{i}] {url}\\n\"\n \n             email = EmailMultiAlternativesRetrying(\n                 _(\"Getting started with your new MDN account\"),\n", "issue": "Refactorings for welcome HTML email \nBased on https://github.com/mdn/kuma/pull/7866 \r\nwe'll drop the `utm` query string things and we'll get rid of the plain text email template. \n", "before_files": [{"content": "import logging\n\nfrom celery import task\nfrom django.conf import settings\nfrom django.contrib.auth import get_user_model\nfrom django.utils import translation\nfrom django.utils.translation import gettext_lazy as _\n\nfrom kuma.core.decorators import skip_in_maintenance_mode\nfrom kuma.core.email_utils import render_email\nfrom kuma.core.utils import (\n    EmailMultiAlternativesRetrying,\n    send_mail_retrying,\n    strings_are_translated,\n)\n\nlog = logging.getLogger(\"kuma.users.tasks\")\n\n\nWELCOME_EMAIL_STRINGS = [\n    \"Like words?\",\n    \"Don't be shy, if you have any doubt, problems, questions: contact us! We are here to help.\",\n]\n\n\n@task\n@skip_in_maintenance_mode\ndef send_recovery_email(user_pk, email, locale=None):\n    user = get_user_model().objects.get(pk=user_pk)\n    locale = locale or settings.WIKI_DEFAULT_LANGUAGE\n    url = settings.SITE_URL + user.get_recovery_url()\n    context = {\"recovery_url\": url, \"username\": user.username}\n    with translation.override(locale):\n        subject = render_email(\"users/email/recovery/subject.ltxt\", context)\n        # Email subject *must not* contain newlines\n        subject = \"\".join(subject.splitlines())\n        plain = render_email(\"users/email/recovery/plain.ltxt\", context)\n        send_mail_retrying(subject, plain, settings.DEFAULT_FROM_EMAIL, [email])\n\n\n@task\n@skip_in_maintenance_mode\ndef send_welcome_email(user_pk, locale):\n    user = get_user_model().objects.get(pk=user_pk)\n    if locale == settings.WIKI_DEFAULT_LANGUAGE or strings_are_translated(\n        WELCOME_EMAIL_STRINGS, locale\n    ):\n        context = {\"username\": user.username}\n        log.debug(\"Using the locale %s to send the welcome email\", locale)\n        with translation.override(locale):\n            content_plain = render_email(\"users/email/welcome/plain.ltxt\", context)\n            content_html = render_email(\"users/email/welcome/html.ltxt\", context)\n\n            email = EmailMultiAlternativesRetrying(\n                _(\"Getting started with your new MDN account\"),\n                content_plain,\n                settings.WELCOME_EMAIL_FROM,\n                [user.email],\n            )\n            email.attach_alternative(content_html, \"text/html\")\n            email.send()\n", "path": "kuma/users/tasks.py"}]}