We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
changing group of plan in django does not work
I cannot change the group of a plan in django. Dropdown is there but changes won't be saved.

--- 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/plans/admin.py`
Content:
```
1 from django.contrib import admin
2 
3 from . import models
4 
5 
6 @admin.register(models.Plan)
7 class OfflineEventAdmin(admin.ModelAdmin):
8     list_display = ('__str__', 'organisation', 'created')
9 
10     date_hierarchy = 'created'
11     search_fields = ('title',)
12     readonly_fields = ('creator', )
13
```

Path: `meinberlin/apps/plans/forms.py`
Content:
```
1 from django import forms
2 from django.conf import settings
3 from django.utils.translation import ugettext_lazy as _
4 
5 from adhocracy4.dashboard.components.forms import ProjectDashboardForm
6 from adhocracy4.maps import widgets as maps_widgets
7 from adhocracy4.projects import models as project_models
8 
9 from . import models
10 
11 
12 class PlanForm(forms.ModelForm):
13 
14     class Meta:
15         model = models.Plan
16         fields = [
17             'title',
18             'description_image',
19             'contact',
20             'point',
21             'point_label',
22             'district',
23             'cost',
24             'description',
25             'topics',
26             'status',
27             'participation']
28         widgets = {
29             'point': maps_widgets.MapChoosePointWidget(
30                 polygon=settings.BERLIN_POLYGON)
31         }
32         error_messages = {
33             'point': {
34                 'required': _('Please locate the plan on the map.')
35             }
36         }
37 
38     def __init__(self, *args, **kwargs):
39         super().__init__(*args, **kwargs)
40         self.fields['district'].empty_label = _('City wide')
41 
42 
43 class CustomMultipleChoiceField(forms.ModelMultipleChoiceField):
44 
45     widget = forms.Select
46 
47     def clean(self, value):
48         if not value:
49             return super().clean([])
50         return super().clean([value])
51 
52 
53 class ProjectPlansDashboardForm(ProjectDashboardForm):
54     plans = CustomMultipleChoiceField(queryset=None,
55                                       label=_('Plans'))
56 
57     class Meta:
58         model = project_models.Project
59         fields = ['plans']
60         required = False
61 
62     def save(self, commit=False):
63         plans = self.cleaned_data['plans']
64         self.instance.plans.set(plans)
65 
66     def __init__(self, *args, **kwargs):
67         super().__init__(*args, **kwargs)
68         self.initial['plans'] = self.instance.plans.all()
69         self.fields['plans'].required = False
70         self.fields['plans'].empty_label = '----------'
71         self.fields['plans'].queryset = \
72             self.instance.organisation.plan_set.all()
73
```

Path: `meinberlin/apps/plans/models.py`
Content:
```
1 from ckeditor.fields import RichTextField
2 from django.conf import settings
3 from django.contrib.auth.models import Group
4 from django.core.urlresolvers import reverse
5 from django.db import models
6 from django.utils.functional import cached_property
7 from django.utils.translation import ugettext_lazy as _
8 
9 from adhocracy4 import transforms
10 from adhocracy4.administrative_districts.models import AdministrativeDistrict
11 from adhocracy4.images.fields import ConfiguredImageField
12 from adhocracy4.maps import fields as map_fields
13 from adhocracy4.models.base import UserGeneratedContentModel
14 from adhocracy4.phases.models import Phase
15 from adhocracy4.projects import models as project_models
16 from adhocracy4.projects.fields import TopicField
17 
18 
19 class Plan(UserGeneratedContentModel):
20 
21     PARTICIPATION_YES = 0
22     PARTICIPATION_NO = 1
23     PARTICIPATION_UNDECIDED = 2
24     PARTICIPATION_CHOICES = (
25         (PARTICIPATION_YES, _('with')),
26         (PARTICIPATION_NO, _('without')),
27         (PARTICIPATION_UNDECIDED, _('undecided')),
28     )
29 
30     STATUS_ONGOING = 0
31     STATUS_DONE = 1
32 
33     STATUS_CHOICES = (
34         (STATUS_ONGOING, _('running')),
35         (STATUS_DONE, _('done'))
36     )
37 
38     title = models.CharField(max_length=120, verbose_name=_('Title'))
39     organisation = models.ForeignKey(
40         settings.A4_ORGANISATIONS_MODEL,
41         on_delete=models.CASCADE,
42         verbose_name=_('Organisation'))
43     projects = models.ManyToManyField(
44         project_models.Project,
45         related_name='plans',
46         blank=True
47     )
48     group = models.ForeignKey(
49         Group,
50         on_delete=models.SET_NULL,
51         blank=True,
52         null=True)
53     point = map_fields.PointField(
54         verbose_name=_('Where can the plan be located on a map?'),
55         help_text=_('Click inside the marked area '
56                     'or type in an address to set the marker. A set '
57                     'marker can be dragged when pressed.'))
58     point_label = models.CharField(
59         default='',
60         max_length=255,
61         verbose_name=_('Label of the location'),
62         help_text=_('The label of the location is '
63                     'displayed in the detail view of the plan'),
64     )
65     district = models.ForeignKey(
66         AdministrativeDistrict,
67         verbose_name=_('District'),
68         null=True,
69         blank=True
70     )
71     contact = models.TextField(max_length=1000, verbose_name=_('Contact'))
72     cost = models.CharField(
73         blank=True,
74         null=True,
75         max_length=255,
76         verbose_name=_('Cost'))
77     description = RichTextField(verbose_name=_('Description'))
78     description_image = ConfiguredImageField(
79         'plan_image',
80         verbose_name=_('Add image'),
81         upload_to='plan/description_image',
82         blank=True,
83         help_prefix=_(
84             'Visualize your plan.'
85         ),
86     )
87     topics = TopicField(
88         verbose_name=_('Topics'),
89         help_text=_('Add topics to your project.'))
90     status = models.SmallIntegerField(
91         choices=STATUS_CHOICES,
92         verbose_name=_('Status')
93     )
94     participation = models.SmallIntegerField(
95         choices=PARTICIPATION_CHOICES,
96         verbose_name=_('Participation')
97     )
98 
99     class Meta:
100         ordering = ['-created']
101 
102     @property
103     def reference_number(self):
104         return '{:d}-{:05d}'.format(self.created.year, self.pk)
105 
106     @property
107     def administrative_district(self):
108         return self.district
109 
110     @property
111     def topic_names(self):
112         if hasattr(settings, 'A4_PROJECT_TOPICS'):
113             choices = dict(settings.A4_PROJECT_TOPICS)
114             return [choices[topic] for topic in self.topics]
115         return []
116 
117     @cached_property
118     def published_projects(self):
119         return self.projects.filter(
120             is_draft=False, is_public=True, is_archived=False)
121 
122     @cached_property
123     def participation_string(self):
124         project_list = self.published_projects.values_list('id', flat=True)
125         phases_in_plan = Phase.objects\
126             .select_related('module__project')\
127             .filter(module__project_id__in=project_list)\
128             .order_by('-start_date')
129 
130         if phases_in_plan.active_phases():
131             return _('running')
132 
133         future_phases_with_start_date = phases_in_plan.future_phases()\
134             .exclude(start_date__isnull=True)
135 
136         if future_phases_with_start_date:
137             future_phase = future_phases_with_start_date.first()
138             return _('starts at {}')\
139                 .format(future_phase.start_date.strftime('%d.%m.%Y'))
140 
141     def __str__(self):
142         return self.title
143 
144     def get_absolute_url(self):
145         return reverse('meinberlin_plans:plan-detail',
146                        kwargs=dict(pk='{:05d}'.format(self.pk),
147                                    year=self.created.year))
148 
149     def save(self, *args, **kwargs):
150         self.description = transforms.clean_html_field(self.description)
151         self.group = self._get_group(self.creator, self.organisation)
152         super().save(*args, **kwargs)
153 
154     def _get_group(self, user, organisation):
155         user_groups = user.groups.all()
156         org_groups = organisation.groups.all()
157         shared_groups = user_groups & org_groups
158         return shared_groups.distinct().first()
159 
160     def is_group_member(self, user):
161         if self.group:
162             return user.groups.filter(id=self.group.id).exists()
163         return False
164
```
--- 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()

```

diff --git a/meinberlin/apps/plans/admin.py b/meinberlin/apps/plans/admin.py
--- a/meinberlin/apps/plans/admin.py
+++ b/meinberlin/apps/plans/admin.py
@@ -4,7 +4,7 @@
 
 
 @admin.register(models.Plan)
-class OfflineEventAdmin(admin.ModelAdmin):
+class PlanAdmin(admin.ModelAdmin):
     list_display = ('__str__', 'organisation', 'created')
 
     date_hierarchy = 'created'
diff --git a/meinberlin/apps/plans/forms.py b/meinberlin/apps/plans/forms.py
--- a/meinberlin/apps/plans/forms.py
+++ b/meinberlin/apps/plans/forms.py
@@ -39,6 +39,14 @@
         super().__init__(*args, **kwargs)
         self.fields['district'].empty_label = _('City wide')
 
+    def save(self, commit=True):
+        plan = super().save(commit=False)
+        group = plan._get_group(plan.creator, plan.organisation)
+        plan.group = group
+        if commit:
+            plan.save()
+        return plan
+
 
 class CustomMultipleChoiceField(forms.ModelMultipleChoiceField):
 
diff --git a/meinberlin/apps/plans/models.py b/meinberlin/apps/plans/models.py
--- a/meinberlin/apps/plans/models.py
+++ b/meinberlin/apps/plans/models.py
@@ -148,7 +148,6 @@
 
     def save(self, *args, **kwargs):
         self.description = transforms.clean_html_field(self.description)
-        self.group = self._get_group(self.creator, self.organisation)
         super().save(*args, **kwargs)
 
     def _get_group(self, user, organisation):

{"golden_diff": "diff --git a/meinberlin/apps/plans/admin.py b/meinberlin/apps/plans/admin.py\n--- a/meinberlin/apps/plans/admin.py\n+++ b/meinberlin/apps/plans/admin.py\n@@ -4,7 +4,7 @@\n \n \n @admin.register(models.Plan)\n-class OfflineEventAdmin(admin.ModelAdmin):\n+class PlanAdmin(admin.ModelAdmin):\n     list_display = ('__str__', 'organisation', 'created')\n \n     date_hierarchy = 'created'\ndiff --git a/meinberlin/apps/plans/forms.py b/meinberlin/apps/plans/forms.py\n--- a/meinberlin/apps/plans/forms.py\n+++ b/meinberlin/apps/plans/forms.py\n@@ -39,6 +39,14 @@\n         super().__init__(*args, **kwargs)\n         self.fields['district'].empty_label = _('City wide')\n \n+    def save(self, commit=True):\n+        plan = super().save(commit=False)\n+        group = plan._get_group(plan.creator, plan.organisation)\n+        plan.group = group\n+        if commit:\n+            plan.save()\n+        return plan\n+\n \n class CustomMultipleChoiceField(forms.ModelMultipleChoiceField):\n \ndiff --git a/meinberlin/apps/plans/models.py b/meinberlin/apps/plans/models.py\n--- a/meinberlin/apps/plans/models.py\n+++ b/meinberlin/apps/plans/models.py\n@@ -148,7 +148,6 @@\n \n     def save(self, *args, **kwargs):\n         self.description = transforms.clean_html_field(self.description)\n-        self.group = self._get_group(self.creator, self.organisation)\n         super().save(*args, **kwargs)\n \n     def _get_group(self, user, organisation):\n", "issue": "changing group of plan in django does not work\nI cannot change the group of a plan in django. Dropdown is there but changes won't be saved.\n", "before_files": [{"content": "from django.contrib import admin\n\nfrom . import models\n\n\n@admin.register(models.Plan)\nclass OfflineEventAdmin(admin.ModelAdmin):\n    list_display = ('__str__', 'organisation', 'created')\n\n    date_hierarchy = 'created'\n    search_fields = ('title',)\n    readonly_fields = ('creator', )\n", "path": "meinberlin/apps/plans/admin.py"}, {"content": "from django import forms\nfrom django.conf import settings\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom adhocracy4.dashboard.components.forms import ProjectDashboardForm\nfrom adhocracy4.maps import widgets as maps_widgets\nfrom adhocracy4.projects import models as project_models\n\nfrom . import models\n\n\nclass PlanForm(forms.ModelForm):\n\n    class Meta:\n        model = models.Plan\n        fields = [\n            'title',\n            'description_image',\n            'contact',\n            'point',\n            'point_label',\n            'district',\n            'cost',\n            'description',\n            'topics',\n            'status',\n            'participation']\n        widgets = {\n            'point': maps_widgets.MapChoosePointWidget(\n                polygon=settings.BERLIN_POLYGON)\n        }\n        error_messages = {\n            'point': {\n                'required': _('Please locate the plan on the map.')\n            }\n        }\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.fields['district'].empty_label = _('City wide')\n\n\nclass CustomMultipleChoiceField(forms.ModelMultipleChoiceField):\n\n    widget = forms.Select\n\n    def clean(self, value):\n        if not value:\n            return super().clean([])\n        return super().clean([value])\n\n\nclass ProjectPlansDashboardForm(ProjectDashboardForm):\n    plans = CustomMultipleChoiceField(queryset=None,\n                                      label=_('Plans'))\n\n    class Meta:\n        model = project_models.Project\n        fields = ['plans']\n        required = False\n\n    def save(self, commit=False):\n        plans = self.cleaned_data['plans']\n        self.instance.plans.set(plans)\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.initial['plans'] = self.instance.plans.all()\n        self.fields['plans'].required = False\n        self.fields['plans'].empty_label = '----------'\n        self.fields['plans'].queryset = \\\n            self.instance.organisation.plan_set.all()\n", "path": "meinberlin/apps/plans/forms.py"}, {"content": "from ckeditor.fields import RichTextField\nfrom django.conf import settings\nfrom django.contrib.auth.models import Group\nfrom django.core.urlresolvers import reverse\nfrom django.db import models\nfrom django.utils.functional import cached_property\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom adhocracy4 import transforms\nfrom adhocracy4.administrative_districts.models import AdministrativeDistrict\nfrom adhocracy4.images.fields import ConfiguredImageField\nfrom adhocracy4.maps import fields as map_fields\nfrom adhocracy4.models.base import UserGeneratedContentModel\nfrom adhocracy4.phases.models import Phase\nfrom adhocracy4.projects import models as project_models\nfrom adhocracy4.projects.fields import TopicField\n\n\nclass Plan(UserGeneratedContentModel):\n\n    PARTICIPATION_YES = 0\n    PARTICIPATION_NO = 1\n    PARTICIPATION_UNDECIDED = 2\n    PARTICIPATION_CHOICES = (\n        (PARTICIPATION_YES, _('with')),\n        (PARTICIPATION_NO, _('without')),\n        (PARTICIPATION_UNDECIDED, _('undecided')),\n    )\n\n    STATUS_ONGOING = 0\n    STATUS_DONE = 1\n\n    STATUS_CHOICES = (\n        (STATUS_ONGOING, _('running')),\n        (STATUS_DONE, _('done'))\n    )\n\n    title = models.CharField(max_length=120, verbose_name=_('Title'))\n    organisation = models.ForeignKey(\n        settings.A4_ORGANISATIONS_MODEL,\n        on_delete=models.CASCADE,\n        verbose_name=_('Organisation'))\n    projects = models.ManyToManyField(\n        project_models.Project,\n        related_name='plans',\n        blank=True\n    )\n    group = models.ForeignKey(\n        Group,\n        on_delete=models.SET_NULL,\n        blank=True,\n        null=True)\n    point = map_fields.PointField(\n        verbose_name=_('Where can the plan be located on a map?'),\n        help_text=_('Click inside the marked area '\n                    'or type in an address to set the marker. A set '\n                    'marker can be dragged when pressed.'))\n    point_label = models.CharField(\n        default='',\n        max_length=255,\n        verbose_name=_('Label of the location'),\n        help_text=_('The label of the location is '\n                    'displayed in the detail view of the plan'),\n    )\n    district = models.ForeignKey(\n        AdministrativeDistrict,\n        verbose_name=_('District'),\n        null=True,\n        blank=True\n    )\n    contact = models.TextField(max_length=1000, verbose_name=_('Contact'))\n    cost = models.CharField(\n        blank=True,\n        null=True,\n        max_length=255,\n        verbose_name=_('Cost'))\n    description = RichTextField(verbose_name=_('Description'))\n    description_image = ConfiguredImageField(\n        'plan_image',\n        verbose_name=_('Add image'),\n        upload_to='plan/description_image',\n        blank=True,\n        help_prefix=_(\n            'Visualize your plan.'\n        ),\n    )\n    topics = TopicField(\n        verbose_name=_('Topics'),\n        help_text=_('Add topics to your project.'))\n    status = models.SmallIntegerField(\n        choices=STATUS_CHOICES,\n        verbose_name=_('Status')\n    )\n    participation = models.SmallIntegerField(\n        choices=PARTICIPATION_CHOICES,\n        verbose_name=_('Participation')\n    )\n\n    class Meta:\n        ordering = ['-created']\n\n    @property\n    def reference_number(self):\n        return '{:d}-{:05d}'.format(self.created.year, self.pk)\n\n    @property\n    def administrative_district(self):\n        return self.district\n\n    @property\n    def topic_names(self):\n        if hasattr(settings, 'A4_PROJECT_TOPICS'):\n            choices = dict(settings.A4_PROJECT_TOPICS)\n            return [choices[topic] for topic in self.topics]\n        return []\n\n    @cached_property\n    def published_projects(self):\n        return self.projects.filter(\n            is_draft=False, is_public=True, is_archived=False)\n\n    @cached_property\n    def participation_string(self):\n        project_list = self.published_projects.values_list('id', flat=True)\n        phases_in_plan = Phase.objects\\\n            .select_related('module__project')\\\n            .filter(module__project_id__in=project_list)\\\n            .order_by('-start_date')\n\n        if phases_in_plan.active_phases():\n            return _('running')\n\n        future_phases_with_start_date = phases_in_plan.future_phases()\\\n            .exclude(start_date__isnull=True)\n\n        if future_phases_with_start_date:\n            future_phase = future_phases_with_start_date.first()\n            return _('starts at {}')\\\n                .format(future_phase.start_date.strftime('%d.%m.%Y'))\n\n    def __str__(self):\n        return self.title\n\n    def get_absolute_url(self):\n        return reverse('meinberlin_plans:plan-detail',\n                       kwargs=dict(pk='{:05d}'.format(self.pk),\n                                   year=self.created.year))\n\n    def save(self, *args, **kwargs):\n        self.description = transforms.clean_html_field(self.description)\n        self.group = self._get_group(self.creator, self.organisation)\n        super().save(*args, **kwargs)\n\n    def _get_group(self, user, organisation):\n        user_groups = user.groups.all()\n        org_groups = organisation.groups.all()\n        shared_groups = user_groups & org_groups\n        return shared_groups.distinct().first()\n\n    def is_group_member(self, user):\n        if self.group:\n            return user.groups.filter(id=self.group.id).exists()\n        return False\n", "path": "meinberlin/apps/plans/models.py"}], "after_files": [{"content": "from django.contrib import admin\n\nfrom . import models\n\n\n@admin.register(models.Plan)\nclass PlanAdmin(admin.ModelAdmin):\n    list_display = ('__str__', 'organisation', 'created')\n\n    date_hierarchy = 'created'\n    search_fields = ('title',)\n    readonly_fields = ('creator', )\n", "path": "meinberlin/apps/plans/admin.py"}, {"content": "from django import forms\nfrom django.conf import settings\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom adhocracy4.dashboard.components.forms import ProjectDashboardForm\nfrom adhocracy4.maps import widgets as maps_widgets\nfrom adhocracy4.projects import models as project_models\n\nfrom . import models\n\n\nclass PlanForm(forms.ModelForm):\n\n    class Meta:\n        model = models.Plan\n        fields = [\n            'title',\n            'description_image',\n            'contact',\n            'point',\n            'point_label',\n            'district',\n            'cost',\n            'description',\n            'topics',\n            'status',\n            'participation']\n        widgets = {\n            'point': maps_widgets.MapChoosePointWidget(\n                polygon=settings.BERLIN_POLYGON)\n        }\n        error_messages = {\n            'point': {\n                'required': _('Please locate the plan on the map.')\n            }\n        }\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.fields['district'].empty_label = _('City wide')\n\n    def save(self, commit=True):\n        plan = super().save(commit=False)\n        group = plan._get_group(plan.creator, plan.organisation)\n        plan.group = group\n        if commit:\n            plan.save()\n        return plan\n\n\nclass CustomMultipleChoiceField(forms.ModelMultipleChoiceField):\n\n    widget = forms.Select\n\n    def clean(self, value):\n        if not value:\n            return super().clean([])\n        return super().clean([value])\n\n\nclass ProjectPlansDashboardForm(ProjectDashboardForm):\n    plans = CustomMultipleChoiceField(queryset=None,\n                                      label=_('Plans'))\n\n    class Meta:\n        model = project_models.Project\n        fields = ['plans']\n        required = False\n\n    def save(self, commit=False):\n        plans = self.cleaned_data['plans']\n        self.instance.plans.set(plans)\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.initial['plans'] = self.instance.plans.all()\n        self.fields['plans'].required = False\n        self.fields['plans'].empty_label = '----------'\n        self.fields['plans'].queryset = \\\n            self.instance.organisation.plan_set.all()\n", "path": "meinberlin/apps/plans/forms.py"}, {"content": "from ckeditor.fields import RichTextField\nfrom django.conf import settings\nfrom django.contrib.auth.models import Group\nfrom django.core.urlresolvers import reverse\nfrom django.db import models\nfrom django.utils.functional import cached_property\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom adhocracy4 import transforms\nfrom adhocracy4.administrative_districts.models import AdministrativeDistrict\nfrom adhocracy4.images.fields import ConfiguredImageField\nfrom adhocracy4.maps import fields as map_fields\nfrom adhocracy4.models.base import UserGeneratedContentModel\nfrom adhocracy4.phases.models import Phase\nfrom adhocracy4.projects import models as project_models\nfrom adhocracy4.projects.fields import TopicField\n\n\nclass Plan(UserGeneratedContentModel):\n\n    PARTICIPATION_YES = 0\n    PARTICIPATION_NO = 1\n    PARTICIPATION_UNDECIDED = 2\n    PARTICIPATION_CHOICES = (\n        (PARTICIPATION_YES, _('with')),\n        (PARTICIPATION_NO, _('without')),\n        (PARTICIPATION_UNDECIDED, _('undecided')),\n    )\n\n    STATUS_ONGOING = 0\n    STATUS_DONE = 1\n\n    STATUS_CHOICES = (\n        (STATUS_ONGOING, _('running')),\n        (STATUS_DONE, _('done'))\n    )\n\n    title = models.CharField(max_length=120, verbose_name=_('Title'))\n    organisation = models.ForeignKey(\n        settings.A4_ORGANISATIONS_MODEL,\n        on_delete=models.CASCADE,\n        verbose_name=_('Organisation'))\n    projects = models.ManyToManyField(\n        project_models.Project,\n        related_name='plans',\n        blank=True\n    )\n    group = models.ForeignKey(\n        Group,\n        on_delete=models.SET_NULL,\n        blank=True,\n        null=True)\n    point = map_fields.PointField(\n        verbose_name=_('Where can the plan be located on a map?'),\n        help_text=_('Click inside the marked area '\n                    'or type in an address to set the marker. A set '\n                    'marker can be dragged when pressed.'))\n    point_label = models.CharField(\n        default='',\n        max_length=255,\n        verbose_name=_('Label of the location'),\n        help_text=_('The label of the location is '\n                    'displayed in the detail view of the plan'),\n    )\n    district = models.ForeignKey(\n        AdministrativeDistrict,\n        verbose_name=_('District'),\n        null=True,\n        blank=True\n    )\n    contact = models.TextField(max_length=1000, verbose_name=_('Contact'))\n    cost = models.CharField(\n        blank=True,\n        null=True,\n        max_length=255,\n        verbose_name=_('Cost'))\n    description = RichTextField(verbose_name=_('Description'))\n    description_image = ConfiguredImageField(\n        'plan_image',\n        verbose_name=_('Add image'),\n        upload_to='plan/description_image',\n        blank=True,\n        help_prefix=_(\n            'Visualize your plan.'\n        ),\n    )\n    topics = TopicField(\n        verbose_name=_('Topics'),\n        help_text=_('Add topics to your project.'))\n    status = models.SmallIntegerField(\n        choices=STATUS_CHOICES,\n        verbose_name=_('Status')\n    )\n    participation = models.SmallIntegerField(\n        choices=PARTICIPATION_CHOICES,\n        verbose_name=_('Participation')\n    )\n\n    class Meta:\n        ordering = ['-created']\n\n    @property\n    def reference_number(self):\n        return '{:d}-{:05d}'.format(self.created.year, self.pk)\n\n    @property\n    def administrative_district(self):\n        return self.district\n\n    @property\n    def topic_names(self):\n        if hasattr(settings, 'A4_PROJECT_TOPICS'):\n            choices = dict(settings.A4_PROJECT_TOPICS)\n            return [choices[topic] for topic in self.topics]\n        return []\n\n    @cached_property\n    def published_projects(self):\n        return self.projects.filter(\n            is_draft=False, is_public=True, is_archived=False)\n\n    @cached_property\n    def participation_string(self):\n        project_list = self.published_projects.values_list('id', flat=True)\n        phases_in_plan = Phase.objects\\\n            .select_related('module__project')\\\n            .filter(module__project_id__in=project_list)\\\n            .order_by('-start_date')\n\n        if phases_in_plan.active_phases():\n            return _('running')\n\n        future_phases_with_start_date = phases_in_plan.future_phases()\\\n            .exclude(start_date__isnull=True)\n\n        if future_phases_with_start_date:\n            future_phase = future_phases_with_start_date.first()\n            return _('starts at {}')\\\n                .format(future_phase.start_date.strftime('%d.%m.%Y'))\n\n    def __str__(self):\n        return self.title\n\n    def get_absolute_url(self):\n        return reverse('meinberlin_plans:plan-detail',\n                       kwargs=dict(pk='{:05d}'.format(self.pk),\n                                   year=self.created.year))\n\n    def save(self, *args, **kwargs):\n        self.description = transforms.clean_html_field(self.description)\n        super().save(*args, **kwargs)\n\n    def _get_group(self, user, organisation):\n        user_groups = user.groups.all()\n        org_groups = organisation.groups.all()\n        shared_groups = user_groups & org_groups\n        return shared_groups.distinct().first()\n\n    def is_group_member(self, user):\n        if self.group:\n            return user.groups.filter(id=self.group.id).exists()\n        return False\n", "path": "meinberlin/apps/plans/models.py"}]}