prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Verify email addresses after E-Mail change
  When a user changes their email address, it should be verified. allauth provides some views for that which may or may not be useful. Unsure whether email addresses currently are verified at signup, but it would be appropriate for it to use the same mechanism.
  
  
  </issue>
  <code>
  [start of nextcloudappstore/user/views.py]
  1 from allauth.account.models import EmailAddress
  2 from allauth.account.views import PasswordChangeView
  3 from django.contrib import messages
  4 from django.contrib.auth.mixins import LoginRequiredMixin
  5 from django.urls import reverse_lazy
  6 from django.shortcuts import redirect, render, get_object_or_404
  7 from django.urls import reverse
  8 from django.views.generic import TemplateView
  9 from django.views.generic import UpdateView
  10 
  11 from nextcloudappstore.core.models import App
  12 from nextcloudappstore.user.forms import DeleteAccountForm, AccountForm
  13 
  14 
  15 class TransferAppsView(LoginRequiredMixin, TemplateView):
  16     template_name = 'user/transfer-apps.html'
  17 
  18     def post(self, request, pk):
  19         app = get_object_or_404(App, pk=pk, owner=self.request.user)
  20         app.ownership_transfer_enabled = not app.ownership_transfer_enabled
  21         app.save()
  22         return redirect(reverse('user:account-transfer-apps'))
  23 
  24     def get_context_data(self, **kwargs):
  25         context = super().get_context_data(**kwargs)
  26         context['apps'] = App.objects.filter(owner=self.request.user)
  27         context['acc_page'] = 'account-transfer-apps'
  28         return context
  29 
  30 
  31 class ChangeLanguageView(LoginRequiredMixin, TemplateView):
  32     template_name = 'user/set-language.html'
  33 
  34     def get_context_data(self, **kwargs):
  35         context = super().get_context_data(**kwargs)
  36         context['acc_page'] = 'account-change-language'
  37         return context
  38 
  39 
  40 class DeleteAccountView(LoginRequiredMixin, TemplateView):
  41     template_name = 'user/delete-account.html'
  42 
  43     def get_context_data(self, **kwargs):
  44         context = super().get_context_data(**kwargs)
  45         context['form'] = DeleteAccountForm()
  46         context['acc_page'] = 'delete-account'
  47         return context
  48 
  49     def post(self, request, *args, **kwargs):
  50         form = DeleteAccountForm(request.POST, user=request.user)
  51         if form.is_valid():
  52             request.user.delete()
  53             return redirect(reverse_lazy('home'))
  54         else:
  55             return render(request, self.template_name, {'form': form})
  56 
  57 
  58 class AccountView(LoginRequiredMixin, UpdateView):
  59     """Display and allow changing of the user's name."""
  60 
  61     template_name = 'user/account.html'
  62     template_name_suffix = ''
  63     form_class = AccountForm
  64     success_url = reverse_lazy('user:account')
  65 
  66     def get_context_data(self, **kwargs):
  67         context = super().get_context_data(**kwargs)
  68         context['acc_page'] = 'account'
  69         return context
  70 
  71     def form_valid(self, form):
  72         email = EmailAddress.objects.get_primary(user=self.request.user)
  73         email.email = form.cleaned_data['email']
  74         email.save()
  75         messages.success(self.request, 'Account details saved.')
  76         return super().form_valid(form)
  77 
  78     def get_object(self, queryset=None):
  79         return self.request.user
  80 
  81 
  82 class PasswordView(LoginRequiredMixin, PasswordChangeView):
  83     """Allow the user to change their password."""
  84 
  85     template_name = 'user/password.html'
  86     success_url = reverse_lazy('user:account-password')
  87 
  88     def get_context_data(self, **kwargs):
  89         context = super().get_context_data(**kwargs)
  90         context['acc_page'] = 'password'
  91         return context
  92 
  93 
  94 class APITokenView(LoginRequiredMixin, TemplateView):
  95     """Display the user's API token, and allow it to be regenerated."""
  96 
  97     template_name = 'user/api-token.html'
  98 
  99     def get_context_data(self, **kwargs):
  100         context = super().get_context_data(**kwargs)
  101         context['acc_page'] = 'api-token'
  102         return context
  103
  [end of nextcloudappstore/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/user/views.py b/nextcloudappstore/user/views.py
  --- a/nextcloudappstore/user/views.py
  +++ b/nextcloudappstore/user/views.py
  @@ -70,8 +70,7 @@
   
       def form_valid(self, form):
           email = EmailAddress.objects.get_primary(user=self.request.user)
  -        email.email = form.cleaned_data['email']
  -        email.save()
  +        email.change(None, form.cleaned_data['email'])
           messages.success(self.request, 'Account details saved.')
           return super().form_valid(form)
  
verification_info: {"golden_diff": "diff --git a/nextcloudappstore/user/views.py b/nextcloudappstore/user/views.py\n--- a/nextcloudappstore/user/views.py\n+++ b/nextcloudappstore/user/views.py\n@@ -70,8 +70,7 @@\n \n     def form_valid(self, form):\n         email = EmailAddress.objects.get_primary(user=self.request.user)\n-        email.email = form.cleaned_data['email']\n-        email.save()\n+        email.change(None, form.cleaned_data['email'])\n         messages.success(self.request, 'Account details saved.')\n         return super().form_valid(form)\n", "issue": "Verify email addresses after E-Mail change\nWhen a user changes their email address, it should be verified. allauth provides some views for that which may or may not be useful. Unsure whether email addresses currently are verified at signup, but it would be appropriate for it to use the same mechanism.\n\n", "before_files": [{"content": "from allauth.account.models import EmailAddress\nfrom allauth.account.views import PasswordChangeView\nfrom django.contrib import messages\nfrom django.contrib.auth.mixins import LoginRequiredMixin\nfrom django.urls import reverse_lazy\nfrom django.shortcuts import redirect, render, get_object_or_404\nfrom django.urls import reverse\nfrom django.views.generic import TemplateView\nfrom django.views.generic import UpdateView\n\nfrom nextcloudappstore.core.models import App\nfrom nextcloudappstore.user.forms import DeleteAccountForm, AccountForm\n\n\nclass TransferAppsView(LoginRequiredMixin, TemplateView):\n    template_name = 'user/transfer-apps.html'\n\n    def post(self, request, pk):\n        app = get_object_or_404(App, pk=pk, owner=self.request.user)\n        app.ownership_transfer_enabled = not app.ownership_transfer_enabled\n        app.save()\n        return redirect(reverse('user:account-transfer-apps'))\n\n    def get_context_data(self, **kwargs):\n        context = super().get_context_data(**kwargs)\n        context['apps'] = App.objects.filter(owner=self.request.user)\n        context['acc_page'] = 'account-transfer-apps'\n        return context\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    form_class = AccountForm\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        email = EmailAddress.objects.get_primary(user=self.request.user)\n        email.email = form.cleaned_data['email']\n        email.save()\n        messages.success(self.request, 'Account details 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/user/views.py"}]}