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

Issue:
Markdown messes with Gender Mainstreaming
When writing “Initiator*innen […] Entscheidungsträger*innen” in a comment, the text between the `*` is set in italics, because of the markdown formatting, I assume. Is there anything we can do about that?  If I remember it correctly, some version of markdown only allows underscores for emphasis and double “*” for setting something in bold. Should we maybe use that version?

![bildschirmfoto 2016-11-21 um 12 22 31](https://cloud.githubusercontent.com/assets/15341015/20481129/e73970dc-afe5-11e6-8189-2210fc0b6c17.png)

Example here: https://opin-stage.liqd.net/de/projects/opin-alleinstellungsmerkmale-fur-produktseite/
Markdown in comments in consistent with rest
We decided against Markdown in most of the other input fields and used CKEditor instead, but comments still use markdown. But this is not document anywhere. So these are our options:
1. support markdown in comments, but also advertise it to the user
2. support only new lines and nor further formatting in comments (like _italic_, **bold**, ~~strike~~)
3. add ckeditor to comment edit field and allow some basic html in comments



Discussion:

Since this is more a product decision than technical I like to have feedback from @rittermo and @NadineKarbach first, before choosing a solution.

Hey, Option 1 seems suitable for me, i i would decide for one. But @rittermo has a deeper insight int o the product development here. // @slomo 


Resolving patch:
diff --git a/euth/comments/models.py b/euth/comments/models.py
--- a/euth/comments/models.py
+++ b/euth/comments/models.py
@@ -5,6 +5,7 @@
 from django.db import models
 from django.utils.translation import ugettext_lazy as _
 
+from contrib.transforms import html_transforms
 from euth.contrib.base_models import UserGeneratedContentModel
 from euth.contrib.generics import models_to_limit
 from euth.ratings import models as rating_models
@@ -47,6 +48,9 @@ def save(self, *args, **kwargs):
         the comment was marked removed or censored
         """
 
+        self.comment = html_transforms.clean_html_all(
+            self.comment)
+
         if self.is_removed:
             self.comment = 'deleted by creator'
         if self.is_censored:
diff --git a/euth/comments/templatetags/react_comments.py b/euth/comments/templatetags/react_comments.py
--- a/euth/comments/templatetags/react_comments.py
+++ b/euth/comments/templatetags/react_comments.py
@@ -16,7 +16,8 @@ def react_comments(context, obj):
     request = context['request']
 
     serializer = ThreadSerializer(
-        obj.comments.all(), many=True, context={'request': request})
+        obj.comments.all().order_by('-created'),
+        many=True, context={'request': request})
     comments = serializer.data
 
     user = request.user


Test patch:
Repository: liqd/a4-opin

Issue:
Dashboard: Add info for result tab
We already discussed the difficulties with understanding the result tab (see: https://opin-stage.liqd.net/de/dashboard/sample-organisation/projects/test-invite/#result). We should add some info to make it easier for initiators to understand its purpose:

“Here you should explain what the expected outcome of the project will be and how you are planning to use the results. If the project is finished you should add a summary of the results.“

If no results were given, we should replace the current message that is shown for participants by: “The initiator hasn’t provided information on the expected outcome of the project yet.”




Discussion:

Resolving patch:
diff --git a/euth/projects/migrations/0008_add_help_text_for_result.py b/euth/projects/migrations/0008_add_help_text_for_result.py
new file mode 100644
--- /dev/null
+++ b/euth/projects/migrations/0008_add_help_text_for_result.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import ckeditor_uploader.fields
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('euth_projects', '0007_fix_typo_in_is_public_helptext'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='project',
+            name='result',
+            field=ckeditor_uploader.fields.RichTextUploadingField(blank=True, help_text='Here you should explain what the expected outcome of the project will be and how you are planning to use the results. If the project is finished you should add a summary of the results.'),
+        ),
+    ]
diff --git a/euth/projects/models.py b/euth/projects/models.py
--- a/euth/projects/models.py
+++ b/euth/projects/models.py
@@ -46,7 +46,14 @@ class Project(base_models.TimeStampedModel):
                     'participation will look like. It will be always visible '
                     'in the „Info“ tab on your project’s page.')
     )
-    result = RichTextUploadingField(blank=True, config_name='image-editor')
+    result = RichTextUploadingField(
+        blank=True,
+        config_name='image-editor',
+        help_text=_('Here you should explain what the expected outcome of the '
+                    'project will be and how you are planning to use the '
+                    'results. If the project is finished you should add a '
+                    'summary of the results.')
+    )
     is_public = models.BooleanField(
         default=True,
         verbose_name=_('Access to the project'),


Test patch:
Repository: liqd/a4-opin

Issue:
Add explanations for inviting users
Currently the inivite users text input is very hard to understand. We should add some more information. (see: https://opin-stage.liqd.net/de/dashboard/sample-organisation/projects/test-invite/users/invite)

The **headline** of the form in the example currently is “INVITE USERS TO TEST INVITE” which should be changed to: INVITE USERS TO PROJECT “PROJECT NAME“

The **label** should be ”E-mail addresses of invited users“

**Add an explanation text underneath the label:**
“Enter the e-mail addresses of users who you want to invite separated by commas. Invited users will get an email to confirm their membership in the project.“

**The text input should have a placeholder text:** “magdalena@example.com,yves@example.com,nadine@example.com…”

The label of the **submit button** should be changed to “send invitations“



Discussion:

Resolving patch:
diff --git a/euth/dashboard/forms.py b/euth/dashboard/forms.py
--- a/euth/dashboard/forms.py
+++ b/euth/dashboard/forms.py
@@ -34,7 +34,16 @@ class Meta:
 
 
 class ProjectInviteForm(forms.Form):
-    emails = forms.CharField()
+    emails = forms.CharField(
+        label=_('E-mail addresses of invited users'),
+        help_text=_('Enter the e-mail addresses of users who you want '
+                    'to invite, separated by commas. Invited users will get '
+                    'an email to confirm their membership in the project.'),
+        widget=forms.TextInput(attrs={
+            'placeholder': 'magdalena@example.com, yves@example.com,'
+                           ' nadine@example.com…'}
+        )
+    )
 
     def __init__(self, project, *args, **kwargs):
         self.project = project


Test patch:
Repository: liqd/a4-opin

Issue:
Wording change for accept page
The page for accepting invites to private projects currently is a bit too straight-forward. ;) Let’s add some information

The headline should be changed to: Do you want to join “<project name>” ?
Then there should be another line underneath the headline set in our standard paragraph text style:
You were invited by the initiator of the project. If you accept you will be able to participate in the project. If you decline the invitation, you can also ask for membership at a later time.

The English label for the reject button should be changed to “decline”
The reject button looks strange. I think the button should be styled as a regular red button. Or is the small font-size on purpose?

![bildschirmfoto 2016-11-22 um 10 08 54](https://cloud.githubusercontent.com/assets/15341015/20517966/c00d3b48-b09d-11e6-8136-e5f91b66a1b1.png)



Discussion:

Resolving patch:
diff --git a/euth/projects/rules.py b/euth/projects/rules.py
--- a/euth/projects/rules.py
+++ b/euth/projects/rules.py
@@ -9,6 +9,6 @@
                is_superuser | is_initiator)
 
 
-rules.add_perm('projects.view_project',
+rules.add_perm('euth_projects.view_project',
                is_superuser | is_initiator |
                ((is_public | is_member) & is_live))
diff --git a/euth/projects/views.py b/euth/projects/views.py
--- a/euth/projects/views.py
+++ b/euth/projects/views.py
@@ -10,7 +10,7 @@ class ProjectDetailView(rules_views.PermissionRequiredMixin,
                         generic.DetailView):
 
     model = models.Project
-    permission_required = 'projects.view_project'
+    permission_required = 'euth_projects.view_project'
 
     @property
     def raise_exception(self):


Test patch:
Repository: liqd/a4-opin

Issue:
Dashboard: Elements in organization/user switch are astray
The arrow and the label for the organization/user name should be in one line and vertically centered in the switch area. Keep in mind that there can be long names of two lines. 
![bildschirmfoto 2016-12-16 um 10 27 11](https://cloud.githubusercontent.com/assets/15341015/21257897/b99b37d4-c37a-11e6-84fb-9254f660f162.png)



Discussion:

Resolving patch:
diff --git a/euth/dashboard/views.py b/euth/dashboard/views.py
--- a/euth/dashboard/views.py
+++ b/euth/dashboard/views.py
@@ -187,10 +187,9 @@ def get_permission_object(self):
         return self.organisation
 
     def get_success_url(self):
-        return reverse('dashboard-project-edit',
+        return reverse('dashboard-project-list',
                        kwargs={
                            'organisation_slug': self.organisation.slug,
-                           'slug': self.get_object().slug
                        })
 
     def get_form_kwargs(self):


Test patch:
Repository: liqd/a4-opin

Issue:
when I log out while  I am on my profile page I get a 500



Discussion:

Resolving patch:
diff --git a/euth/follows/templatetags/follow_tags.py b/euth/follows/templatetags/follow_tags.py
--- a/euth/follows/templatetags/follow_tags.py
+++ b/euth/follows/templatetags/follow_tags.py
@@ -7,8 +7,11 @@
 
 @register.assignment_tag()
 def is_following(user, project):
-    return models.Follow.objects.filter(
-        enabled=True,
-        project=project,
-        creator=user
-    ).exists()
+    if not user.is_anonymous():
+        return models.Follow.objects.filter(
+            enabled=True,
+            project=project,
+            creator=user
+        ).exists()
+    else:
+        return False


Test patch:
Repository: liqd/a4-opin

Issue:
too much space below video, not deletable in wagtail 
![wagtail bug](https://cloud.githubusercontent.com/assets/24652917/21648586/c86d744c-d29e-11e6-83b0-120667f43c41.jpg)



Discussion:

Resolving patch:
diff --git a/home/wagtail_hooks.py b/home/wagtail_hooks.py
--- a/home/wagtail_hooks.py
+++ b/home/wagtail_hooks.py
@@ -7,4 +7,4 @@
 def editor_css():
     return format_html('<link rel="stylesheet" href="'
                        + settings.STATIC_URL
-                       + 'scss/wagtail_admin/wagtail_admin.css">')
+                       + 'wagtail_admin.css">')


Test patch:
Repository: liqd/a4-opin

Issue:
project page header: more vertical space for byline
The byline in the project page’s header area, which show’s the project’s organization is vertically too close to the headline of the project. 
![bildschirmfoto 2016-12-07 um 17 00 56](https://cloud.githubusercontent.com/assets/15341015/20975340/7df03d10-bc9f-11e6-8427-c6eb0b357fc5.png)



Discussion:

Resolving patch:
diff --git a/euth/organisations/views.py b/euth/organisations/views.py
--- a/euth/organisations/views.py
+++ b/euth/organisations/views.py
@@ -15,4 +15,4 @@ def visible_projects(self):
 
 class OrganisationListView(generic.ListView):
     model = models.Organisation
-    paginate_by = 10
+    paginate_by = 12


Test patch:
diff --git a/tests/organisations/test_views.py b/tests/organisations/test_views.py
--- a/tests/organisations/test_views.py
+++ b/tests/organisations/test_views.py
@@ -15,6 +15,8 @@ def test_list_view(client, organisation_factory):
         organisation_factory()
     url = reverse('organisation-list')
     response = client.get(url)
-    assert len(response.context[-1]['object_list']) == 10
+    from euth.organisations.views import OrganisationListView
+    assert len(response.context[-1]['object_list']) == OrganisationListView\
+        .paginate_by
     assert response.context['is_paginated']
     assert response.status_code == 200
Repository: liqd/a4-opin

Issue:
Refactor idea to use a4 comments and ratings queryset
https://github.com/liqd/adhocracy4/pull/20


Discussion:

Resolving patch:
diff --git a/euth/ideas/models.py b/euth/ideas/models.py
--- a/euth/ideas/models.py
+++ b/euth/ideas/models.py
@@ -6,41 +6,13 @@
 from adhocracy4 import transforms
 from adhocracy4.comments import models as comment_models
 from adhocracy4.images import fields
+from adhocracy4.models import query
 from adhocracy4.modules import models as module_models
 from adhocracy4.ratings import models as rating_models
 
 
-class IdeaQuerySet(models.QuerySet):
-
-    def _rate_value_condition(self, value):
-        return models.Case(
-            models.When(ratings__value=value, then=models.F('ratings__id')),
-            output_field=models.IntegerField()
-        )
-
-    def annotate_positive_rating_count(self):
-        return self.annotate(
-            positive_rating_count=models.Count(
-                self._rate_value_condition(1),
-                distinct=True  # needed to combine with other count annotations
-            )
-        )
-
-    def annotate_negative_rating_count(self):
-        return self.annotate(
-            negative_rating_count=models.Count(
-                self._rate_value_condition(-1),
-                distinct=True  # needed to combine with other count annotations
-            )
-        )
-
-    def annotate_comment_count(self):
-        return self.annotate(
-            comment_count=models.Count(
-                'comments',
-                distinct=True  # needed to combine with other count annotations
-            )
-        )
+class IdeaQuerySet(query.RateableQuerySet, query.CommentableQuerySet):
+    pass
 
 
 class Idea(module_models.Item):


Test patch:
Repository: liqd/a4-opin

Issue:
update settings
https://github.com/liqd/adhocracy4/pull/19


Discussion:

Resolving patch:
diff --git a/euth_wagtail/settings/base.py b/euth_wagtail/settings/base.py
--- a/euth_wagtail/settings/base.py
+++ b/euth_wagtail/settings/base.py
@@ -70,9 +70,9 @@
     'adhocracy4.phases.apps.PhasesConfig',
     'adhocracy4.projects.apps.ProjectsConfig',
     'adhocracy4.ratings.apps.RatingsConfig',
-    'adhocracy4.reports.apps.ReportConfig',
+    'adhocracy4.reports.apps.ReportsConfig',
     'adhocracy4.modules.apps.ModulesConfig',
-    'adhocracy4.comments.apps.CommentConfig',
+    'adhocracy4.comments.apps.CommentsConfig',
 
     'euth.users.apps.UsersConfig',
     'euth.actions.apps.ActionsConfig',


Test patch:
Repository: liqd/a4-opin

Issue:
Change sorting order on organization page
We currently sort projects on the organization pages from oldest to newest (date of creation). We should reverse the order, so that new projects are shown first.


Discussion:

Resolving patch:
diff --git a/euth/organisations/views.py b/euth/organisations/views.py
--- a/euth/organisations/views.py
+++ b/euth/organisations/views.py
@@ -7,10 +7,11 @@ class OrganisationDetailView(generic.DetailView):
     model = models.Organisation
 
     def visible_projects(self):
+        projects = self.object.project_set.order_by('-created')
         if self.request.user in self.object.initiators.all():
-            return self.object.project_set.all()
+            return projects.all()
         else:
-            return self.object.project_set.filter(is_draft=False)
+            return projects.filter(is_draft=False)
 
 
 class OrganisationListView(generic.ListView):


Test patch:
Repository: liqd/a4-opin

Issue:
use small images in user avatar in moderators list



Discussion:

Resolving patch:
diff --git a/euth/users/serializers.py b/euth/users/serializers.py
--- a/euth/users/serializers.py
+++ b/euth/users/serializers.py
@@ -1,16 +1,22 @@
+from easy_thumbnails.files import get_thumbnailer
 from rest_framework import serializers
 
 from .models import User
 
 
 class UserSerializer(serializers.ModelSerializer):
-    avatar = serializers.ImageField()
+    avatar = serializers.SerializerMethodField()
 
     class Meta:
         model = User
         fields = ('id', 'username', 'avatar', 'default_avatar')
         read_only_fields = ('id', 'username', 'avatar', 'default_avatar')
 
+    def get_avatar(self, obj):
+        if obj.avatar:
+            image = get_thumbnailer(obj.avatar)['avatar_small']
+            return image.url
+
 
 # mails should not be exposed in API, so there is a separate one for this
 class UserWithMailSerializer(UserSerializer):


Test patch:
Repository: liqd/a4-opin

Issue:
DST | Changes on "Aim"-Page 
Hey hey, Nicolas from Nexus/WP3 sent some remarks for changes. On this page it would be helpful to 
1) Start the sentences on the left hand side with a capital letter 2) Change the question into "What is the aim of your participation project?" and lastly 3) Add a line above the first row: Text on left column "Aim", Text for the right column "Examples"

![bildschirmfoto 2017-03-07 um 17 39 54](https://cloud.githubusercontent.com/assets/13625047/23668067/2fb0261c-0360-11e7-9e65-e761b813ecb0.png)



Discussion:

Resolving patch:
diff --git a/euth/blueprintsuggest/blueprints.py b/euth/blueprintsuggest/blueprints.py
--- a/euth/blueprintsuggest/blueprints.py
+++ b/euth/blueprintsuggest/blueprints.py
@@ -13,36 +13,36 @@
 class Aim(Enum):
     collect_ideas = (
         'collect_ideas',
-        _('create and gather new ideas or visions.'),
+        _('Create and gather new ideas or visions.'),
         [_('(Urban) planning processes'),
          _('Develop concepts or guiding principles')]
     )
     discuss_topic = (
         'discuss_topic',
-        _('gather feedback on a topic and discuss it in greater detail.'),
+        _('Gather feedback on a topic and discuss it in greater detail.'),
         [_('Discuss existing concepts or plans'),
          _('Develop solutions for existing problems')]
     )
     design_place = (
         'design_place',
-        _('design a place.'),
+        _('Design a place.'),
         [_('(Urban) planning processes'),
          _('Set the agenda of an event')]
     )
     run_survey = (
         'run_survey',
-        _('learn about what people like most.'),
+        _('Learn about what people like most.'),
         [_('Majority votes'), _('Opinion polls')]
     )
     run_competition = (
         'run_competition',
-        _('run a competition.'),
+        _('Run a competition.'),
         [_('All sorts of competitions, '
            'like idea contests etc.')]
     )
     work_document = (
         'work_document',
-        _('work collaboratively on a text document.'),
+        _('Work collaboratively on a text document.'),
         [_('Draft or revise statutes, articles, or charters'),
          _('Involve different authors in writing a shared text')]
     )


Test patch:
Repository: liqd/a4-opin

Issue:
Fix translations
I am facing problems compiling the messages files: 

First I run into: `CommandError: Execution of msgfmt failed: /Users/magdalenanoffke/Documents/dev/euth_wagtail/euth_wagtail/locale/en/LC_MESSAGES/django.po:48: »msgid«- und »msgstr«-Eintrag beginnen nicht jeweils mit »\n«
/Users/magdalenanoffke/Documents/dev/euth_wagtail/euth_wagtail/locale/en/LC_MESSAGES/django.po:733: eine Formatspezifikation für Argument »days«, wie in »msgstr[0]«, fehlt in »msgid_plural«
msgfmt: es sind 3 fatale Fehler aufgetreten
` 
Somehow the .mo file is still created but then I run into a `KeyError at /de/
'days'` on the landing page, which is thrown by `/Users/magdalenanoffke/Documents/dev/euth_wagtail/venv/lib/python3.5/site-packages/adhocracy4/projects/templatetags/project_tags.py in get_days, line 15`

Deleting the .mo files fixes the error, but this is obviously no solution


Discussion:

Resolving patch:
diff --git a/euth/contrib/management/commands/makemessages.py b/euth/contrib/management/commands/makemessages.py
new file mode 100644
--- /dev/null
+++ b/euth/contrib/management/commands/makemessages.py
@@ -0,0 +1,15 @@
+from os.path import relpath
+from django.core.management.commands import makemessages
+import adhocracy4
+import euth
+import euth_wagtail
+
+
+class Command(makemessages.Command):
+    def find_files(self, root):
+        a4_path = super().find_files(adhocracy4.__path__[0])
+        euth_path = super().find_files(relpath(euth.__path__[0]))
+        euth_wagtail_path = super().find_files(
+            relpath(euth_wagtail.__path__[0])
+        )
+        return a4_path + euth_path + euth_wagtail_path


Test patch:
Repository: liqd/a4-opin

Issue:
add test for email sending after moderator was added to project



Discussion:

Resolving patch:
diff --git a/euth/projects/emails.py b/euth/projects/emails.py
--- a/euth/projects/emails.py
+++ b/euth/projects/emails.py
@@ -4,5 +4,5 @@
 class ModeratorAddedEmail(OpinEmail):
     template_name = 'notify_new_moderator'
 
-    def get_recipients(self):
-        self.kwargs['user']
+    def get_receivers(self):
+        return [self.kwargs['user']]


Test patch:
diff --git a/tests/projects/__init__.py b/tests/projects/__init__.py
new file mode 100644
diff --git a/tests/projects/test_api.py b/tests/projects/test_api.py
new file mode 100644
--- /dev/null
+++ b/tests/projects/test_api.py
@@ -0,0 +1,48 @@
+import pytest
+from django.core import mail
+from django.core.urlresolvers import reverse
+from rest_framework import status
+
+from tests.factories import UserFactory
+
+
+@pytest.mark.django_db
+def test_anonymous_user_cannot_get_project_detail(apiclient, project):
+    url = reverse('projects-detail', kwargs={'pk': project.pk})
+    response = apiclient.get(url)
+    assert response.status_code == status.HTTP_403_FORBIDDEN
+
+
+@pytest.mark.django_db
+def test_authenticated_user_cannot_get_project_detail(apiclient,
+                                                      project, user):
+    apiclient.force_authenticate(user=user)
+    url = reverse('projects-detail', kwargs={'pk': project.pk})
+    response = apiclient.get(url)
+    assert response.status_code == status.HTTP_405_METHOD_NOT_ALLOWED
+
+
+@pytest.mark.django_db
+def test_initiator_cannot_get_project_detail(apiclient, project):
+    initiator = project.organisation.initiators.all().first()
+    apiclient.force_authenticate(user=initiator)
+    url = reverse('projects-detail', kwargs={'pk': project.pk})
+    response = apiclient.get(url)
+    assert response.status_code == status.HTTP_405_METHOD_NOT_ALLOWED
+
+
+@pytest.mark.django_db
+def test_initiator_can_add_moderator_to_project(apiclient, project, user):
+    initiator = project.organisation.initiators.all().first()
+    apiclient.force_authenticate(user=initiator)
+    url = reverse('projects-detail', kwargs={'pk': project.pk})
+    user1 = UserFactory(username='Cersei')
+    data = {
+        'moderators': [user1.pk]
+    }
+    response = apiclient.patch(url, data, format='json')
+    assert len(mail.outbox) == 1
+    message = 'You were added as a moderator to a project'
+    assert message in mail.outbox[0].subject
+    assert mail.outbox[0].to[0] == user1.email
+    assert response.status_code == status.HTTP_200_OK
Repository: liqd/a4-opin

Issue:
cannot delete user in django admin if user has not uploaded avatar 



Discussion:

Resolving patch:
diff --git a/euth/users/signals.py b/euth/users/signals.py
--- a/euth/users/signals.py
+++ b/euth/users/signals.py
@@ -20,4 +20,4 @@ def delete_old_image(sender, instance, **kwargs):
 
 @receiver(signals.post_delete, sender=models.User)
 def delete_images_for_User(sender, instance, **kwargs):
-    services.delete_images([instance.avatar])
+    services.delete_images([instance._avatar])


Test patch: