prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  make it possible to detach plan from project
  now that a connection of a project with a plan is no longer obligatory, initiators need to be able to undo a connection. Once I click on a plan I can no longer NOT connect to a plan, which should be possible.
  
  ![image](https://user-images.githubusercontent.com/35491681/47439596-f041f000-d7ac-11e8-85f8-13407e97ada3.png)
  
  
  </issue>
  <code>
  [start of meinberlin/apps/plans/forms.py]
  1 from django import forms
  2 from django.conf import settings
  3 from django.db.models import Q
  4 from django.utils.translation import ugettext_lazy as _
  5 
  6 from adhocracy4.dashboard.components.forms import ProjectDashboardForm
  7 from adhocracy4.maps import widgets as maps_widgets
  8 from adhocracy4.projects import models as project_models
  9 from meinberlin.apps.contrib import widgets as contrib_widgets
  10 
  11 from . import models
  12 
  13 
  14 def get_theme_options():
  15     return models.Plan.objects\
  16         .filter(~Q(theme=''))\
  17         .order_by('theme')\
  18         .values_list('theme', flat=True)\
  19         .distinct()
  20 
  21 
  22 class PlanForm(forms.ModelForm):
  23 
  24     class Meta:
  25         model = models.Plan
  26         fields = [
  27             'title',
  28             'description_image',
  29             'contact',
  30             'point',
  31             'point_label',
  32             'district',
  33             'cost',
  34             'description',
  35             'theme',
  36             'status',
  37             'participation']
  38         widgets = {
  39             'point': maps_widgets.MapChoosePointWidget(
  40                 polygon=settings.BERLIN_POLYGON),
  41             'theme': contrib_widgets.TextWithDatalistWidget(attrs={
  42                 'options': get_theme_options
  43             })
  44         }
  45         error_messages = {
  46             'point': {
  47                 'required': _('Please locate the plan on the map.')
  48             }
  49         }
  50 
  51     def __init__(self, *args, **kwargs):
  52         super().__init__(*args, **kwargs)
  53         self.fields['district'].empty_label = _('City wide')
  54 
  55 
  56 class CustomMultipleChoiceField(forms.ModelMultipleChoiceField):
  57 
  58     widget = forms.RadioSelect
  59 
  60     def clean(self, value):
  61         if value is None:
  62             return super().clean([])
  63         return super().clean([value])
  64 
  65 
  66 class ProjectPlansDashboardForm(ProjectDashboardForm):
  67     plans = CustomMultipleChoiceField(queryset=None,
  68                                       label=_('Plans'))
  69 
  70     class Meta:
  71         model = project_models.Project
  72         fields = ['plans']
  73         required = False
  74 
  75     def save(self, commit=False):
  76         plans = self.cleaned_data['plans']
  77         self.instance.plans.set(plans)
  78 
  79     def __init__(self, *args, **kwargs):
  80         super().__init__(*args, **kwargs)
  81         self.initial['plans'] = self.instance.plans.all()
  82         self.fields['plans'
  83                     ].queryset = self.instance.organisation.plan_set.all()
  84
  [end of meinberlin/apps/plans/forms.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/plans/forms.py b/meinberlin/apps/plans/forms.py
  --- a/meinberlin/apps/plans/forms.py
  +++ b/meinberlin/apps/plans/forms.py
  @@ -55,10 +55,10 @@
   
   class CustomMultipleChoiceField(forms.ModelMultipleChoiceField):
   
  -    widget = forms.RadioSelect
  +    widget = forms.Select
   
       def clean(self, value):
  -        if value is None:
  +        if not value:
               return super().clean([])
           return super().clean([value])
   
  @@ -79,5 +79,7 @@
       def __init__(self, *args, **kwargs):
           super().__init__(*args, **kwargs)
           self.initial['plans'] = self.instance.plans.all()
  -        self.fields['plans'
  -                    ].queryset = self.instance.organisation.plan_set.all()
  +        self.fields['plans'].required = False
  +        self.fields['plans'].empty_label = '----------'
  +        self.fields['plans'].queryset = \
  +            self.instance.organisation.plan_set.all()
  
verification_info: {"golden_diff": "diff --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@@ -55,10 +55,10 @@\n \n class CustomMultipleChoiceField(forms.ModelMultipleChoiceField):\n \n-    widget = forms.RadioSelect\n+    widget = forms.Select\n \n     def clean(self, value):\n-        if value is None:\n+        if not value:\n             return super().clean([])\n         return super().clean([value])\n \n@@ -79,5 +79,7 @@\n     def __init__(self, *args, **kwargs):\n         super().__init__(*args, **kwargs)\n         self.initial['plans'] = self.instance.plans.all()\n-        self.fields['plans'\n-                    ].queryset = self.instance.organisation.plan_set.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", "issue": "make it possible to detach plan from project\nnow that a connection of a project with a plan is no longer obligatory, initiators need to be able to undo a connection. Once I click on a plan I can no longer NOT connect to a plan, which should be possible.\r\n\r\n![image](https://user-images.githubusercontent.com/35491681/47439596-f041f000-d7ac-11e8-85f8-13407e97ada3.png)\r\n\n", "before_files": [{"content": "from django import forms\nfrom django.conf import settings\nfrom django.db.models import Q\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\nfrom meinberlin.apps.contrib import widgets as contrib_widgets\n\nfrom . import models\n\n\ndef get_theme_options():\n    return models.Plan.objects\\\n        .filter(~Q(theme=''))\\\n        .order_by('theme')\\\n        .values_list('theme', flat=True)\\\n        .distinct()\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            'theme',\n            'status',\n            'participation']\n        widgets = {\n            'point': maps_widgets.MapChoosePointWidget(\n                polygon=settings.BERLIN_POLYGON),\n            'theme': contrib_widgets.TextWithDatalistWidget(attrs={\n                'options': get_theme_options\n            })\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.RadioSelect\n\n    def clean(self, value):\n        if value is None:\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'\n                    ].queryset = self.instance.organisation.plan_set.all()\n", "path": "meinberlin/apps/plans/forms.py"}]}