prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  get_newsletters during normal register is broken
  If checked, the user still has get_newsletters = False. But when changed in the account settings, it's changed.
  
  </issue>
  <code>
  [start of apps/users/forms.py]
  1 from allauth.socialaccount.adapter import get_adapter
  2 from allauth.utils import email_address_exists
  3 from django import forms
  4 from django.contrib.auth import forms as auth_forms
  5 from django.contrib.auth import get_user_model
  6 from django.utils.translation import ugettext_lazy as _
  7 
  8 User = get_user_model()
  9 
  10 
  11 class TermsSignupForm(auth_forms.UserCreationForm):
  12     terms_of_use = forms.BooleanField(label=_('Terms of use'), error_messages={
  13         'required': _('Please accept the terms of use.')
  14     })
  15 
  16     def signup(self, request, user):
  17         user.signup(
  18             self.cleaned_data['username'],
  19             self.cleaned_data['email'],
  20         )
  21 
  22     class Meta:
  23         model = User
  24         fields = ('email', 'username', 'password1', 'password2',
  25                   'terms_of_use', 'get_newsletters')
  26 
  27 # Tried to add form as described in allauth documentation:
  28 # https://django-allauth.readthedocs.io/en/latest/forms.html#socialaccount-forms
  29 # ran into the following error:
  30 # https://stackoverflow.com/questions/57254251/custom-form-with-socialaccount-in-django-allauth
  31 # added this solution, maybe not the best
  32 
  33 
  34 class SignupForm(forms.Form):
  35     terms_of_use = forms.BooleanField(label=_('Terms of use'), error_messages={
  36         'required': _('Please accept the terms of use.')
  37     })
  38     get_newsletters = forms.BooleanField(
  39         label=_('Send me newsletters'), required=False)
  40     email = forms.EmailField(widget=forms.HiddenInput())
  41     username = forms.CharField(widget=forms.HiddenInput())
  42 
  43     def __init__(self, *args, **kwargs):
  44         self.sociallogin = kwargs.pop('sociallogin')
  45         initial = get_adapter().get_signup_form_initial_data(
  46             self.sociallogin)
  47         kwargs.update({
  48             'initial': initial})
  49         super().__init__(*args, **kwargs)
  50 
  51     def save(self, request):
  52         adapter = get_adapter(request)
  53         user = adapter.save_user(request, self.sociallogin, form=self)
  54         user.get_newsletters = self.cleaned_data['get_newsletters']
  55         user.save()
  56         user.signup(
  57             user.username,
  58             user.email
  59         )
  60         return user
  61 
  62     def clean(self):
  63         email = self.cleaned_data['email']
  64         if email_address_exists(email):
  65             raise forms.ValidationError(
  66                 get_adapter().error_messages['email_taken']
  67                 % self.sociallogin.account.get_provider().name)
  68         return super().clean()
  69
  [end of apps/users/forms.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/apps/users/forms.py b/apps/users/forms.py
  --- a/apps/users/forms.py
  +++ b/apps/users/forms.py
  @@ -14,6 +14,7 @@
       })
   
       def signup(self, request, user):
  +        user.get_newsletters = self.cleaned_data["get_newsletters"]
           user.signup(
               self.cleaned_data['username'],
               self.cleaned_data['email'],
  
verification_info: {"golden_diff": "diff --git a/apps/users/forms.py b/apps/users/forms.py\n--- a/apps/users/forms.py\n+++ b/apps/users/forms.py\n@@ -14,6 +14,7 @@\n     })\n \n     def signup(self, request, user):\n+        user.get_newsletters = self.cleaned_data[\"get_newsletters\"]\n         user.signup(\n             self.cleaned_data['username'],\n             self.cleaned_data['email'],\n", "issue": "get_newsletters during normal register is broken\nIf checked, the user still has get_newsletters = False. But when changed in the account settings, it's changed.\n", "before_files": [{"content": "from allauth.socialaccount.adapter import get_adapter\nfrom allauth.utils import email_address_exists\nfrom django import forms\nfrom django.contrib.auth import forms as auth_forms\nfrom django.contrib.auth import get_user_model\nfrom django.utils.translation import ugettext_lazy as _\n\nUser = get_user_model()\n\n\nclass TermsSignupForm(auth_forms.UserCreationForm):\n    terms_of_use = forms.BooleanField(label=_('Terms of use'), error_messages={\n        'required': _('Please accept the terms of use.')\n    })\n\n    def signup(self, request, user):\n        user.signup(\n            self.cleaned_data['username'],\n            self.cleaned_data['email'],\n        )\n\n    class Meta:\n        model = User\n        fields = ('email', 'username', 'password1', 'password2',\n                  'terms_of_use', 'get_newsletters')\n\n# Tried to add form as described in allauth documentation:\n# https://django-allauth.readthedocs.io/en/latest/forms.html#socialaccount-forms\n# ran into the following error:\n# https://stackoverflow.com/questions/57254251/custom-form-with-socialaccount-in-django-allauth\n# added this solution, maybe not the best\n\n\nclass SignupForm(forms.Form):\n    terms_of_use = forms.BooleanField(label=_('Terms of use'), error_messages={\n        'required': _('Please accept the terms of use.')\n    })\n    get_newsletters = forms.BooleanField(\n        label=_('Send me newsletters'), required=False)\n    email = forms.EmailField(widget=forms.HiddenInput())\n    username = forms.CharField(widget=forms.HiddenInput())\n\n    def __init__(self, *args, **kwargs):\n        self.sociallogin = kwargs.pop('sociallogin')\n        initial = get_adapter().get_signup_form_initial_data(\n            self.sociallogin)\n        kwargs.update({\n            'initial': initial})\n        super().__init__(*args, **kwargs)\n\n    def save(self, request):\n        adapter = get_adapter(request)\n        user = adapter.save_user(request, self.sociallogin, form=self)\n        user.get_newsletters = self.cleaned_data['get_newsletters']\n        user.save()\n        user.signup(\n            user.username,\n            user.email\n        )\n        return user\n\n    def clean(self):\n        email = self.cleaned_data['email']\n        if email_address_exists(email):\n            raise forms.ValidationError(\n                get_adapter().error_messages['email_taken']\n                % self.sociallogin.account.get_provider().name)\n        return super().clean()\n", "path": "apps/users/forms.py"}]}