prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  testing #2252 follow mail: mail participation ends soon
  Where: Mail "participation ends soon"
  
  * in a single module project link should go to project view and not to a module view that does not regularly exist in this case. Is that possible?
  * As in the other mails: paragraph between two sentences probably looks better.
  
  </issue>
  <code>
  [start of meinberlin/apps/offlineevents/models.py]
  1 from datetime import timedelta
  2 
  3 from autoslug import AutoSlugField
  4 from ckeditor_uploader.fields import RichTextUploadingField
  5 from django.db import models
  6 from django.urls import reverse
  7 from django.utils import timezone
  8 from django.utils.translation import ugettext_lazy as _
  9 
  10 from adhocracy4 import transforms
  11 from adhocracy4.models.base import UserGeneratedContentModel
  12 from adhocracy4.projects import models as project_models
  13 
  14 
  15 class OfflineEventsQuerySet(models.QuerySet):
  16 
  17     def starts_within(self, hours=72):
  18         """All offlineevents starting within the given time."""
  19         now = timezone.now()
  20         return self.filter(date__gt=now,
  21                            date__lt=(now + timedelta(hours=hours)))
  22 
  23 
  24 class OfflineEvent(UserGeneratedContentModel):
  25     slug = AutoSlugField(populate_from='name', unique=True)
  26     name = models.CharField(max_length=120, verbose_name=_('Name of event'))
  27     event_type = models.CharField(
  28         max_length=30, verbose_name=_('Event type'),
  29         help_text=_('The content of this field is shown in the timeline. It '
  30                     'should have no more than 30 characters e.g. Information '
  31                     'event or 3rd public workshop.'))
  32     date = models.DateTimeField(
  33         verbose_name=_('Date'))
  34     description = RichTextUploadingField(
  35         config_name='image-editor',
  36         verbose_name=_('Description'))
  37     project = models.ForeignKey(
  38         project_models.Project, on_delete=models.CASCADE)
  39 
  40     objects = OfflineEventsQuerySet.as_manager()
  41 
  42     class Meta:
  43         ordering = ['-date']
  44 
  45     def __str__(self):
  46         return self.name
  47 
  48     def save(self, *args, **kwargs):
  49         self.description = transforms.clean_html_field(
  50             self.description, 'image-editor')
  51         super().save(*args, **kwargs)
  52 
  53     def get_absolute_url(self):
  54         return reverse('meinberlin_offlineevents:offlineevent-detail',
  55                        args=[str(self.slug)])
  56
  [end of meinberlin/apps/offlineevents/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/meinberlin/apps/offlineevents/models.py b/meinberlin/apps/offlineevents/models.py
  --- a/meinberlin/apps/offlineevents/models.py
  +++ b/meinberlin/apps/offlineevents/models.py
  @@ -3,8 +3,8 @@
   from autoslug import AutoSlugField
   from ckeditor_uploader.fields import RichTextUploadingField
   from django.db import models
  -from django.urls import reverse
   from django.utils import timezone
  +from django.utils.functional import cached_property
   from django.utils.translation import ugettext_lazy as _
   
   from adhocracy4 import transforms
  @@ -50,6 +50,16 @@
               self.description, 'image-editor')
           super().save(*args, **kwargs)
   
  +    @cached_property
  +    def get_timeline_index(self):
  +        if self.project.display_timeline:
  +            for count, cluster in enumerate(self.project.participation_dates):
  +                if 'event_type' in cluster and self.slug == cluster['slug']:
  +                    return count
  +        return 0
  +
       def get_absolute_url(self):
  -        return reverse('meinberlin_offlineevents:offlineevent-detail',
  -                       args=[str(self.slug)])
  +        if self.project.display_timeline:
  +            return '{}?initialSlide={}'.format(self.project.get_absolute_url(),
  +                                               self.get_timeline_index)
  +        return self.project.get_absolute_url()
  
verification_info: {"golden_diff": "diff --git a/meinberlin/apps/offlineevents/models.py b/meinberlin/apps/offlineevents/models.py\n--- a/meinberlin/apps/offlineevents/models.py\n+++ b/meinberlin/apps/offlineevents/models.py\n@@ -3,8 +3,8 @@\n from autoslug import AutoSlugField\n from ckeditor_uploader.fields import RichTextUploadingField\n from django.db import models\n-from django.urls import reverse\n from django.utils import timezone\n+from django.utils.functional import cached_property\n from django.utils.translation import ugettext_lazy as _\n \n from adhocracy4 import transforms\n@@ -50,6 +50,16 @@\n             self.description, 'image-editor')\n         super().save(*args, **kwargs)\n \n+    @cached_property\n+    def get_timeline_index(self):\n+        if self.project.display_timeline:\n+            for count, cluster in enumerate(self.project.participation_dates):\n+                if 'event_type' in cluster and self.slug == cluster['slug']:\n+                    return count\n+        return 0\n+\n     def get_absolute_url(self):\n-        return reverse('meinberlin_offlineevents:offlineevent-detail',\n-                       args=[str(self.slug)])\n+        if self.project.display_timeline:\n+            return '{}?initialSlide={}'.format(self.project.get_absolute_url(),\n+                                               self.get_timeline_index)\n+        return self.project.get_absolute_url()\n", "issue": "testing #2252 follow mail: mail participation ends soon\nWhere: Mail \"participation ends soon\"\r\n\r\n* in a single module project link should go to project view and not to a module view that does not regularly exist in this case. Is that possible?\r\n* As in the other mails: paragraph between two sentences probably looks better.\n", "before_files": [{"content": "from datetime import timedelta\n\nfrom autoslug import AutoSlugField\nfrom ckeditor_uploader.fields import RichTextUploadingField\nfrom django.db import models\nfrom django.urls import reverse\nfrom django.utils import timezone\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom adhocracy4 import transforms\nfrom adhocracy4.models.base import UserGeneratedContentModel\nfrom adhocracy4.projects import models as project_models\n\n\nclass OfflineEventsQuerySet(models.QuerySet):\n\n    def starts_within(self, hours=72):\n        \"\"\"All offlineevents starting within the given time.\"\"\"\n        now = timezone.now()\n        return self.filter(date__gt=now,\n                           date__lt=(now + timedelta(hours=hours)))\n\n\nclass OfflineEvent(UserGeneratedContentModel):\n    slug = AutoSlugField(populate_from='name', unique=True)\n    name = models.CharField(max_length=120, verbose_name=_('Name of event'))\n    event_type = models.CharField(\n        max_length=30, verbose_name=_('Event type'),\n        help_text=_('The content of this field is shown in the timeline. It '\n                    'should have no more than 30 characters e.g. Information '\n                    'event or 3rd public workshop.'))\n    date = models.DateTimeField(\n        verbose_name=_('Date'))\n    description = RichTextUploadingField(\n        config_name='image-editor',\n        verbose_name=_('Description'))\n    project = models.ForeignKey(\n        project_models.Project, on_delete=models.CASCADE)\n\n    objects = OfflineEventsQuerySet.as_manager()\n\n    class Meta:\n        ordering = ['-date']\n\n    def __str__(self):\n        return self.name\n\n    def save(self, *args, **kwargs):\n        self.description = transforms.clean_html_field(\n            self.description, 'image-editor')\n        super().save(*args, **kwargs)\n\n    def get_absolute_url(self):\n        return reverse('meinberlin_offlineevents:offlineevent-detail',\n                       args=[str(self.slug)])\n", "path": "meinberlin/apps/offlineevents/models.py"}]}