prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  timeline wrong way?
  the phases in the timeline seem to be sorted in the wrong direction:
  ![bildschirmfoto 2016-10-21 um 13 33 06](https://cloud.githubusercontent.com/assets/2905743/19597159/1eee7114-9793-11e6-97f9-5acd3d610f46.png)
  ![bildschirmfoto 2016-10-21 um 13 33 18](https://cloud.githubusercontent.com/assets/2905743/19597161/22f8492e-9793-11e6-97a6-8b7e4e2b4388.png)
  
  
  </issue>
  <code>
  [start of euth/phases/models.py]
  1 from django.core.exceptions import ValidationError
  2 from django.db import models
  3 from django.utils import timezone
  4 from django.utils.translation import ugettext as _
  5 
  6 from euth.modules import models as modules_models
  7 
  8 from . import content
  9 from .validators import validate_content
  10 
  11 
  12 class PhasesQuerySet(models.QuerySet):
  13 
  14     def active_phases(self):
  15         now = timezone.now()
  16         return self.filter(start_date__lte=now, end_date__gt=now)
  17 
  18 
  19 class Phase(models.Model):
  20     name = models.CharField(max_length=80)
  21     description = models.TextField(max_length=300)
  22     type = models.CharField(max_length=128, validators=[validate_content])
  23     module = models.ForeignKey(modules_models.Module, on_delete=models.CASCADE)
  24     start_date = models.DateTimeField(blank=True, null=True)
  25     end_date = models.DateTimeField(blank=True, null=True)
  26 
  27     objects = PhasesQuerySet.as_manager()
  28 
  29     def __str__(self):
  30         return '{} ({})'.format(self.name, self.type)
  31 
  32     def content(self):
  33         return content[self.type]
  34 
  35     def clean(self):
  36         if self.end_date and self.start_date:
  37             if self.end_date < self.start_date:
  38                 raise ValidationError({
  39                     'end_date': _('End date can not be smaller'
  40                                   'than the start date.')
  41                 })
  42         super().clean()
  43 
  44     @property
  45     def view(self):
  46         return content[self.type].view
  47 
  48     def has_feature(self, feature, model):
  49         return content[self.type].has_feature(feature, model)
  50
  [end of euth/phases/models.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/euth/phases/models.py b/euth/phases/models.py
  --- a/euth/phases/models.py
  +++ b/euth/phases/models.py
  @@ -26,6 +26,9 @@
   
       objects = PhasesQuerySet.as_manager()
   
  +    class Meta:
  +        ordering = ['type']
  +
       def __str__(self):
           return '{} ({})'.format(self.name, self.type)
  
verification_info: {"golden_diff": "diff --git a/euth/phases/models.py b/euth/phases/models.py\n--- a/euth/phases/models.py\n+++ b/euth/phases/models.py\n@@ -26,6 +26,9 @@\n \n     objects = PhasesQuerySet.as_manager()\n \n+    class Meta:\n+        ordering = ['type']\n+\n     def __str__(self):\n         return '{} ({})'.format(self.name, self.type)\n", "issue": "timeline wrong way?\nthe phases in the timeline seem to be sorted in the wrong direction:\n![bildschirmfoto 2016-10-21 um 13 33 06](https://cloud.githubusercontent.com/assets/2905743/19597159/1eee7114-9793-11e6-97f9-5acd3d610f46.png)\n![bildschirmfoto 2016-10-21 um 13 33 18](https://cloud.githubusercontent.com/assets/2905743/19597161/22f8492e-9793-11e6-97a6-8b7e4e2b4388.png)\n\n", "before_files": [{"content": "from django.core.exceptions import ValidationError\nfrom django.db import models\nfrom django.utils import timezone\nfrom django.utils.translation import ugettext as _\n\nfrom euth.modules import models as modules_models\n\nfrom . import content\nfrom .validators import validate_content\n\n\nclass PhasesQuerySet(models.QuerySet):\n\n    def active_phases(self):\n        now = timezone.now()\n        return self.filter(start_date__lte=now, end_date__gt=now)\n\n\nclass Phase(models.Model):\n    name = models.CharField(max_length=80)\n    description = models.TextField(max_length=300)\n    type = models.CharField(max_length=128, validators=[validate_content])\n    module = models.ForeignKey(modules_models.Module, on_delete=models.CASCADE)\n    start_date = models.DateTimeField(blank=True, null=True)\n    end_date = models.DateTimeField(blank=True, null=True)\n\n    objects = PhasesQuerySet.as_manager()\n\n    def __str__(self):\n        return '{} ({})'.format(self.name, self.type)\n\n    def content(self):\n        return content[self.type]\n\n    def clean(self):\n        if self.end_date and self.start_date:\n            if self.end_date < self.start_date:\n                raise ValidationError({\n                    'end_date': _('End date can not be smaller'\n                                  'than the start date.')\n                })\n        super().clean()\n\n    @property\n    def view(self):\n        return content[self.type].view\n\n    def has_feature(self, feature, model):\n        return content[self.type].has_feature(feature, model)\n", "path": "euth/phases/models.py"}]}