prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Mark rules error for anonymous users on events
  'AnonymousUser' object has no attribute 'mark_rules'
  
  
  </issue>
  <code>
  [start of apps/events/forms.py]
  1 from django import forms
  2 from captcha.fields import CaptchaField
  3 
  4 class CaptchaForm(forms.Form):
  5     def __init__(self, *args, **kwargs):
  6         user = kwargs.pop('user', None)
  7         super(CaptchaForm, self).__init__(*args, **kwargs)
  8         # Removing mark rules field if user has already accepted the rules
  9         if user and  user.mark_rules:
  10             del self.fields['mark_rules']
  11     mark_rules = forms.BooleanField(label=u'Jeg godtar <a href="/profile/#marks" target="_blank">prikkreglene</a>')
  12     captcha = CaptchaField()
  13
  [end of apps/events/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/events/forms.py b/apps/events/forms.py
  --- a/apps/events/forms.py
  +++ b/apps/events/forms.py
  @@ -6,7 +6,7 @@
           user = kwargs.pop('user', None)
           super(CaptchaForm, self).__init__(*args, **kwargs)
           # Removing mark rules field if user has already accepted the rules
  -        if user and  user.mark_rules:
  +        if user and user.is_authenticated() and user.mark_rules:
               del self.fields['mark_rules']
       mark_rules = forms.BooleanField(label=u'Jeg godtar <a href="/profile/#marks" target="_blank">prikkreglene</a>')
       captcha = CaptchaField()
  
verification_info: {"golden_diff": "diff --git a/apps/events/forms.py b/apps/events/forms.py\n--- a/apps/events/forms.py\n+++ b/apps/events/forms.py\n@@ -6,7 +6,7 @@\n         user = kwargs.pop('user', None)\n         super(CaptchaForm, self).__init__(*args, **kwargs)\n         # Removing mark rules field if user has already accepted the rules\n-        if user and  user.mark_rules:\n+        if user and user.is_authenticated() and user.mark_rules:\n             del self.fields['mark_rules']\n     mark_rules = forms.BooleanField(label=u'Jeg godtar <a href=\"/profile/#marks\" target=\"_blank\">prikkreglene</a>')\n     captcha = CaptchaField()\n", "issue": "Mark rules error for anonymous users on events\n'AnonymousUser' object has no attribute 'mark_rules'\n\n", "before_files": [{"content": "from django import forms\nfrom captcha.fields import CaptchaField\n\nclass CaptchaForm(forms.Form):\n    def __init__(self, *args, **kwargs):\n        user = kwargs.pop('user', None)\n        super(CaptchaForm, self).__init__(*args, **kwargs)\n        # Removing mark rules field if user has already accepted the rules\n        if user and  user.mark_rules:\n            del self.fields['mark_rules']\n    mark_rules = forms.BooleanField(label=u'Jeg godtar <a href=\"/profile/#marks\" target=\"_blank\">prikkreglene</a>')\n    captcha = CaptchaField()\n", "path": "apps/events/forms.py"}]}