We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
User testing 2394: add module button placement and wording
URL: https://meinberlin-dev.liqd.net/dashboard/modules/
user: initiator/group member
expected behaviour:
behaviour: move 'add module' button to below the project menu and swap order of added modules so newest first, update wording to 'show in project'
important screensize: all
device & browser: all


--- 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/dashboard/views.py`
Content:
```
1 from django.apps import apps
2 from django.contrib import messages
3 from django.contrib.messages.views import SuccessMessageMixin
4 from django.http import HttpResponseRedirect
5 from django.urls import resolve
6 from django.urls import reverse
7 from django.utils.translation import ugettext_lazy as _
8 from django.views import generic
9 from django.views.generic.detail import SingleObjectMixin
10 
11 from adhocracy4.dashboard import mixins
12 from adhocracy4.dashboard import signals
13 from adhocracy4.dashboard import views as a4dashboard_views
14 from adhocracy4.dashboard.blueprints import get_blueprints
15 from adhocracy4.modules import models as module_models
16 from adhocracy4.phases import models as phase_models
17 from adhocracy4.projects import models as project_models
18 from adhocracy4.projects.mixins import ProjectMixin
19 from meinberlin.apps.dashboard.forms import DashboardProjectCreateForm
20 
21 
22 class ModuleBlueprintListView(ProjectMixin,
23                               mixins.DashboardBaseMixin,
24                               mixins.BlueprintMixin,
25                               generic.DetailView):
26     template_name = 'meinberlin_dashboard/module_blueprint_list_dashboard.html'
27     permission_required = 'a4projects.change_project'
28     model = project_models.Project
29     slug_url_kwarg = 'project_slug'
30     menu_item = 'project'
31 
32     @property
33     def blueprints(self):
34         return get_blueprints()
35 
36     def get_permission_object(self):
37         return self.project
38 
39 
40 class ModuleCreateView(ProjectMixin,
41                        mixins.DashboardBaseMixin,
42                        mixins.BlueprintMixin,
43                        SingleObjectMixin,
44                        generic.View):
45     permission_required = 'a4projects.change_project'
46     model = project_models.Project
47     slug_url_kwarg = 'project_slug'
48 
49     def post(self, request, *args, **kwargs):
50         project = self.get_object()
51         weight = 1
52         if project.modules:
53             weight = max(
54                 project.modules.values_list('weight', flat=True)
55             ) + 1
56         module = module_models.Module(
57             name=self.blueprint.title,
58             weight=weight,
59             project=project,
60             is_draft=True,
61         )
62         module.save()
63         signals.module_created.send(sender=None,
64                                     module=module,
65                                     user=self.request.user)
66 
67         self._create_module_settings(module)
68         self._create_phases(module, self.blueprint.content)
69 
70         return HttpResponseRedirect(self.get_next(module))
71 
72     def _create_module_settings(self, module):
73         if self.blueprint.settings_model:
74             settings_model = apps.get_model(*self.blueprint.settings_model)
75             module_settings = settings_model(module=module)
76             module_settings.save()
77 
78     def _create_phases(self, module, blueprint_phases):
79         for index, phase_content in enumerate(blueprint_phases):
80             phase = phase_models.Phase(
81                 type=phase_content.identifier,
82                 name=phase_content.name,
83                 description=phase_content.description,
84                 weight=index,
85                 module=module,
86             )
87             phase.save()
88 
89     def get_next(self, module):
90         return reverse('a4dashboard:dashboard-module_basic-edit', kwargs={
91             'module_slug': module.slug
92         })
93 
94     def get_permission_object(self):
95         return self.project
96 
97 
98 class ModulePublishView(SingleObjectMixin,
99                         generic.View):
100     permission_required = 'a4projects.change_project'
101     model = module_models.Module
102     slug_url_kwarg = 'module_slug'
103 
104     def get_permission_object(self):
105         return self.get_object().project
106 
107     def post(self, request, *args, **kwargs):
108         action = request.POST.get('action', None)
109         if action == 'publish':
110             self.publish_module()
111         elif action == 'unpublish':
112             self.unpublish_module()
113         else:
114             messages.warning(self.request, _('Invalid action'))
115 
116         return HttpResponseRedirect(self.get_next())
117 
118     def get_next(self):
119         if 'referrer' in self.request.POST:
120             return self.request.POST['referrer']
121         elif 'HTTP_REFERER' in self.request.META:
122             return self.request.META['HTTP_REFERER']
123 
124         return reverse('a4dashboard:project-edit', kwargs={
125             'project_slug': self.project.slug
126         })
127 
128     def publish_module(self):
129         module = self.get_object()
130         if not module.is_draft:
131             messages.info(self.request, _('Module is already added'))
132             return
133 
134         module.is_draft = False
135         module.save()
136 
137         signals.module_published.send(sender=None,
138                                       module=module,
139                                       user=self.request.user)
140 
141         messages.success(self.request,
142                          _('Module successfully added.'))
143 
144     def unpublish_module(self):
145         module = self.get_object()
146         if module.is_draft:
147             messages.info(self.request, _('Module is already removed'))
148             return
149 
150         module.is_draft = True
151         module.save()
152 
153         signals.module_unpublished.send(sender=None,
154                                         module=module,
155                                         user=self.request.user)
156 
157         messages.success(self.request,
158                          _('Module successfully removed.'))
159 
160 
161 class ModuleDeleteView(generic.DeleteView):
162     permission_required = 'a4projects.change_project'
163     model = module_models.Module
164     success_message = _('The module has been deleted')
165 
166     def delete(self, request, *args, **kwargs):
167         messages.success(self.request, self.success_message)
168         return super().delete(request, *args, **kwargs)
169 
170     def get_permission_object(self):
171         return self.get_object().project
172 
173     def get_success_url(self):
174         referrer = self.request.POST.get('referrer', None) \
175             or self.request.META.get('HTTP_REFERER', None)
176         if referrer:
177             view, args, kwargs = resolve(referrer)
178             if 'module_slug' not in kwargs \
179                     or not kwargs['module_slug'] == self.get_object().slug:
180                 return referrer
181 
182         return reverse('a4dashboard:project-edit', kwargs={
183             'project_slug': self.get_object().project.slug
184         })
185 
186 
187 class DashboardProjectListView(a4dashboard_views.ProjectListView):
188     def get_queryset(self):
189         return super().get_queryset().filter(
190             projectcontainer=None,
191             externalproject=None
192         )
193 
194 
195 class ProjectCreateView(mixins.DashboardBaseMixin,
196                         SuccessMessageMixin,
197                         generic.CreateView):
198     model = project_models.Project
199     slug_url_kwarg = 'project_slug'
200     form_class = DashboardProjectCreateForm
201     template_name = 'a4dashboard/project_create_form.html'
202     permission_required = 'a4projects.add_project'
203     menu_item = 'project'
204     success_message = _('Project successfully created.')
205 
206     def get_permission_object(self):
207         return self.organisation
208 
209     def get_form_kwargs(self):
210         kwargs = super().get_form_kwargs()
211         kwargs['organisation'] = self.organisation
212         kwargs['creator'] = self.request.user
213         return kwargs
214 
215     def get_success_url(self):
216         return reverse('a4dashboard:project-edit',
217                        kwargs={'project_slug': self.object.slug})
218 
219     def form_valid(self, form):
220         response = super().form_valid(form)
221         signals.project_created.send(sender=None,
222                                      project=self.object,
223                                      user=self.request.user)
224 
225         return response
226
```
--- 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/dashboard/views.py b/meinberlin/apps/dashboard/views.py
--- a/meinberlin/apps/dashboard/views.py
+++ b/meinberlin/apps/dashboard/views.py
@@ -67,7 +67,14 @@
         self._create_module_settings(module)
         self._create_phases(module, self.blueprint.content)
 
-        return HttpResponseRedirect(self.get_next(module))
+        closed = request.COOKIES.get('closed_accordeons', '')
+        closed_project_accordeon = \
+            'dashboard-nav__project--{}'.format(str(self.project.id))
+        if closed_project_accordeon not in closed:
+            closed = closed_project_accordeon + closed
+        response = HttpResponseRedirect(self.get_next(module))
+        response.set_cookie('closed_accordeons', closed)
+        return response
 
     def _create_module_settings(self, module):
         if self.blueprint.settings_model:

{"golden_diff": "diff --git a/meinberlin/apps/dashboard/views.py b/meinberlin/apps/dashboard/views.py\n--- a/meinberlin/apps/dashboard/views.py\n+++ b/meinberlin/apps/dashboard/views.py\n@@ -67,7 +67,14 @@\n         self._create_module_settings(module)\n         self._create_phases(module, self.blueprint.content)\n \n-        return HttpResponseRedirect(self.get_next(module))\n+        closed = request.COOKIES.get('closed_accordeons', '')\n+        closed_project_accordeon = \\\n+            'dashboard-nav__project--{}'.format(str(self.project.id))\n+        if closed_project_accordeon not in closed:\n+            closed = closed_project_accordeon + closed\n+        response = HttpResponseRedirect(self.get_next(module))\n+        response.set_cookie('closed_accordeons', closed)\n+        return response\n \n     def _create_module_settings(self, module):\n         if self.blueprint.settings_model:\n", "issue": "User testing 2394: add module button placement and wording\nURL: https://meinberlin-dev.liqd.net/dashboard/modules/\r\nuser: initiator/group member\r\nexpected behaviour:\r\nbehaviour: move 'add module' button to below the project menu and swap order of added modules so newest first, update wording to 'show in project'\r\nimportant screensize: all\r\ndevice & browser: all\r\n\n", "before_files": [{"content": "from django.apps import apps\nfrom django.contrib import messages\nfrom django.contrib.messages.views import SuccessMessageMixin\nfrom django.http import HttpResponseRedirect\nfrom django.urls import resolve\nfrom django.urls import reverse\nfrom django.utils.translation import ugettext_lazy as _\nfrom django.views import generic\nfrom django.views.generic.detail import SingleObjectMixin\n\nfrom adhocracy4.dashboard import mixins\nfrom adhocracy4.dashboard import signals\nfrom adhocracy4.dashboard import views as a4dashboard_views\nfrom adhocracy4.dashboard.blueprints import get_blueprints\nfrom adhocracy4.modules import models as module_models\nfrom adhocracy4.phases import models as phase_models\nfrom adhocracy4.projects import models as project_models\nfrom adhocracy4.projects.mixins import ProjectMixin\nfrom meinberlin.apps.dashboard.forms import DashboardProjectCreateForm\n\n\nclass ModuleBlueprintListView(ProjectMixin,\n                              mixins.DashboardBaseMixin,\n                              mixins.BlueprintMixin,\n                              generic.DetailView):\n    template_name = 'meinberlin_dashboard/module_blueprint_list_dashboard.html'\n    permission_required = 'a4projects.change_project'\n    model = project_models.Project\n    slug_url_kwarg = 'project_slug'\n    menu_item = 'project'\n\n    @property\n    def blueprints(self):\n        return get_blueprints()\n\n    def get_permission_object(self):\n        return self.project\n\n\nclass ModuleCreateView(ProjectMixin,\n                       mixins.DashboardBaseMixin,\n                       mixins.BlueprintMixin,\n                       SingleObjectMixin,\n                       generic.View):\n    permission_required = 'a4projects.change_project'\n    model = project_models.Project\n    slug_url_kwarg = 'project_slug'\n\n    def post(self, request, *args, **kwargs):\n        project = self.get_object()\n        weight = 1\n        if project.modules:\n            weight = max(\n                project.modules.values_list('weight', flat=True)\n            ) + 1\n        module = module_models.Module(\n            name=self.blueprint.title,\n            weight=weight,\n            project=project,\n            is_draft=True,\n        )\n        module.save()\n        signals.module_created.send(sender=None,\n                                    module=module,\n                                    user=self.request.user)\n\n        self._create_module_settings(module)\n        self._create_phases(module, self.blueprint.content)\n\n        return HttpResponseRedirect(self.get_next(module))\n\n    def _create_module_settings(self, module):\n        if self.blueprint.settings_model:\n            settings_model = apps.get_model(*self.blueprint.settings_model)\n            module_settings = settings_model(module=module)\n            module_settings.save()\n\n    def _create_phases(self, module, blueprint_phases):\n        for index, phase_content in enumerate(blueprint_phases):\n            phase = phase_models.Phase(\n                type=phase_content.identifier,\n                name=phase_content.name,\n                description=phase_content.description,\n                weight=index,\n                module=module,\n            )\n            phase.save()\n\n    def get_next(self, module):\n        return reverse('a4dashboard:dashboard-module_basic-edit', kwargs={\n            'module_slug': module.slug\n        })\n\n    def get_permission_object(self):\n        return self.project\n\n\nclass ModulePublishView(SingleObjectMixin,\n                        generic.View):\n    permission_required = 'a4projects.change_project'\n    model = module_models.Module\n    slug_url_kwarg = 'module_slug'\n\n    def get_permission_object(self):\n        return self.get_object().project\n\n    def post(self, request, *args, **kwargs):\n        action = request.POST.get('action', None)\n        if action == 'publish':\n            self.publish_module()\n        elif action == 'unpublish':\n            self.unpublish_module()\n        else:\n            messages.warning(self.request, _('Invalid action'))\n\n        return HttpResponseRedirect(self.get_next())\n\n    def get_next(self):\n        if 'referrer' in self.request.POST:\n            return self.request.POST['referrer']\n        elif 'HTTP_REFERER' in self.request.META:\n            return self.request.META['HTTP_REFERER']\n\n        return reverse('a4dashboard:project-edit', kwargs={\n            'project_slug': self.project.slug\n        })\n\n    def publish_module(self):\n        module = self.get_object()\n        if not module.is_draft:\n            messages.info(self.request, _('Module is already added'))\n            return\n\n        module.is_draft = False\n        module.save()\n\n        signals.module_published.send(sender=None,\n                                      module=module,\n                                      user=self.request.user)\n\n        messages.success(self.request,\n                         _('Module successfully added.'))\n\n    def unpublish_module(self):\n        module = self.get_object()\n        if module.is_draft:\n            messages.info(self.request, _('Module is already removed'))\n            return\n\n        module.is_draft = True\n        module.save()\n\n        signals.module_unpublished.send(sender=None,\n                                        module=module,\n                                        user=self.request.user)\n\n        messages.success(self.request,\n                         _('Module successfully removed.'))\n\n\nclass ModuleDeleteView(generic.DeleteView):\n    permission_required = 'a4projects.change_project'\n    model = module_models.Module\n    success_message = _('The module has been deleted')\n\n    def delete(self, request, *args, **kwargs):\n        messages.success(self.request, self.success_message)\n        return super().delete(request, *args, **kwargs)\n\n    def get_permission_object(self):\n        return self.get_object().project\n\n    def get_success_url(self):\n        referrer = self.request.POST.get('referrer', None) \\\n            or self.request.META.get('HTTP_REFERER', None)\n        if referrer:\n            view, args, kwargs = resolve(referrer)\n            if 'module_slug' not in kwargs \\\n                    or not kwargs['module_slug'] == self.get_object().slug:\n                return referrer\n\n        return reverse('a4dashboard:project-edit', kwargs={\n            'project_slug': self.get_object().project.slug\n        })\n\n\nclass DashboardProjectListView(a4dashboard_views.ProjectListView):\n    def get_queryset(self):\n        return super().get_queryset().filter(\n            projectcontainer=None,\n            externalproject=None\n        )\n\n\nclass ProjectCreateView(mixins.DashboardBaseMixin,\n                        SuccessMessageMixin,\n                        generic.CreateView):\n    model = project_models.Project\n    slug_url_kwarg = 'project_slug'\n    form_class = DashboardProjectCreateForm\n    template_name = 'a4dashboard/project_create_form.html'\n    permission_required = 'a4projects.add_project'\n    menu_item = 'project'\n    success_message = _('Project successfully created.')\n\n    def get_permission_object(self):\n        return self.organisation\n\n    def get_form_kwargs(self):\n        kwargs = super().get_form_kwargs()\n        kwargs['organisation'] = self.organisation\n        kwargs['creator'] = self.request.user\n        return kwargs\n\n    def get_success_url(self):\n        return reverse('a4dashboard:project-edit',\n                       kwargs={'project_slug': self.object.slug})\n\n    def form_valid(self, form):\n        response = super().form_valid(form)\n        signals.project_created.send(sender=None,\n                                     project=self.object,\n                                     user=self.request.user)\n\n        return response\n", "path": "meinberlin/apps/dashboard/views.py"}], "after_files": [{"content": "from django.apps import apps\nfrom django.contrib import messages\nfrom django.contrib.messages.views import SuccessMessageMixin\nfrom django.http import HttpResponseRedirect\nfrom django.urls import resolve\nfrom django.urls import reverse\nfrom django.utils.translation import ugettext_lazy as _\nfrom django.views import generic\nfrom django.views.generic.detail import SingleObjectMixin\n\nfrom adhocracy4.dashboard import mixins\nfrom adhocracy4.dashboard import signals\nfrom adhocracy4.dashboard import views as a4dashboard_views\nfrom adhocracy4.dashboard.blueprints import get_blueprints\nfrom adhocracy4.modules import models as module_models\nfrom adhocracy4.phases import models as phase_models\nfrom adhocracy4.projects import models as project_models\nfrom adhocracy4.projects.mixins import ProjectMixin\nfrom meinberlin.apps.dashboard.forms import DashboardProjectCreateForm\n\n\nclass ModuleBlueprintListView(ProjectMixin,\n                              mixins.DashboardBaseMixin,\n                              mixins.BlueprintMixin,\n                              generic.DetailView):\n    template_name = 'meinberlin_dashboard/module_blueprint_list_dashboard.html'\n    permission_required = 'a4projects.change_project'\n    model = project_models.Project\n    slug_url_kwarg = 'project_slug'\n    menu_item = 'project'\n\n    @property\n    def blueprints(self):\n        return get_blueprints()\n\n    def get_permission_object(self):\n        return self.project\n\n\nclass ModuleCreateView(ProjectMixin,\n                       mixins.DashboardBaseMixin,\n                       mixins.BlueprintMixin,\n                       SingleObjectMixin,\n                       generic.View):\n    permission_required = 'a4projects.change_project'\n    model = project_models.Project\n    slug_url_kwarg = 'project_slug'\n\n    def post(self, request, *args, **kwargs):\n        project = self.get_object()\n        weight = 1\n        if project.modules:\n            weight = max(\n                project.modules.values_list('weight', flat=True)\n            ) + 1\n        module = module_models.Module(\n            name=self.blueprint.title,\n            weight=weight,\n            project=project,\n            is_draft=True,\n        )\n        module.save()\n        signals.module_created.send(sender=None,\n                                    module=module,\n                                    user=self.request.user)\n\n        self._create_module_settings(module)\n        self._create_phases(module, self.blueprint.content)\n\n        closed = request.COOKIES.get('closed_accordeons', '')\n        closed_project_accordeon = \\\n            'dashboard-nav__project--{}'.format(str(self.project.id))\n        if closed_project_accordeon not in closed:\n            closed = closed_project_accordeon + closed\n        response = HttpResponseRedirect(self.get_next(module))\n        response.set_cookie('closed_accordeons', closed)\n        return response\n\n    def _create_module_settings(self, module):\n        if self.blueprint.settings_model:\n            settings_model = apps.get_model(*self.blueprint.settings_model)\n            module_settings = settings_model(module=module)\n            module_settings.save()\n\n    def _create_phases(self, module, blueprint_phases):\n        for index, phase_content in enumerate(blueprint_phases):\n            phase = phase_models.Phase(\n                type=phase_content.identifier,\n                name=phase_content.name,\n                description=phase_content.description,\n                weight=index,\n                module=module,\n            )\n            phase.save()\n\n    def get_next(self, module):\n        return reverse('a4dashboard:dashboard-module_basic-edit', kwargs={\n            'module_slug': module.slug\n        })\n\n    def get_permission_object(self):\n        return self.project\n\n\nclass ModulePublishView(SingleObjectMixin,\n                        generic.View):\n    permission_required = 'a4projects.change_project'\n    model = module_models.Module\n    slug_url_kwarg = 'module_slug'\n\n    def get_permission_object(self):\n        return self.get_object().project\n\n    def post(self, request, *args, **kwargs):\n        action = request.POST.get('action', None)\n        if action == 'publish':\n            self.publish_module()\n        elif action == 'unpublish':\n            self.unpublish_module()\n        else:\n            messages.warning(self.request, _('Invalid action'))\n\n        return HttpResponseRedirect(self.get_next())\n\n    def get_next(self):\n        if 'referrer' in self.request.POST:\n            return self.request.POST['referrer']\n        elif 'HTTP_REFERER' in self.request.META:\n            return self.request.META['HTTP_REFERER']\n\n        return reverse('a4dashboard:project-edit', kwargs={\n            'project_slug': self.project.slug\n        })\n\n    def publish_module(self):\n        module = self.get_object()\n        if not module.is_draft:\n            messages.info(self.request, _('Module is already added'))\n            return\n\n        module.is_draft = False\n        module.save()\n\n        signals.module_published.send(sender=None,\n                                      module=module,\n                                      user=self.request.user)\n\n        messages.success(self.request,\n                         _('Module successfully added.'))\n\n    def unpublish_module(self):\n        module = self.get_object()\n        if module.is_draft:\n            messages.info(self.request, _('Module is already removed'))\n            return\n\n        module.is_draft = True\n        module.save()\n\n        signals.module_unpublished.send(sender=None,\n                                        module=module,\n                                        user=self.request.user)\n\n        messages.success(self.request,\n                         _('Module successfully removed.'))\n\n\nclass ModuleDeleteView(generic.DeleteView):\n    permission_required = 'a4projects.change_project'\n    model = module_models.Module\n    success_message = _('The module has been deleted')\n\n    def delete(self, request, *args, **kwargs):\n        messages.success(self.request, self.success_message)\n        return super().delete(request, *args, **kwargs)\n\n    def get_permission_object(self):\n        return self.get_object().project\n\n    def get_success_url(self):\n        referrer = self.request.POST.get('referrer', None) \\\n            or self.request.META.get('HTTP_REFERER', None)\n        if referrer:\n            view, args, kwargs = resolve(referrer)\n            if 'module_slug' not in kwargs \\\n                    or not kwargs['module_slug'] == self.get_object().slug:\n                return referrer\n\n        return reverse('a4dashboard:project-edit', kwargs={\n            'project_slug': self.get_object().project.slug\n        })\n\n\nclass DashboardProjectListView(a4dashboard_views.ProjectListView):\n    def get_queryset(self):\n        return super().get_queryset().filter(\n            projectcontainer=None,\n            externalproject=None\n        )\n\n\nclass ProjectCreateView(mixins.DashboardBaseMixin,\n                        SuccessMessageMixin,\n                        generic.CreateView):\n    model = project_models.Project\n    slug_url_kwarg = 'project_slug'\n    form_class = DashboardProjectCreateForm\n    template_name = 'a4dashboard/project_create_form.html'\n    permission_required = 'a4projects.add_project'\n    menu_item = 'project'\n    success_message = _('Project successfully created.')\n\n    def get_permission_object(self):\n        return self.organisation\n\n    def get_form_kwargs(self):\n        kwargs = super().get_form_kwargs()\n        kwargs['organisation'] = self.organisation\n        kwargs['creator'] = self.request.user\n        return kwargs\n\n    def get_success_url(self):\n        return reverse('a4dashboard:project-edit',\n                       kwargs={'project_slug': self.object.slug})\n\n    def form_valid(self, form):\n        response = super().form_valid(form)\n        signals.project_created.send(sender=None,\n                                     project=self.object,\n                                     user=self.request.user)\n\n        return response\n", "path": "meinberlin/apps/dashboard/views.py"}]}