prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  store window: district tile announces more results than there are if I click on them
  store window tile shows ALL project of district, if I click and get to project overview, the default filter takes out all old projects and plans without beteiligung.
  
  can we only count running projects with participation?
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `meinberlin/apps/cms/models/storefronts.py`
  Content:
  ```
  1 import random
  2 
  3 from django.db import models
  4 from django.utils.functional import cached_property
  5 from modelcluster.fields import ParentalKey
  6 from modelcluster.models import ClusterableModel
  7 from wagtail.admin import edit_handlers
  8 from wagtail.admin.edit_handlers import FieldPanel
  9 from wagtail.images.edit_handlers import ImageChooserPanel
  10 from wagtail.snippets.models import register_snippet
  11 
  12 from adhocracy4.comments.models import Comment
  13 from adhocracy4.modules.models import Item
  14 from adhocracy4.projects.models import Project
  15 from meinberlin.apps.projects import get_project_type
  16 
  17 
  18 class StorefrontItem(models.Model):
  19     district = models.ForeignKey(
  20         'a4administrative_districts.AdministrativeDistrict',
  21         related_name='+',
  22         null=True,
  23         blank=True
  24     )
  25     project = models.ForeignKey(
  26         'a4projects.Project',
  27         related_name='+',
  28         null=True,
  29         blank=True
  30     )
  31     quote = models.TextField(
  32         blank=True,
  33         max_length=150
  34     )
  35 
  36     def __str__(self):
  37         return str(self.pk)
  38 
  39     @cached_property
  40     def item_type(self):
  41         if get_project_type(self.project) in ('external', 'bplan'):
  42             return 'external'
  43         return 'project'
  44 
  45     @cached_property
  46     def project_url(self):
  47         if self.item_type == 'external':
  48             return self.project.externalproject.url
  49         return self.project.get_absolute_url()
  50 
  51     @cached_property
  52     def district_project_count(self):
  53         return Project.objects\
  54             .filter(administrative_district=self.district,
  55                     is_draft=False,
  56                     is_public=True,
  57                     is_archived=False
  58                     ).count()
  59 
  60     panels = [
  61         FieldPanel('district'),
  62         FieldPanel('project'),
  63         FieldPanel('quote'),
  64     ]
  65 
  66 
  67 @register_snippet
  68 class Storefront(ClusterableModel):
  69     title = models.CharField(max_length=255, null=False, blank=False)
  70     image = models.ForeignKey(
  71         'meinberlin_cms.CustomImage',
  72         null=True,
  73         blank=True,
  74         on_delete=models.SET_NULL,
  75         related_name='+'
  76     )
  77     teaser = models.CharField(max_length=100)
  78 
  79     def __str__(self):
  80         return self.title
  81 
  82     @cached_property
  83     def num_entries(self):
  84         num_comments = Comment.objects.all().count()
  85         num_items = Item.objects.all().count()
  86         return num_comments + num_items
  87 
  88     @cached_property
  89     def num_projects(self):
  90         projects = Project.objects.all()\
  91             .filter(is_draft=False, is_archived=False, is_public=True)
  92         active_project_count = 0
  93         for project in projects:
  94             if project.active_phase or project.future_phases:
  95                 active_project_count += 1
  96         return active_project_count
  97 
  98     @cached_property
  99     def random_items(self):
  100         items = self.items.all()
  101         if items.count() > 3:
  102             items_list = items.values_list('id', flat=True)
  103             random_items = random.sample(list(items_list), 3)
  104             return StorefrontItem.objects.filter(id__in=random_items)
  105         else:
  106             return items
  107 
  108     title_panel = [
  109         edit_handlers.FieldPanel('title')
  110     ]
  111 
  112     image_tile_panel = [
  113         ImageChooserPanel('image'),
  114         edit_handlers.FieldPanel('teaser')
  115     ]
  116 
  117     project_tiles_panel = [
  118         edit_handlers.InlinePanel('items', min_num=3)
  119     ]
  120 
  121     edit_handler = edit_handlers.TabbedInterface([
  122         edit_handlers.ObjectList(title_panel, heading='Title'),
  123         edit_handlers.ObjectList(image_tile_panel, heading='Image Tile'),
  124         edit_handlers.ObjectList(project_tiles_panel, heading='Project Tiles')
  125     ])
  126 
  127 
  128 class StorefrontCollection(StorefrontItem):
  129     parent = ParentalKey('meinberlin_cms.Storefront', related_name='items')
  130
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/meinberlin/apps/cms/models/storefronts.py b/meinberlin/apps/cms/models/storefronts.py
  --- a/meinberlin/apps/cms/models/storefronts.py
  +++ b/meinberlin/apps/cms/models/storefronts.py
  @@ -50,12 +50,17 @@
   
       @cached_property
       def district_project_count(self):
  -        return Project.objects\
  +        projects = Project.objects\
               .filter(administrative_district=self.district,
                       is_draft=False,
                       is_public=True,
                       is_archived=False
  -                    ).count()
  +                    )
  +        active_project_count = 0
  +        for project in projects:
  +            if project.active_phase or project.future_phases:
  +                active_project_count += 1
  +        return active_project_count
   
       panels = [
           FieldPanel('district'),
  
verification_info: {"golden_diff": "diff --git a/meinberlin/apps/cms/models/storefronts.py b/meinberlin/apps/cms/models/storefronts.py\n--- a/meinberlin/apps/cms/models/storefronts.py\n+++ b/meinberlin/apps/cms/models/storefronts.py\n@@ -50,12 +50,17 @@\n \n     @cached_property\n     def district_project_count(self):\n-        return Project.objects\\\n+        projects = Project.objects\\\n             .filter(administrative_district=self.district,\n                     is_draft=False,\n                     is_public=True,\n                     is_archived=False\n-                    ).count()\n+                    )\n+        active_project_count = 0\n+        for project in projects:\n+            if project.active_phase or project.future_phases:\n+                active_project_count += 1\n+        return active_project_count\n \n     panels = [\n         FieldPanel('district'),\n", "issue": "store window: district tile announces more results than there are if I click on them\nstore window tile shows ALL project of district, if I click and get to project overview, the default filter takes out all old projects and plans without beteiligung.\r\n\r\ncan we only count running projects with participation?\n", "before_files": [{"content": "import random\n\nfrom django.db import models\nfrom django.utils.functional import cached_property\nfrom modelcluster.fields import ParentalKey\nfrom modelcluster.models import ClusterableModel\nfrom wagtail.admin import edit_handlers\nfrom wagtail.admin.edit_handlers import FieldPanel\nfrom wagtail.images.edit_handlers import ImageChooserPanel\nfrom wagtail.snippets.models import register_snippet\n\nfrom adhocracy4.comments.models import Comment\nfrom adhocracy4.modules.models import Item\nfrom adhocracy4.projects.models import Project\nfrom meinberlin.apps.projects import get_project_type\n\n\nclass StorefrontItem(models.Model):\n    district = models.ForeignKey(\n        'a4administrative_districts.AdministrativeDistrict',\n        related_name='+',\n        null=True,\n        blank=True\n    )\n    project = models.ForeignKey(\n        'a4projects.Project',\n        related_name='+',\n        null=True,\n        blank=True\n    )\n    quote = models.TextField(\n        blank=True,\n        max_length=150\n    )\n\n    def __str__(self):\n        return str(self.pk)\n\n    @cached_property\n    def item_type(self):\n        if get_project_type(self.project) in ('external', 'bplan'):\n            return 'external'\n        return 'project'\n\n    @cached_property\n    def project_url(self):\n        if self.item_type == 'external':\n            return self.project.externalproject.url\n        return self.project.get_absolute_url()\n\n    @cached_property\n    def district_project_count(self):\n        return Project.objects\\\n            .filter(administrative_district=self.district,\n                    is_draft=False,\n                    is_public=True,\n                    is_archived=False\n                    ).count()\n\n    panels = [\n        FieldPanel('district'),\n        FieldPanel('project'),\n        FieldPanel('quote'),\n    ]\n\n\n@register_snippet\nclass Storefront(ClusterableModel):\n    title = models.CharField(max_length=255, null=False, blank=False)\n    image = models.ForeignKey(\n        'meinberlin_cms.CustomImage',\n        null=True,\n        blank=True,\n        on_delete=models.SET_NULL,\n        related_name='+'\n    )\n    teaser = models.CharField(max_length=100)\n\n    def __str__(self):\n        return self.title\n\n    @cached_property\n    def num_entries(self):\n        num_comments = Comment.objects.all().count()\n        num_items = Item.objects.all().count()\n        return num_comments + num_items\n\n    @cached_property\n    def num_projects(self):\n        projects = Project.objects.all()\\\n            .filter(is_draft=False, is_archived=False, is_public=True)\n        active_project_count = 0\n        for project in projects:\n            if project.active_phase or project.future_phases:\n                active_project_count += 1\n        return active_project_count\n\n    @cached_property\n    def random_items(self):\n        items = self.items.all()\n        if items.count() > 3:\n            items_list = items.values_list('id', flat=True)\n            random_items = random.sample(list(items_list), 3)\n            return StorefrontItem.objects.filter(id__in=random_items)\n        else:\n            return items\n\n    title_panel = [\n        edit_handlers.FieldPanel('title')\n    ]\n\n    image_tile_panel = [\n        ImageChooserPanel('image'),\n        edit_handlers.FieldPanel('teaser')\n    ]\n\n    project_tiles_panel = [\n        edit_handlers.InlinePanel('items', min_num=3)\n    ]\n\n    edit_handler = edit_handlers.TabbedInterface([\n        edit_handlers.ObjectList(title_panel, heading='Title'),\n        edit_handlers.ObjectList(image_tile_panel, heading='Image Tile'),\n        edit_handlers.ObjectList(project_tiles_panel, heading='Project Tiles')\n    ])\n\n\nclass StorefrontCollection(StorefrontItem):\n    parent = ParentalKey('meinberlin_cms.Storefront', related_name='items')\n", "path": "meinberlin/apps/cms/models/storefronts.py"}], "after_files": [{"content": "import random\n\nfrom django.db import models\nfrom django.utils.functional import cached_property\nfrom modelcluster.fields import ParentalKey\nfrom modelcluster.models import ClusterableModel\nfrom wagtail.admin import edit_handlers\nfrom wagtail.admin.edit_handlers import FieldPanel\nfrom wagtail.images.edit_handlers import ImageChooserPanel\nfrom wagtail.snippets.models import register_snippet\n\nfrom adhocracy4.comments.models import Comment\nfrom adhocracy4.modules.models import Item\nfrom adhocracy4.projects.models import Project\nfrom meinberlin.apps.projects import get_project_type\n\n\nclass StorefrontItem(models.Model):\n    district = models.ForeignKey(\n        'a4administrative_districts.AdministrativeDistrict',\n        related_name='+',\n        null=True,\n        blank=True\n    )\n    project = models.ForeignKey(\n        'a4projects.Project',\n        related_name='+',\n        null=True,\n        blank=True\n    )\n    quote = models.TextField(\n        blank=True,\n        max_length=150\n    )\n\n    def __str__(self):\n        return str(self.pk)\n\n    @cached_property\n    def item_type(self):\n        if get_project_type(self.project) in ('external', 'bplan'):\n            return 'external'\n        return 'project'\n\n    @cached_property\n    def project_url(self):\n        if self.item_type == 'external':\n            return self.project.externalproject.url\n        return self.project.get_absolute_url()\n\n    @cached_property\n    def district_project_count(self):\n        projects = Project.objects\\\n            .filter(administrative_district=self.district,\n                    is_draft=False,\n                    is_public=True,\n                    is_archived=False\n                    )\n        active_project_count = 0\n        for project in projects:\n            if project.active_phase or project.future_phases:\n                active_project_count += 1\n        return active_project_count\n\n    panels = [\n        FieldPanel('district'),\n        FieldPanel('project'),\n        FieldPanel('quote'),\n    ]\n\n\n@register_snippet\nclass Storefront(ClusterableModel):\n    title = models.CharField(max_length=255, null=False, blank=False)\n    image = models.ForeignKey(\n        'meinberlin_cms.CustomImage',\n        null=True,\n        blank=True,\n        on_delete=models.SET_NULL,\n        related_name='+'\n    )\n    teaser = models.CharField(max_length=100)\n\n    def __str__(self):\n        return self.title\n\n    @cached_property\n    def num_entries(self):\n        num_comments = Comment.objects.all().count()\n        num_items = Item.objects.all().count()\n        return num_comments + num_items\n\n    @cached_property\n    def num_projects(self):\n        projects = Project.objects.all()\\\n            .filter(is_draft=False, is_archived=False, is_public=True)\n        active_project_count = 0\n        for project in projects:\n            if project.active_phase or project.future_phases:\n                active_project_count += 1\n        return active_project_count\n\n    @cached_property\n    def random_items(self):\n        items = self.items.all()\n        if items.count() > 3:\n            items_list = items.values_list('id', flat=True)\n            random_items = random.sample(list(items_list), 3)\n            return StorefrontItem.objects.filter(id__in=random_items)\n        else:\n            return items\n\n    title_panel = [\n        edit_handlers.FieldPanel('title')\n    ]\n\n    image_tile_panel = [\n        ImageChooserPanel('image'),\n        edit_handlers.FieldPanel('teaser')\n    ]\n\n    project_tiles_panel = [\n        edit_handlers.InlinePanel('items', min_num=3)\n    ]\n\n    edit_handler = edit_handlers.TabbedInterface([\n        edit_handlers.ObjectList(title_panel, heading='Title'),\n        edit_handlers.ObjectList(image_tile_panel, heading='Image Tile'),\n        edit_handlers.ObjectList(project_tiles_panel, heading='Project Tiles')\n    ])\n\n\nclass StorefrontCollection(StorefrontItem):\n    parent = ParentalKey('meinberlin_cms.Storefront', related_name='items')\n", "path": "meinberlin/apps/cms/models/storefronts.py"}]}