prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Filter draft projects from all listings
  Projects that are in draft mode should be removed from most listings:
  - [x] latest projects for all users
  - [x] other projects for all users
  - [x] organisation page for non-initiators
  
  
  </issue>
  <code>
  [start of euth/organisations/views.py]
  1 from django.views import generic
  2 
  3 from . import models
  4 
  5 
  6 class OrganisationDetailView(generic.DetailView):
  7     model = models.Organisation
  8 
  9 
  10 class OrganisationListView(generic.ListView):
  11     model = models.Organisation
  12     paginate_by = 10
  13
  [end of euth/organisations/views.py]
  [start of euth/projects/models.py]
  1 from django.conf import settings
  2 from django.db import models
  3 from django.utils import functional, timezone
  4 
  5 from contrib.transforms import html_transforms
  6 from euth.contrib import base_models, validators
  7 from euth.organisations import models as org_models
  8 
  9 
  10 class ProjectManager(models.Manager):
  11 
  12     def get_by_natural_key(self, name):
  13         return self.get(name=name)
  14 
  15     def featured(self):
  16         return self.filter(is_draft=False).order_by('-created')[:8]
  17 
  18 
  19 class Project(base_models.TimeStampedModel):
  20     slug = models.SlugField(max_length=512, unique=True)
  21     name = models.CharField(max_length=512)
  22     organisation = models.ForeignKey(
  23         org_models.Organisation, on_delete=models.CASCADE)
  24     description = models.CharField(max_length=1024)
  25     information = models.TextField()
  26     is_public = models.BooleanField(default=True)
  27     is_draft = models.BooleanField(default=True)
  28     image = models.ImageField(
  29         upload_to='projects/backgrounds',
  30         blank=True,
  31         validators=[validators.validate_hero_image])
  32     participants = models.ManyToManyField(
  33         settings.AUTH_USER_MODEL,
  34         related_name='project_participant',
  35         blank=True,
  36     )
  37     moderators = models.ManyToManyField(
  38         settings.AUTH_USER_MODEL,
  39         related_name='project_moderator'
  40     )
  41 
  42     objects = ProjectManager()
  43 
  44     def __str__(self):
  45         return self.name
  46 
  47     def save(self, *args, **kwargs):
  48         self.information = html_transforms.clean_html_field(
  49             self.information)
  50         super(Project, self).save(*args, **kwargs)
  51 
  52     def get_absolute_url(self):
  53         from django.core.urlresolvers import reverse
  54         return reverse('project-detail', args=[str(self.slug)])
  55 
  56     def has_member(self, user):
  57         """
  58         Everybody is member of all public projects and private projects can
  59         be joined as moderator or participant.
  60         """
  61         return (
  62             (user.is_authenticated() and self.is_public)
  63             or (user in self.participants.all())
  64             or (user in self.moderators.all())
  65         )
  66 
  67     @functional.cached_property
  68     def other_projects(self):
  69         other_projects = self.organisation.project_set.all().exclude(
  70             slug=self.slug)
  71         return other_projects
  72 
  73     @functional.cached_property
  74     def is_private(self):
  75         return not self.is_public
  76 
  77     @functional.cached_property
  78     def active_phase(self):
  79         from euth.phases import models as phase_models
  80         return phase_models.Phase.objects\
  81                                  .filter(module__project=self)\
  82                                  .active_phases()\
  83                                  .first()
  84 
  85     @property
  86     def days_left(self):
  87         if self.active_phase:
  88             today = timezone.now().replace(hour=0, minute=0, second=0)
  89             time_delta = self.active_phase.end_date - today
  90             return time_delta.days
  91
  [end of euth/projects/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/organisations/views.py b/euth/organisations/views.py
  --- a/euth/organisations/views.py
  +++ b/euth/organisations/views.py
  @@ -6,6 +6,12 @@
   class OrganisationDetailView(generic.DetailView):
       model = models.Organisation
   
  +    def visible_projects(self):
  +        if self.request.user in self.object.initiators.all():
  +            return self.object.project_set.all()
  +        else:
  +            return self.object.project_set.filter(is_draft=False)
  +
   
   class OrganisationListView(generic.ListView):
       model = models.Organisation
  diff --git a/euth/projects/models.py b/euth/projects/models.py
  --- a/euth/projects/models.py
  +++ b/euth/projects/models.py
  @@ -66,8 +66,8 @@
   
       @functional.cached_property
       def other_projects(self):
  -        other_projects = self.organisation.project_set.all().exclude(
  -            slug=self.slug)
  +        other_projects = self.organisation.project_set\
  +            .filter(is_draft=False).exclude(slug=self.slug)
           return other_projects
   
       @functional.cached_property
  
verification_info: {"golden_diff": "diff --git a/euth/organisations/views.py b/euth/organisations/views.py\n--- a/euth/organisations/views.py\n+++ b/euth/organisations/views.py\n@@ -6,6 +6,12 @@\n class OrganisationDetailView(generic.DetailView):\n     model = models.Organisation\n \n+    def visible_projects(self):\n+        if self.request.user in self.object.initiators.all():\n+            return self.object.project_set.all()\n+        else:\n+            return self.object.project_set.filter(is_draft=False)\n+\n \n class OrganisationListView(generic.ListView):\n     model = models.Organisation\ndiff --git a/euth/projects/models.py b/euth/projects/models.py\n--- a/euth/projects/models.py\n+++ b/euth/projects/models.py\n@@ -66,8 +66,8 @@\n \n     @functional.cached_property\n     def other_projects(self):\n-        other_projects = self.organisation.project_set.all().exclude(\n-            slug=self.slug)\n+        other_projects = self.organisation.project_set\\\n+            .filter(is_draft=False).exclude(slug=self.slug)\n         return other_projects\n \n     @functional.cached_property\n", "issue": "Filter draft projects from all listings\nProjects that are in draft mode should be removed from most listings:\n- [x] latest projects for all users\n- [x] other projects for all users\n- [x] organisation page for non-initiators\n\n", "before_files": [{"content": "from django.views import generic\n\nfrom . import models\n\n\nclass OrganisationDetailView(generic.DetailView):\n    model = models.Organisation\n\n\nclass OrganisationListView(generic.ListView):\n    model = models.Organisation\n    paginate_by = 10\n", "path": "euth/organisations/views.py"}, {"content": "from django.conf import settings\nfrom django.db import models\nfrom django.utils import functional, timezone\n\nfrom contrib.transforms import html_transforms\nfrom euth.contrib import base_models, validators\nfrom euth.organisations import models as org_models\n\n\nclass ProjectManager(models.Manager):\n\n    def get_by_natural_key(self, name):\n        return self.get(name=name)\n\n    def featured(self):\n        return self.filter(is_draft=False).order_by('-created')[:8]\n\n\nclass Project(base_models.TimeStampedModel):\n    slug = models.SlugField(max_length=512, unique=True)\n    name = models.CharField(max_length=512)\n    organisation = models.ForeignKey(\n        org_models.Organisation, on_delete=models.CASCADE)\n    description = models.CharField(max_length=1024)\n    information = models.TextField()\n    is_public = models.BooleanField(default=True)\n    is_draft = models.BooleanField(default=True)\n    image = models.ImageField(\n        upload_to='projects/backgrounds',\n        blank=True,\n        validators=[validators.validate_hero_image])\n    participants = models.ManyToManyField(\n        settings.AUTH_USER_MODEL,\n        related_name='project_participant',\n        blank=True,\n    )\n    moderators = models.ManyToManyField(\n        settings.AUTH_USER_MODEL,\n        related_name='project_moderator'\n    )\n\n    objects = ProjectManager()\n\n    def __str__(self):\n        return self.name\n\n    def save(self, *args, **kwargs):\n        self.information = html_transforms.clean_html_field(\n            self.information)\n        super(Project, self).save(*args, **kwargs)\n\n    def get_absolute_url(self):\n        from django.core.urlresolvers import reverse\n        return reverse('project-detail', args=[str(self.slug)])\n\n    def has_member(self, user):\n        \"\"\"\n        Everybody is member of all public projects and private projects can\n        be joined as moderator or participant.\n        \"\"\"\n        return (\n            (user.is_authenticated() and self.is_public)\n            or (user in self.participants.all())\n            or (user in self.moderators.all())\n        )\n\n    @functional.cached_property\n    def other_projects(self):\n        other_projects = self.organisation.project_set.all().exclude(\n            slug=self.slug)\n        return other_projects\n\n    @functional.cached_property\n    def is_private(self):\n        return not self.is_public\n\n    @functional.cached_property\n    def active_phase(self):\n        from euth.phases import models as phase_models\n        return phase_models.Phase.objects\\\n                                 .filter(module__project=self)\\\n                                 .active_phases()\\\n                                 .first()\n\n    @property\n    def days_left(self):\n        if self.active_phase:\n            today = timezone.now().replace(hour=0, minute=0, second=0)\n            time_delta = self.active_phase.end_date - today\n            return time_delta.days\n", "path": "euth/projects/models.py"}]}