prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Translation of the Report Email
  I would like to translate the words of the report email, if you could integrate this kind of template on the po file, it would be amazing... naturally title of the email included, which it would be `[(name-site)] Unit #(num) ((lang))`
  
  ```
  Username: (username)
  Current URL: (url)
  IP address: (ip_address)
  User-Agent: (user_agent)
  
  Unit: (url_string)
  
  Source: (source_string)
  
  Current translation: 
  
  Your question or comment:
  ```
  
  Thx in advance ;)
  
  
  </issue>
  <code>
  [start of pootle/apps/contact/views.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.core.urlresolvers import reverse
  11 from django.views.generic import TemplateView
  12 
  13 from contact_form.views import ContactFormView as OriginalContactFormView
  14 
  15 from pootle.core.views import AjaxResponseMixin
  16 
  17 from .forms import ContactForm, ReportForm
  18 
  19 
  20 SUBJECT_TEMPLATE = 'Unit #%d (%s)'
  21 BODY_TEMPLATE = '''
  22 Unit: %s
  23 
  24 Source: %s
  25 
  26 Current translation: %s
  27 
  28 Your question or comment:
  29 '''
  30 
  31 
  32 class ContactFormTemplateView(TemplateView):
  33     template_name = 'contact_form/contact_form.html'
  34 
  35 
  36 class ContactFormView(AjaxResponseMixin, OriginalContactFormView):
  37     form_class = ContactForm
  38     template_name = 'contact_form/xhr_contact_form.html'
  39 
  40     def get_context_data(self, **kwargs):
  41         ctx = super(ContactFormView, self).get_context_data(**kwargs)
  42         # Provide the form action URL to use in the template that renders the
  43         # contact dialog.
  44         ctx.update({
  45             'contact_form_url': reverse('pootle-contact-xhr'),
  46         })
  47         return ctx
  48 
  49     def get_initial(self):
  50         initial = super(ContactFormView, self).get_initial()
  51 
  52         user = self.request.user
  53         if user.is_authenticated():
  54             initial.update({
  55                 'name': user.full_name,
  56                 'email': user.email,
  57             })
  58 
  59         return initial
  60 
  61     def get_success_url(self):
  62         # XXX: This is unused. We don't need a `/contact/sent/` URL, but
  63         # the parent :cls:`ContactView` enforces us to set some value here
  64         return reverse('pootle-contact')
  65 
  66 
  67 class ReportFormView(ContactFormView):
  68     form_class = ReportForm
  69 
  70     def get_context_data(self, **kwargs):
  71         ctx = super(ReportFormView, self).get_context_data(**kwargs)
  72         # Provide the form action URL to use in the template that renders the
  73         # contact dialog.
  74         ctx.update({
  75             'contact_form_url': reverse('pootle-contact-report-error'),
  76         })
  77         return ctx
  78 
  79     def get_initial(self):
  80         initial = super(ReportFormView, self).get_initial()
  81 
  82         report = self.request.GET.get('report', False)
  83         if report:
  84             try:
  85                 from pootle_store.models import Unit
  86                 uid = int(report)
  87                 try:
  88                     unit = Unit.objects.select_related(
  89                         'store__translation_project__project',
  90                     ).get(id=uid)
  91                     if unit.is_accessible_by(self.request.user):
  92                         unit_absolute_url = self.request.build_absolute_uri(
  93                                 unit.get_translate_url()
  94                             )
  95                         initial.update({
  96                             'subject': SUBJECT_TEMPLATE % (
  97                                 unit.id,
  98                                 unit.store.translation_project.language.code
  99                             ),
  100                             'body': BODY_TEMPLATE % (
  101                                 unit_absolute_url,
  102                                 unit.source,
  103                                 unit.target
  104                             ),
  105                             'report_email': unit.store.translation_project \
  106                                                       .project.report_email,
  107                         })
  108                 except Unit.DoesNotExist:
  109                     pass
  110             except ValueError:
  111                 pass
  112 
  113         return initial
  114
  [end of pootle/apps/contact/views.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/contact/views.py b/pootle/apps/contact/views.py
  --- a/pootle/apps/contact/views.py
  +++ b/pootle/apps/contact/views.py
  @@ -8,6 +8,7 @@
   # AUTHORS file for copyright and authorship information.
   
   from django.core.urlresolvers import reverse
  +from django.template.loader import render_to_string
   from django.views.generic import TemplateView
   
   from contact_form.views import ContactFormView as OriginalContactFormView
  @@ -17,18 +18,6 @@
   from .forms import ContactForm, ReportForm
   
   
  -SUBJECT_TEMPLATE = 'Unit #%d (%s)'
  -BODY_TEMPLATE = '''
  -Unit: %s
  -
  -Source: %s
  -
  -Current translation: %s
  -
  -Your question or comment:
  -'''
  -
  -
   class ContactFormTemplateView(TemplateView):
       template_name = 'contact_form/contact_form.html'
   
  @@ -93,15 +82,18 @@
                                   unit.get_translate_url()
                               )
                           initial.update({
  -                            'subject': SUBJECT_TEMPLATE % (
  -                                unit.id,
  -                                unit.store.translation_project.language.code
  -                            ),
  -                            'body': BODY_TEMPLATE % (
  -                                unit_absolute_url,
  -                                unit.source,
  -                                unit.target
  -                            ),
  +                            'subject': render_to_string(
  +                                'contact_form/report_form_subject.txt', {
  +                                    'unit': unit,
  +                                    'language': unit.store \
  +                                                    .translation_project \
  +                                                    .language.code,
  +                            }),
  +                            'body': render_to_string(
  +                                'contact_form/report_form_body.txt', {
  +                                    'unit': unit,
  +                                    'unit_absolute_url': unit_absolute_url,
  +                            }),
                               'report_email': unit.store.translation_project \
                                                         .project.report_email,
                           })
  
verification_info: {"golden_diff": "diff --git a/pootle/apps/contact/views.py b/pootle/apps/contact/views.py\n--- a/pootle/apps/contact/views.py\n+++ b/pootle/apps/contact/views.py\n@@ -8,6 +8,7 @@\n # AUTHORS file for copyright and authorship information.\n \n from django.core.urlresolvers import reverse\n+from django.template.loader import render_to_string\n from django.views.generic import TemplateView\n \n from contact_form.views import ContactFormView as OriginalContactFormView\n@@ -17,18 +18,6 @@\n from .forms import ContactForm, ReportForm\n \n \n-SUBJECT_TEMPLATE = 'Unit #%d (%s)'\n-BODY_TEMPLATE = '''\n-Unit: %s\n-\n-Source: %s\n-\n-Current translation: %s\n-\n-Your question or comment:\n-'''\n-\n-\n class ContactFormTemplateView(TemplateView):\n     template_name = 'contact_form/contact_form.html'\n \n@@ -93,15 +82,18 @@\n                                 unit.get_translate_url()\n                             )\n                         initial.update({\n-                            'subject': SUBJECT_TEMPLATE % (\n-                                unit.id,\n-                                unit.store.translation_project.language.code\n-                            ),\n-                            'body': BODY_TEMPLATE % (\n-                                unit_absolute_url,\n-                                unit.source,\n-                                unit.target\n-                            ),\n+                            'subject': render_to_string(\n+                                'contact_form/report_form_subject.txt', {\n+                                    'unit': unit,\n+                                    'language': unit.store \\\n+                                                    .translation_project \\\n+                                                    .language.code,\n+                            }),\n+                            'body': render_to_string(\n+                                'contact_form/report_form_body.txt', {\n+                                    'unit': unit,\n+                                    'unit_absolute_url': unit_absolute_url,\n+                            }),\n                             'report_email': unit.store.translation_project \\\n                                                       .project.report_email,\n                         })\n", "issue": "Translation of the Report Email\nI would like to translate the words of the report email, if you could integrate this kind of template on the po file, it would be amazing... naturally title of the email included, which it would be `[(name-site)] Unit #(num) ((lang))`\n\n```\nUsername: (username)\nCurrent URL: (url)\nIP address: (ip_address)\nUser-Agent: (user_agent)\n\nUnit: (url_string)\n\nSource: (source_string)\n\nCurrent translation: \n\nYour question or comment:\n```\n\nThx in advance ;)\n\n", "before_files": [{"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.core.urlresolvers import reverse\nfrom django.views.generic import TemplateView\n\nfrom contact_form.views import ContactFormView as OriginalContactFormView\n\nfrom pootle.core.views import AjaxResponseMixin\n\nfrom .forms import ContactForm, ReportForm\n\n\nSUBJECT_TEMPLATE = 'Unit #%d (%s)'\nBODY_TEMPLATE = '''\nUnit: %s\n\nSource: %s\n\nCurrent translation: %s\n\nYour question or comment:\n'''\n\n\nclass ContactFormTemplateView(TemplateView):\n    template_name = 'contact_form/contact_form.html'\n\n\nclass ContactFormView(AjaxResponseMixin, OriginalContactFormView):\n    form_class = ContactForm\n    template_name = 'contact_form/xhr_contact_form.html'\n\n    def get_context_data(self, **kwargs):\n        ctx = super(ContactFormView, self).get_context_data(**kwargs)\n        # Provide the form action URL to use in the template that renders the\n        # contact dialog.\n        ctx.update({\n            'contact_form_url': reverse('pootle-contact-xhr'),\n        })\n        return ctx\n\n    def get_initial(self):\n        initial = super(ContactFormView, self).get_initial()\n\n        user = self.request.user\n        if user.is_authenticated():\n            initial.update({\n                'name': user.full_name,\n                'email': user.email,\n            })\n\n        return initial\n\n    def get_success_url(self):\n        # XXX: This is unused. We don't need a `/contact/sent/` URL, but\n        # the parent :cls:`ContactView` enforces us to set some value here\n        return reverse('pootle-contact')\n\n\nclass ReportFormView(ContactFormView):\n    form_class = ReportForm\n\n    def get_context_data(self, **kwargs):\n        ctx = super(ReportFormView, self).get_context_data(**kwargs)\n        # Provide the form action URL to use in the template that renders the\n        # contact dialog.\n        ctx.update({\n            'contact_form_url': reverse('pootle-contact-report-error'),\n        })\n        return ctx\n\n    def get_initial(self):\n        initial = super(ReportFormView, self).get_initial()\n\n        report = self.request.GET.get('report', False)\n        if report:\n            try:\n                from pootle_store.models import Unit\n                uid = int(report)\n                try:\n                    unit = Unit.objects.select_related(\n                        'store__translation_project__project',\n                    ).get(id=uid)\n                    if unit.is_accessible_by(self.request.user):\n                        unit_absolute_url = self.request.build_absolute_uri(\n                                unit.get_translate_url()\n                            )\n                        initial.update({\n                            'subject': SUBJECT_TEMPLATE % (\n                                unit.id,\n                                unit.store.translation_project.language.code\n                            ),\n                            'body': BODY_TEMPLATE % (\n                                unit_absolute_url,\n                                unit.source,\n                                unit.target\n                            ),\n                            'report_email': unit.store.translation_project \\\n                                                      .project.report_email,\n                        })\n                except Unit.DoesNotExist:\n                    pass\n            except ValueError:\n                pass\n\n        return initial\n", "path": "pootle/apps/contact/views.py"}]}