prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Wrong penalty count in email
  The counter in the penalty email is still wrong:
  
  ![screenshot from 2018-02-02 13-43-18](https://user-images.githubusercontent.com/1467188/35733820-208df2e4-081f-11e8-9903-3767cfedd43d.png)
  
  
  </issue>
  <code>
  [start of lego/apps/feed/feed_handlers/penalty_handler.py]
  1 from lego.apps.feed.activities import Activity
  2 from lego.apps.feed.feed_handlers.base_handler import BaseHandler
  3 from lego.apps.feed.feed_manager import feed_manager
  4 from lego.apps.feed.feeds.notification_feed import NotificationFeed
  5 from lego.apps.feed.registry import register_handler
  6 from lego.apps.feed.verbs import PenaltyVerb
  7 from lego.apps.users.models import Penalty
  8 from lego.apps.users.notifications import PenaltyNotification
  9 
  10 
  11 class PenaltyHandler(BaseHandler):
  12     model = Penalty
  13     manager = feed_manager
  14 
  15     def get_activity(self, penalty):
  16         return Activity(
  17             actor=penalty.source_event, verb=PenaltyVerb, object=penalty, target=penalty.user,
  18             time=penalty.created_at, extra_context={
  19                 'reason': penalty.reason,
  20                 'weight': penalty.weight,
  21                 'total': penalty.user.number_of_penalties()
  22             }
  23         )
  24 
  25     def handle_create(self, penalty):
  26         activity = self.get_activity(penalty)
  27         self.manager.add_activity(activity, [penalty.user.pk], [NotificationFeed])
  28 
  29         # Send Notification
  30         notification = PenaltyNotification(penalty.user, penalty=penalty)
  31         notification.notify()
  32 
  33     def handle_update(self, penalty):
  34         activity = self.get_activity(penalty)
  35         self.manager.add_activity(activity, [penalty.user.pk], [NotificationFeed])
  36 
  37     def handle_delete(self, penalty):
  38         activity = self.get_activity(penalty)
  39         self.manager.remove_activity(activity, [penalty.user.pk], [NotificationFeed])
  40 
  41 
  42 register_handler(PenaltyHandler)
  43
  [end of lego/apps/feed/feed_handlers/penalty_handler.py]
  [start of lego/apps/users/notifications.py]
  1 from lego.apps.notifications.constants import PENALTY_CREATION
  2 from lego.apps.notifications.notification import Notification
  3 
  4 
  5 class PenaltyNotification(Notification):
  6 
  7     name = PENALTY_CREATION
  8 
  9     def generate_mail(self):
  10         penalty = self.kwargs['penalty']
  11 
  12         return self._delay_mail(
  13             to_email=self.user.email,
  14             context={
  15                 'name': self.user.full_name,
  16                 'weight': penalty.weight,
  17                 'event': penalty.source_event.title,
  18                 'reason': penalty.reason,
  19                 'total': self.user.number_of_penalties()
  20             },
  21             subject=f'Du har fått en ny prikk',
  22             plain_template='users/email/penalty.txt',
  23             html_template='users/email/penalty.html',
  24         )
  25 
  26     def generate_push(self):
  27         penalty = self.kwargs['penalty']
  28 
  29         return self._delay_push(
  30             template='users/push/penalty.txt', context={
  31                 'weight': penalty.weight,
  32                 'event': penalty.source_event.title,
  33             }, instance=penalty
  34         )
  35
  [end of lego/apps/users/notifications.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/lego/apps/feed/feed_handlers/penalty_handler.py b/lego/apps/feed/feed_handlers/penalty_handler.py
  --- a/lego/apps/feed/feed_handlers/penalty_handler.py
  +++ b/lego/apps/feed/feed_handlers/penalty_handler.py
  @@ -18,7 +18,6 @@
               time=penalty.created_at, extra_context={
                   'reason': penalty.reason,
                   'weight': penalty.weight,
  -                'total': penalty.user.number_of_penalties()
               }
           )
   
  diff --git a/lego/apps/users/notifications.py b/lego/apps/users/notifications.py
  --- a/lego/apps/users/notifications.py
  +++ b/lego/apps/users/notifications.py
  @@ -16,7 +16,6 @@
                   'weight': penalty.weight,
                   'event': penalty.source_event.title,
                   'reason': penalty.reason,
  -                'total': self.user.number_of_penalties()
               },
               subject=f'Du har fått en ny prikk',
               plain_template='users/email/penalty.txt',
  
verification_info: {"golden_diff": "diff --git a/lego/apps/feed/feed_handlers/penalty_handler.py b/lego/apps/feed/feed_handlers/penalty_handler.py\n--- a/lego/apps/feed/feed_handlers/penalty_handler.py\n+++ b/lego/apps/feed/feed_handlers/penalty_handler.py\n@@ -18,7 +18,6 @@\n             time=penalty.created_at, extra_context={\n                 'reason': penalty.reason,\n                 'weight': penalty.weight,\n-                'total': penalty.user.number_of_penalties()\n             }\n         )\n \ndiff --git a/lego/apps/users/notifications.py b/lego/apps/users/notifications.py\n--- a/lego/apps/users/notifications.py\n+++ b/lego/apps/users/notifications.py\n@@ -16,7 +16,6 @@\n                 'weight': penalty.weight,\n                 'event': penalty.source_event.title,\n                 'reason': penalty.reason,\n-                'total': self.user.number_of_penalties()\n             },\n             subject=f'Du har f\u00e5tt en ny prikk',\n             plain_template='users/email/penalty.txt',\n", "issue": "Wrong penalty count in email\nThe counter in the penalty email is still wrong:\r\n\r\n![screenshot from 2018-02-02 13-43-18](https://user-images.githubusercontent.com/1467188/35733820-208df2e4-081f-11e8-9903-3767cfedd43d.png)\r\n\n", "before_files": [{"content": "from lego.apps.feed.activities import Activity\nfrom lego.apps.feed.feed_handlers.base_handler import BaseHandler\nfrom lego.apps.feed.feed_manager import feed_manager\nfrom lego.apps.feed.feeds.notification_feed import NotificationFeed\nfrom lego.apps.feed.registry import register_handler\nfrom lego.apps.feed.verbs import PenaltyVerb\nfrom lego.apps.users.models import Penalty\nfrom lego.apps.users.notifications import PenaltyNotification\n\n\nclass PenaltyHandler(BaseHandler):\n    model = Penalty\n    manager = feed_manager\n\n    def get_activity(self, penalty):\n        return Activity(\n            actor=penalty.source_event, verb=PenaltyVerb, object=penalty, target=penalty.user,\n            time=penalty.created_at, extra_context={\n                'reason': penalty.reason,\n                'weight': penalty.weight,\n                'total': penalty.user.number_of_penalties()\n            }\n        )\n\n    def handle_create(self, penalty):\n        activity = self.get_activity(penalty)\n        self.manager.add_activity(activity, [penalty.user.pk], [NotificationFeed])\n\n        # Send Notification\n        notification = PenaltyNotification(penalty.user, penalty=penalty)\n        notification.notify()\n\n    def handle_update(self, penalty):\n        activity = self.get_activity(penalty)\n        self.manager.add_activity(activity, [penalty.user.pk], [NotificationFeed])\n\n    def handle_delete(self, penalty):\n        activity = self.get_activity(penalty)\n        self.manager.remove_activity(activity, [penalty.user.pk], [NotificationFeed])\n\n\nregister_handler(PenaltyHandler)\n", "path": "lego/apps/feed/feed_handlers/penalty_handler.py"}, {"content": "from lego.apps.notifications.constants import PENALTY_CREATION\nfrom lego.apps.notifications.notification import Notification\n\n\nclass PenaltyNotification(Notification):\n\n    name = PENALTY_CREATION\n\n    def generate_mail(self):\n        penalty = self.kwargs['penalty']\n\n        return self._delay_mail(\n            to_email=self.user.email,\n            context={\n                'name': self.user.full_name,\n                'weight': penalty.weight,\n                'event': penalty.source_event.title,\n                'reason': penalty.reason,\n                'total': self.user.number_of_penalties()\n            },\n            subject=f'Du har f\u00e5tt en ny prikk',\n            plain_template='users/email/penalty.txt',\n            html_template='users/email/penalty.html',\n        )\n\n    def generate_push(self):\n        penalty = self.kwargs['penalty']\n\n        return self._delay_push(\n            template='users/push/penalty.txt', context={\n                'weight': penalty.weight,\n                'event': penalty.source_event.title,\n            }, instance=penalty\n        )\n", "path": "lego/apps/users/notifications.py"}]}