internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: liqd/a4-meinberlin

Issue:
testing #1824: if group is deleted, its projects/container/plans should not be deleted



Discussion:

Resolving patch:
diff --git a/meinberlin/apps/plans/migrations/0040_on_delete_group_set_null.py b/meinberlin/apps/plans/migrations/0040_on_delete_group_set_null.py
new file mode 100644
--- /dev/null
+++ b/meinberlin/apps/plans/migrations/0040_on_delete_group_set_null.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.20 on 2019-04-03 11:40
+from __future__ import unicode_literals
+
+import django.db.models.deletion
+from django.db import migrations
+from django.db import models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('meinberlin_plans', '0039_plan_group'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='plan',
+            name='group',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='auth.Group'),
+        ),
+    ]
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
@@ -47,6 +47,7 @@ class Plan(UserGeneratedContentModel):
     )
     group = models.ForeignKey(
         Group,
+        on_delete=models.SET_NULL,
         blank=True,
         null=True)
     point = map_fields.PointField(


Test patch:
Repository: liqd/a4-meinberlin

Issue:
Identity spoofing via secondary email
See https://github.com/pennersr/django-allauth/issues/2265

cc: @CarolingerSeilchenspringer @MagdaN @fuzzylogic2000 


Discussion:
@CarolingerSeilchenspringer, @MagdaN: actually the content of the email address

```
diese E-Mail-Adresse soll dem Benutzerkonto "..." auf der Beteiligungsplattform meinBerlin-dev hinzugefügt werden
```

makes it quite clear that the original intention was to sent it to the newly added address. So probably this is simply a bug. Also see the reply to my issue above: https://github.com/pennersr/django-allauth/issues/2265#issuecomment-482440609
thanks, @treba123! If it is not a problem of django-allauth, can we find a solution then? We should fix this with the next release, so I set a milestone. Maybe you also want to check our other platforms?

Resolving patch:
diff --git a/meinberlin/apps/users/adapters.py b/meinberlin/apps/users/adapters.py
--- a/meinberlin/apps/users/adapters.py
+++ b/meinberlin/apps/users/adapters.py
@@ -40,9 +40,8 @@ def get_email_confirmation_url(self, request, emailconfirmation):
             return url
 
     def send_mail(self, template_prefix, email, context):
-        user = context['user']
         return UserAccountEmail.send(
-            user,
+            email,
             template_name=template_prefix,
             **context
         )


Test patch:
Repository: liqd/a4-meinberlin

Issue:
events not editable for groupmembers
group member CAN edit a project but CANNOT an event related to the project. 403 error.


Discussion:

Resolving patch:
diff --git a/meinberlin/apps/offlineevents/rules.py b/meinberlin/apps/offlineevents/rules.py
--- a/meinberlin/apps/offlineevents/rules.py
+++ b/meinberlin/apps/offlineevents/rules.py
@@ -4,10 +4,11 @@
 from adhocracy4.modules import predicates as module_predicates
 from adhocracy4.organisations.predicates import is_initiator
 from adhocracy4.projects.predicates import is_moderator
+from adhocracy4.projects.predicates import is_prj_group_member
 
 rules.add_perm(
     'meinberlin_offlineevents.list_offlineevent',
-    is_superuser | is_initiator | is_moderator
+    is_superuser | is_initiator | is_moderator | is_prj_group_member
 )
 
 rules.add_perm(
@@ -17,10 +18,10 @@
 
 rules.add_perm(
     'meinberlin_offlineevents.add_offlineevent',
-    is_superuser | is_initiator | is_moderator
+    is_superuser | is_initiator | is_moderator | is_prj_group_member
 )
 
 rules.add_perm(
     'meinberlin_offlineevents.change_offlineevent',
-    is_superuser | is_initiator | is_moderator
+    is_superuser | is_initiator | is_moderator | is_prj_group_member
 )


Test patch:
Repository: liqd/a4-meinberlin

Issue:
testing #2058[mB] long running projects 
* translation missing

no more than that. Thanks!


Discussion:

Resolving patch:
diff --git a/meinberlin/apps/offlineevents/forms.py b/meinberlin/apps/offlineevents/forms.py
--- a/meinberlin/apps/offlineevents/forms.py
+++ b/meinberlin/apps/offlineevents/forms.py
@@ -18,3 +18,7 @@ class OfflineEventForm(forms.ModelForm):
     class Meta:
         model = models.OfflineEvent
         fields = ['name', 'event_type', 'date', 'description']
+
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        self.fields['date'].label = _('Date and time')
diff --git a/meinberlin/apps/offlineevents/migrations/0005_remove_default_for_event_type.py b/meinberlin/apps/offlineevents/migrations/0005_remove_default_for_event_type.py
new file mode 100644
--- /dev/null
+++ b/meinberlin/apps/offlineevents/migrations/0005_remove_default_for_event_type.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.2 on 2019-06-20 13:18
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('meinberlin_offlineevents', '0004_event_type_form_field'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='offlineevent',
+            name='event_type',
+            field=models.CharField(help_text='The content of this field is shown in the timeline. It should have no more than 30 characters e.g. Information event or 3rd public workshop.', max_length=30, verbose_name='Event type'),
+        ),
+    ]
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
@@ -13,7 +13,7 @@ class OfflineEvent(UserGeneratedContentModel):
     slug = AutoSlugField(populate_from='name', unique=True)
     name = models.CharField(max_length=120, verbose_name=_('Name of event'))
     event_type = models.CharField(
-        max_length=30, default='Veranstaltung', verbose_name=_('Event type'),
+        max_length=30, verbose_name=_('Event type'),
         help_text=_('The content of this field is shown in the timeline. It '
                     'should have no more than 30 characters e.g. Information '
                     'event or 3rd public workshop.'))


Test patch:
Repository: liqd/a4-meinberlin

Issue:
take out secret dev notes visible in frontend :-)

![Bildschirmfoto 2019-07-05 um 11 58 43](https://user-images.githubusercontent.com/35491681/60715029-65f58280-9f1c-11e9-85ff-91caecfbd2db.png)





Discussion:

Resolving patch:
diff --git a/meinberlin/apps/projects/templatetags/meinberlin_project_tags.py b/meinberlin/apps/projects/templatetags/meinberlin_project_tags.py
--- a/meinberlin/apps/projects/templatetags/meinberlin_project_tags.py
+++ b/meinberlin/apps/projects/templatetags/meinberlin_project_tags.py
@@ -40,12 +40,18 @@ def to_class_name(value):
 @register.simple_tag
 def get_num_entries(module):
     """Count all user-generated items."""
-    item_count = Idea.objects.filter(module=module).count() \
+    item_count = \
+        Idea.objects.filter(module=module).count() \
         + MapIdea.objects.filter(module=module).count() \
         + budget_proposal.objects.filter(module=module).count() \
         + kiezkasse_proposal.objects.filter(module=module).count() \
         + Comment.objects.filter(idea__module=module).count() \
         + Comment.objects.filter(mapidea__module=module).count() \
         + Comment.objects.filter(budget_proposal__module=module).count() \
-        + Comment.objects.filter(kiezkasse_proposal__module=module).count()
+        + Comment.objects.filter(kiezkasse_proposal__module=module).count() \
+        + Comment.objects.filter(topic__module=module).count() \
+        + Comment.objects.filter(maptopic__module=module).count() \
+        + Comment.objects.filter(paragraph__chapter__module=module).count() \
+        + Comment.objects.filter(chapter__module=module).count() \
+        + Comment.objects.filter(poll__module=module).count()
     return item_count


Test patch:
Repository: liqd/a4-meinberlin

Issue:
missing text and call to action in map prio
I added a map prio to my multi module project [https://meinberlin-dev.liqd.net/projects/ihre-vision-fur-berlin-welche-themen-sind-ihnen-wi/](url) and there is only the map in the module view, no call to action or text.

[https://meinberlin-dev.liqd.net/projects/module/ortspriorisierung-4/](url)


Discussion:
Note: loads project header, not proper module view?!

Resolving patch:
diff --git a/meinberlin/apps/maptopicprio/views.py b/meinberlin/apps/maptopicprio/views.py
--- a/meinberlin/apps/maptopicprio/views.py
+++ b/meinberlin/apps/maptopicprio/views.py
@@ -7,6 +7,7 @@
 from adhocracy4.filters import views as filter_views
 from adhocracy4.projects.mixins import ProjectMixin
 from meinberlin.apps.contrib import filters
+from meinberlin.apps.contrib import mixins as contrib_mixins
 from meinberlin.apps.exports.views import DashboardExportView
 from meinberlin.apps.ideas import views as idea_views
 
@@ -62,7 +63,8 @@ class MapTopicDetailView(idea_views.AbstractIdeaDetailView):
     permission_required = 'meinberlin_maptopicprio.view_maptopic'
 
 
-class MapTopicListView(idea_views.AbstractIdeaListView):
+class MapTopicListView(idea_views.AbstractIdeaListView,
+                       contrib_mixins.DisplayProjectOrModuleMixin):
     model = models.MapTopic
     filter_set = MapTopicFilterSet
 
diff --git a/meinberlin/apps/projects/views.py b/meinberlin/apps/projects/views.py
--- a/meinberlin/apps/projects/views.py
+++ b/meinberlin/apps/projects/views.py
@@ -433,8 +433,8 @@ def display_timeline(self):
         return len(self.full_list) > 1
 
     @cached_property
-    def is_project_view_with_timeline(self):
-        return self.display_timeline and self.get_current_modules()
+    def is_project_view(self):
+        return self.get_current_modules()
 
     def _view_by_phase(self):
         if self.module.last_active_phase:


Test patch:
Repository: liqd/a4-meinberlin

Issue:
text commenting results show module detail 
when only text commenting module used for project, module detail also shown in results tab


Discussion:

Resolving patch:
diff --git a/meinberlin/apps/documents/views.py b/meinberlin/apps/documents/views.py
--- a/meinberlin/apps/documents/views.py
+++ b/meinberlin/apps/documents/views.py
@@ -1,5 +1,4 @@
 from django.http import Http404
-from django.http.response import HttpResponseRedirect
 from django.urls import reverse
 from django.utils.translation import ugettext_lazy as _
 from django.views import generic
@@ -32,16 +31,6 @@ class ChapterDetailView(ProjectMixin,
     permission_required = 'meinberlin_documents.view_chapter'
     get_context_from_object = True
 
-    def dispatch(self, request, *args, **kwargs):
-        # Redirect first chapter view to the project detail page
-        res = super().dispatch(request, *args, **kwargs)
-        chapter = self.get_object()
-        if self.request.path == chapter.get_absolute_url() \
-                and chapter == self.chapter_list.first():
-            return HttpResponseRedirect(self.project.get_absolute_url())
-        else:
-            return res
-
     def get_context_data(self, **kwargs):
         context = super(ChapterDetailView, self).get_context_data(**kwargs)
         context['chapter_list'] = self.chapter_list


Test patch:
diff --git a/tests/documents/test_document_views.py b/tests/documents/test_document_views.py
--- a/tests/documents/test_document_views.py
+++ b/tests/documents/test_document_views.py
@@ -1,8 +1,6 @@
 import pytest
 from django.urls import reverse
 
-from adhocracy4.test.helpers import redirect_target
-
 
 @pytest.mark.django_db
 def test_chapter_detail_view_redirect_first_chapter(client, chapter_factory,
@@ -16,4 +14,4 @@ def test_chapter_detail_view_redirect_first_chapter(client, chapter_factory,
     )
 
     response = client.get(url)
-    assert redirect_target(response) == 'project-detail'
+    assert response.status_code == 200
Repository: liqd/a4-meinberlin

Issue:
counting contributions to polls on module tile
as discussed please count the comments AND all answers on poll module tiles.


Discussion:

Resolving patch:
diff --git a/meinberlin/apps/projects/templatetags/meinberlin_project_tags.py b/meinberlin/apps/projects/templatetags/meinberlin_project_tags.py
--- a/meinberlin/apps/projects/templatetags/meinberlin_project_tags.py
+++ b/meinberlin/apps/projects/templatetags/meinberlin_project_tags.py
@@ -5,6 +5,7 @@
 from meinberlin.apps.ideas.models import Idea
 from meinberlin.apps.kiezkasse.models import Proposal as kiezkasse_proposal
 from meinberlin.apps.mapideas.models import MapIdea
+from meinberlin.apps.polls.models import Vote
 from meinberlin.apps.projects import get_project_type
 
 register = template.Library()
@@ -53,5 +54,6 @@ def get_num_entries(module):
         + Comment.objects.filter(maptopic__module=module).count() \
         + Comment.objects.filter(paragraph__chapter__module=module).count() \
         + Comment.objects.filter(chapter__module=module).count() \
-        + Comment.objects.filter(poll__module=module).count()
+        + Comment.objects.filter(poll__module=module).count() \
+        + Vote.objects.filter(choice__question__poll__module=module).count()
     return item_count


Test patch:
Repository: liqd/a4-meinberlin

Issue:
same module displayed twice in project view
1 module is displayed twice (see picture) while another one (schönen text kommentieren) is not displayed at all. 

have a look at this [project](https://meinberlin-dev.liqd.net/projects/ihre-vision-fur-berlin-welche-themen-sind-ihnen-wi/)

![Bildschirmfoto 2019-07-12 um 12 40 21](https://user-images.githubusercontent.com/35491681/61122521-44f3db00-a4a2-11e9-8c40-2d6a80021435.png)



Discussion:

Resolving patch:
diff --git a/meinberlin/apps/projects/views.py b/meinberlin/apps/projects/views.py
--- a/meinberlin/apps/projects/views.py
+++ b/meinberlin/apps/projects/views.py
@@ -392,7 +392,7 @@ def modules(self):
             .annotate(start_date=Min('phase__start_date'))\
             .annotate(end_date=Max('phase__end_date'))\
             .exclude(Q(start_date=None) | Q(end_date=None))\
-            .order_by('start_date')
+            .order_by('start_date', 'id')
 
     @cached_property
     def events(self):


Test patch:
Repository: liqd/a4-meinberlin

Issue:
single module project without timeline is missing any discription
my single module project [https://meinberlin-dev.liqd.net/projects/schillerkasse-ihre-kiezkasse-fur-den-schillerkiez/](url) which is module Kiezkasse should have a phase information. It is currently running.

![Bildschirmfoto 2019-07-05 um 14 17 04](https://user-images.githubusercontent.com/35491681/60721991-e1acfa80-9f2f-11e9-950f-cf28dd3e7645.png)



Discussion:
same is true for ideensammlung mit KArte [https://meinberlin-dev.liqd.net/projects/carolin-findet-ihrberlin-2/](https://meinberlin-dev.liqd.net/projects/carolin-findet-ihrberlin-2/)
@CarolingerSeilchenspringer what exactly do you expect there? at the moment the active phase description is displayed
@MagdaN please leave it as it was before, this view should not change at all and still look like here: [https://mein.berlin.de/projects/stadtteilkasse-tiergarten-sud/](url) . 
Does this have to do with this issue as somehow the display of phase description was gone in multimodule? https://github.com/liqd/a4-meinberlin/issues/2350


Resolving patch:
diff --git a/meinberlin/apps/contrib/mixins.py b/meinberlin/apps/contrib/mixins.py
--- a/meinberlin/apps/contrib/mixins.py
+++ b/meinberlin/apps/contrib/mixins.py
@@ -156,7 +156,8 @@ def get_context_data(self, **kwargs):
             except IndexError:
                 pass
             try:
-                previous_module = cluster[idx - 1]
+                if idx > 0:
+                    previous_module = cluster[idx - 1]
             except IndexError:
                 pass
             context['other_modules'] = cluster


Test patch:
Repository: liqd/a4-meinberlin

Issue:
in text commenting links to first chapter lead back to the project view
...so I am back to the timeline and the tiles

There are two links doing that: "back to chapter" in paragraph detail view and "previous chapter" in second chapter.


Discussion:

Resolving patch:
diff --git a/meinberlin/apps/documents/models.py b/meinberlin/apps/documents/models.py
--- a/meinberlin/apps/documents/models.py
+++ b/meinberlin/apps/documents/models.py
@@ -24,6 +24,12 @@ def __str__(self):
         return "{}_chapter_{}".format(str(self.module), self.pk)
 
     def get_absolute_url(self):
+        if (self.project.display_timeline
+                and not self.module.is_in_module_cluster):
+            return ('{}?initialSlide={}'
+                    .format(reverse('meinberlin_documents:chapter-detail',
+                                    args=[str(self.pk)]),
+                            self.module.get_timeline_index))
         return reverse('meinberlin_documents:chapter-detail',
                        args=[str(self.pk)])
 
diff --git a/meinberlin/apps/documents/views.py b/meinberlin/apps/documents/views.py
--- a/meinberlin/apps/documents/views.py
+++ b/meinberlin/apps/documents/views.py
@@ -1,5 +1,6 @@
 from django.http import Http404
 from django.urls import reverse
+from django.utils.functional import cached_property
 from django.utils.translation import ugettext_lazy as _
 from django.views import generic
 
@@ -32,7 +33,7 @@ class ChapterDetailView(ProjectMixin,
     get_context_from_object = True
 
     def get_context_data(self, **kwargs):
-        context = super(ChapterDetailView, self).get_context_data(**kwargs)
+        context = super().get_context_data(**kwargs)
         context['chapter_list'] = self.chapter_list
         return context
 
@@ -40,6 +41,15 @@ def get_context_data(self, **kwargs):
     def chapter_list(self):
         return models.Chapter.objects.filter(module=self.module)
 
+    @cached_property
+    def extends(self):
+        if self.url_name == 'module-detail':
+            return 'a4modules/module_detail.html'
+        if self.url_name == 'chapter-detail':
+            if self.module.is_in_module_cluster:
+                return 'a4modules/module_detail.html'
+        return 'a4projects/project_detail.html'
+
 
 class DocumentDetailView(ChapterDetailView):
     get_context_from_object = False


Test patch:
Repository: liqd/a4-meinberlin

Issue:
bplan template dates saved but not shown in Dashboard
URL: https://mein.berlin.de/dashboard/projects/erweiterung-mauerpark-bebauungsplan-3-64-im-bezirk/bplan/
user: initiator
expected behaviour: date and time that I have entered are still shown after saving form
behaviour: dates are no longer shown after saving, no error message, I can still publish the project and date is shown correctly on project tile
device & browser: Desktop, mac, chrome Version 76.0.3809.132 (Offizieller Build) (64-Bit)
Importance: relevant bug, fix before next release


Discussion:

Resolving patch:
diff --git a/meinberlin/apps/bplan/forms.py b/meinberlin/apps/bplan/forms.py
--- a/meinberlin/apps/bplan/forms.py
+++ b/meinberlin/apps/bplan/forms.py
@@ -25,6 +25,7 @@ class BplanProjectForm(ExternalProjectForm):
     class Meta:
         model = models.Bplan
         fields = ['name', 'identifier', 'url', 'description', 'tile_image',
-                  'tile_image_copyright', 'is_archived', 'office_worker_email']
+                  'tile_image_copyright', 'is_archived', 'office_worker_email',
+                  'start_date', 'end_date']
         required_for_project_publish = ['name', 'url', 'description',
                                         'office_worker_email']


Test patch:
Repository: liqd/a4-meinberlin

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.


Discussion:

Resolving patch:
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 @@ def save(self, *args, **kwargs):
             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()


Test patch:
diff --git a/tests/offlineevents/test_views_integration.py b/tests/offlineevents/test_views_integration.py
--- a/tests/offlineevents/test_views_integration.py
+++ b/tests/offlineevents/test_views_integration.py
@@ -8,4 +8,4 @@ def test_detail_view(client, offline_event):
     url = offline_event.get_absolute_url()
     response = client.get(url)
     assert_template_response(
-        response, 'meinberlin_offlineevents/offlineevent_detail.html')
+        response, 'meinberlin_projects/project_detail.html')