prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Email change form
  Among the account pages should be a page from which a user can change their email address. The email field on the `User` model needs to be updated and a correspondig django-allauth `EmailAddress` object should be associated with the user. django-allauth supports multiple email addresses per user, but we only want one. New email addresses should be verified with [this](http://django-allauth.readthedocs.io/en/latest/views.html#e-mail-verification). The page should be located at `/account/email/`.
  
  @BernhardPosselt Do you agree with the above?
  
  
  </issue>
  <code>
  [start of nextcloudappstore/core/user/views.py]
  1 from allauth.account.views import PasswordChangeView
  2 from django.contrib import messages
  3 from django.contrib.auth.mixins import LoginRequiredMixin
  4 from django.contrib.auth.models import User
  5 from django.core.urlresolvers import reverse_lazy
  6 from django.shortcuts import redirect, render
  7 from django.views.generic import TemplateView
  8 from django.views.generic import UpdateView
  9 
  10 from nextcloudappstore.core.user.forms import DeleteAccountForm
  11 
  12 
  13 class ChangeLanguageView(LoginRequiredMixin, TemplateView):
  14     template_name = 'user/set-language.html'
  15 
  16     def get_context_data(self, **kwargs):
  17         context = super().get_context_data(**kwargs)
  18         context['acc_page'] = 'account-change-language'
  19         return context
  20 
  21 
  22 class DeleteAccountView(LoginRequiredMixin, TemplateView):
  23     template_name = 'user/delete-account.html'
  24 
  25     def get_context_data(self, **kwargs):
  26         context = super().get_context_data(**kwargs)
  27         context['form'] = DeleteAccountForm()
  28         context['acc_page'] = 'delete-account'
  29         return context
  30 
  31     def post(self, request, *args, **kwargs):
  32         form = DeleteAccountForm(request.POST, user=request.user)
  33         if form.is_valid():
  34             request.user.delete()
  35             return redirect(reverse_lazy('home'))
  36         else:
  37             return render(request, self.template_name, {'form': form})
  38 
  39 
  40 class AccountView(LoginRequiredMixin, UpdateView):
  41     """Display and allow changing of the user's name."""
  42 
  43     template_name = 'user/account.html'
  44     template_name_suffix = ''
  45     model = User
  46     fields = ['first_name', 'last_name']
  47     success_url = reverse_lazy('user:account')
  48 
  49     def get_context_data(self, **kwargs):
  50         context = super().get_context_data(**kwargs)
  51         context['acc_page'] = 'account'
  52         return context
  53 
  54     def form_valid(self, form):
  55         messages.success(self.request, 'Name saved.')
  56         return super().form_valid(form)
  57 
  58     def get_object(self, queryset=None):
  59         return self.request.user
  60 
  61 
  62 class PasswordView(LoginRequiredMixin, PasswordChangeView):
  63     """Allow the user to change their password."""
  64 
  65     template_name = 'user/password.html'
  66     success_url = reverse_lazy('user:account-password')
  67 
  68     def get_context_data(self, **kwargs):
  69         context = super().get_context_data(**kwargs)
  70         context['acc_page'] = 'password'
  71         return context
  72 
  73 
  74 class APITokenView(LoginRequiredMixin, TemplateView):
  75     """Display the user's API token, and allow it to be regenerated."""
  76 
  77     template_name = 'user/api-token.html'
  78 
  79     def get_context_data(self, **kwargs):
  80         context = super().get_context_data(**kwargs)
  81         context['acc_page'] = 'api-token'
  82         return context
  83
  [end of nextcloudappstore/core/user/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/nextcloudappstore/core/user/views.py b/nextcloudappstore/core/user/views.py
  --- a/nextcloudappstore/core/user/views.py
  +++ b/nextcloudappstore/core/user/views.py
  @@ -43,7 +43,7 @@
       template_name = 'user/account.html'
       template_name_suffix = ''
       model = User
  -    fields = ['first_name', 'last_name']
  +    fields = ['first_name', 'last_name', 'email']
       success_url = reverse_lazy('user:account')
   
       def get_context_data(self, **kwargs):
  @@ -52,7 +52,7 @@
           return context
   
       def form_valid(self, form):
  -        messages.success(self.request, 'Name saved.')
  +        messages.success(self.request, 'Account details saved.')
           return super().form_valid(form)
   
       def get_object(self, queryset=None):
  
verification_info: {"golden_diff": "diff --git a/nextcloudappstore/core/user/views.py b/nextcloudappstore/core/user/views.py\n--- a/nextcloudappstore/core/user/views.py\n+++ b/nextcloudappstore/core/user/views.py\n@@ -43,7 +43,7 @@\n     template_name = 'user/account.html'\n     template_name_suffix = ''\n     model = User\n-    fields = ['first_name', 'last_name']\n+    fields = ['first_name', 'last_name', 'email']\n     success_url = reverse_lazy('user:account')\n \n     def get_context_data(self, **kwargs):\n@@ -52,7 +52,7 @@\n         return context\n \n     def form_valid(self, form):\n-        messages.success(self.request, 'Name saved.')\n+        messages.success(self.request, 'Account details saved.')\n         return super().form_valid(form)\n \n     def get_object(self, queryset=None):\n", "issue": "Email change form\nAmong the account pages should be a page from which a user can change their email address. The email field on the `User` model needs to be updated and a correspondig django-allauth `EmailAddress` object should be associated with the user. django-allauth supports multiple email addresses per user, but we only want one. New email addresses should be verified with [this](http://django-allauth.readthedocs.io/en/latest/views.html#e-mail-verification). The page should be located at `/account/email/`.\n\n@BernhardPosselt Do you agree with the above?\n\n", "before_files": [{"content": "from allauth.account.views import PasswordChangeView\nfrom django.contrib import messages\nfrom django.contrib.auth.mixins import LoginRequiredMixin\nfrom django.contrib.auth.models import User\nfrom django.core.urlresolvers import reverse_lazy\nfrom django.shortcuts import redirect, render\nfrom django.views.generic import TemplateView\nfrom django.views.generic import UpdateView\n\nfrom nextcloudappstore.core.user.forms import DeleteAccountForm\n\n\nclass ChangeLanguageView(LoginRequiredMixin, TemplateView):\n    template_name = 'user/set-language.html'\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['acc_page'] = 'account-change-language'\n        return context\n\n\nclass DeleteAccountView(LoginRequiredMixin, TemplateView):\n    template_name = 'user/delete-account.html'\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['form'] = DeleteAccountForm()\n        context['acc_page'] = 'delete-account'\n        return context\n\n    def post(self, request, *args, **kwargs):\n        form = DeleteAccountForm(request.POST, user=request.user)\n        if form.is_valid():\n            request.user.delete()\n            return redirect(reverse_lazy('home'))\n        else:\n            return render(request, self.template_name, {'form': form})\n\n\nclass AccountView(LoginRequiredMixin, UpdateView):\n    \"\"\"Display and allow changing of the user's name.\"\"\"\n\n    template_name = 'user/account.html'\n    template_name_suffix = ''\n    model = User\n    fields = ['first_name', 'last_name']\n    success_url = reverse_lazy('user:account')\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['acc_page'] = 'account'\n        return context\n\n    def form_valid(self, form):\n        messages.success(self.request, 'Name saved.')\n        return super().form_valid(form)\n\n    def get_object(self, queryset=None):\n        return self.request.user\n\n\nclass PasswordView(LoginRequiredMixin, PasswordChangeView):\n    \"\"\"Allow the user to change their password.\"\"\"\n\n    template_name = 'user/password.html'\n    success_url = reverse_lazy('user:account-password')\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['acc_page'] = 'password'\n        return context\n\n\nclass APITokenView(LoginRequiredMixin, TemplateView):\n    \"\"\"Display the user's API token, and allow it to be regenerated.\"\"\"\n\n    template_name = 'user/api-token.html'\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['acc_page'] = 'api-token'\n        return context\n", "path": "nextcloudappstore/core/user/views.py"}]}