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

Issue:
Extend linting to javascript and jsx files



Discussion:

Resolving patch:
diff --git a/adhocracy4/reports/emails.py b/adhocracy4/reports/emails.py
--- a/adhocracy4/reports/emails.py
+++ b/adhocracy4/reports/emails.py
@@ -1,5 +1,4 @@
 from django.contrib.auth import get_user_model
-from django.core import urlresolvers
 
 from adhocracy4 import emails
 


Test patch:
Repository: liqd/adhocracy4

Issue:
improve accessibility of image upload
* add alt attribute with the filename
* if there is no image uploaded the image tag should not be there
* the label's `for` attribute doesn't reference the file input's id.

The first part causes the HTML to be invalid, which is part of the BITV Test "4.1.1a Valides HTML".
The third part is part of the BITV Test "3.3.2a Formularfelder richtig beschriftet".


Discussion:

Resolving patch:
diff --git a/adhocracy4/images/widgets.py b/adhocracy4/images/widgets.py
--- a/adhocracy4/images/widgets.py
+++ b/adhocracy4/images/widgets.py
@@ -19,13 +19,13 @@ class Media:
         js = (staticfiles_storage.url('a4images/imageUploader.js'),)
 
     def render(self, name, value, attrs=None):
-
+        html_id = attrs and attrs.get('id', name) or name
         has_image_set = self.is_initial(value)
         is_required = self.is_required
 
         file_placeholder = ugettext('Select a picture from your local folder.')
         file_input = super().render(name, None, {
-            'id': name,
+            'id': html_id,
             'class': 'form-control form-control-file'
         })
 
@@ -39,7 +39,8 @@ def render(self, name, value, attrs=None):
         text_input = widgets.TextInput().render('__noname__', file_name, {
             'class': 'form-control form-control-file-dummy',
             'placeholder': file_placeholder,
-            'tabindex': '-1'
+            'tabindex': '-1',
+            'id': 'text-{}'.format(html_id)
         })
 
         checkbox_id = self.clear_checkbox_id(name)
@@ -47,16 +48,16 @@ def render(self, name, value, attrs=None):
         checkbox_input = widgets.CheckboxInput().render(checkbox_name, False, {
             'id': checkbox_id,
             'class': 'clear-image',
-            'data-upload-clear': name,
+            'data-upload-clear': html_id,
         })
 
         context = {
-            'name': name,
+            'id': html_id,
             'has_image_set': has_image_set,
             'is_required': is_required,
             'file_url': file_url,
             'file_input': file_input,
-            'file_id': name + '-file',
+            'file_id': html_id + '-file',
             'text_input': text_input,
             'checkbox_input': checkbox_input,
             'checkbox_id': checkbox_id


Test patch:
Repository: liqd/adhocracy4

Issue:
Keep html time field optional even if a DateTimeField is set to be required
Time is optional in the backend but the html input field still gets the required attribute if the the DateTimeField is initializes with `required=True`
The time Widget should always be initialized without required.


Discussion:

Resolving patch:
diff --git a/adhocracy4/forms/widgets.py b/adhocracy4/forms/widgets.py
--- a/adhocracy4/forms/widgets.py
+++ b/adhocracy4/forms/widgets.py
@@ -32,7 +32,8 @@ def render(self, name, value, attrs=None):
             'class': 'timepicker',
             'placeholder': self.widgets[1].format_value(
                 self.get_default_time()),
-            'id': attrs['id'] + '_time'
+            'id': attrs['id'] + '_time',
+            'required': False
         })
 
         if isinstance(value, datetime.datetime):


Test patch:
Repository: liqd/adhocracy4

Issue:
Subject with new line crashes email sending

Subject with new line crashes email sending



Discussion:

Resolving patch:
diff --git a/adhocracy4/emails/base.py b/adhocracy4/emails/base.py
--- a/adhocracy4/emails/base.py
+++ b/adhocracy4/emails/base.py
@@ -1,3 +1,5 @@
+import re
+
 from django.conf import settings
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.sites import models as site_models
@@ -102,8 +104,10 @@ def dispatch(self, object, *args, **kwargs):
             else:
                 to_address = receiver
 
+            subject_clean = re.sub(r'[\r\n]', '', subject).strip()
+
             mail = EmailMultiAlternatives(
-                subject=subject.strip(),
+                subject=subject_clean,
                 body=text,
                 from_email=settings.DEFAULT_FROM_EMAIL,
                 to=[to_address],
diff --git a/adhocracy4/emails/mixins.py b/adhocracy4/emails/mixins.py
--- a/adhocracy4/emails/mixins.py
+++ b/adhocracy4/emails/mixins.py
@@ -1,7 +1,6 @@
 from email.mime.image import MIMEImage
 
 from django.contrib.staticfiles import finders
-from .base import EmailBase
 
 
 class PlatformEmailMixin:
@@ -29,7 +28,7 @@ def get_attachments(self):
         return attachments
 
 
-class SyncEmailMixin(EmailBase):
+class SyncEmailMixin:
     """Send Emails synchronously."""
 
     @classmethod


Test patch:
Repository: liqd/adhocracy4

Issue:
Increase comment limit to 2048 and display better error message
Take error message from REST response and display in existing error message alert. On top it probably makes sense to limit the field as well.


Discussion:

Resolving patch:
diff --git a/adhocracy4/comments/migrations/0002_extend_comments_field.py b/adhocracy4/comments/migrations/0002_extend_comments_field.py
new file mode 100644
--- /dev/null
+++ b/adhocracy4/comments/migrations/0002_extend_comments_field.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.4 on 2018-01-02 15:00
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('a4comments', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='comment',
+            name='comment',
+            field=models.TextField(max_length=2048),
+        ),
+    ]
diff --git a/adhocracy4/comments/models.py b/adhocracy4/comments/models.py
--- a/adhocracy4/comments/models.py
+++ b/adhocracy4/comments/models.py
@@ -21,7 +21,7 @@ class Comment(base.UserGeneratedContentModel):
     object_pk = models.PositiveIntegerField()
     content_object = GenericForeignKey(
         ct_field="content_type", fk_field="object_pk")
-    comment = models.TextField(max_length=1024)
+    comment = models.TextField(max_length=2048)
     is_removed = models.BooleanField(default=False)
     is_censored = models.BooleanField(default=False)
     ratings = GenericRelation(rating_models.Rating,


Test patch:
Repository: liqd/adhocracy4

Issue:
IntegrityError in ratings
See:
- https://sentry.liqd.net/sentry/debattenportalspdde/issues/84/
- https://sentry.liqd.net/sentry/meinberlin-prod/issues/5/


Discussion:
I believe that happens when users have the same page open in different tabs and try to rate in one tab even though they already rated in the other tab and did not refresh the page
Alright, I'll check that. If that's the cause, I'll try to add a check for that.
> I believe that happens when users have the same page open in different tabs and try to rate in one tab even though they already rated in the other tab and did not refresh the page

Confirmed. But it only happens if the user didn't rate the comment (or whatever it is) before. So I guess the offending function might be https://github.com/liqd/adhocracy4/blob/44b104bbeff2400e62f5e9033cd217ec7757d493/adhocracy4/ratings/api.py#L26-L30

Trying to debug

Resolving patch:
diff --git a/adhocracy4/ratings/api.py b/adhocracy4/ratings/api.py
--- a/adhocracy4/ratings/api.py
+++ b/adhocracy4/ratings/api.py
@@ -3,6 +3,7 @@
 from django_filters import rest_framework as filters
 from rest_framework import mixins, viewsets
 from rest_framework.response import Response
+from rest_framework.serializers import ValidationError
 
 from adhocracy4.api.mixins import ContentTypeMixin
 from adhocracy4.api.permissions import ViewSetRulesPermission
@@ -24,6 +25,11 @@ class RatingViewSet(mixins.CreateModelMixin,
     content_type_filter = settings.A4_RATEABLES
 
     def perform_create(self, serializer):
+        queryset = Rating.objects.filter(content_type_id=self.content_type.pk,
+                                         creator=self.request.user,
+                                         object_pk=self.content_object.pk)
+        if queryset.exists():
+            raise ValidationError(queryset[0].pk)
         serializer.save(
             content_object=self.content_object,
             creator=self.request.user


Test patch:
Repository: liqd/adhocracy4

Issue:
check (and in case fix) usage of class in FollowButton
should be className


Discussion:

Resolving patch:
diff --git a/adhocracy4/projects/migrations/0025_change_helptext_is_archived.py b/adhocracy4/projects/migrations/0025_change_helptext_is_archived.py
new file mode 100644
--- /dev/null
+++ b/adhocracy4/projects/migrations/0025_change_helptext_is_archived.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.3 on 2019-10-23 13:42
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('a4projects', '0024_group_on_delete_set_null'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='project',
+            name='is_archived',
+            field=models.BooleanField(default=False, help_text='Archived projects are not shown in the project overview. For project initiators they are still visible in the dashboard.', verbose_name='Project is archived'),
+        ),
+    ]
diff --git a/adhocracy4/projects/models.py b/adhocracy4/projects/models.py
--- a/adhocracy4/projects/models.py
+++ b/adhocracy4/projects/models.py
@@ -252,8 +252,9 @@ class Project(ProjectContactDetailMixin,
     is_archived = models.BooleanField(
         default=False,
         verbose_name=_('Project is archived'),
-        help_text=_('Exclude this project from all listings by default. '
-                    'You can still access this project by using filters.'),
+        help_text=_('Archived projects are not shown in the project overview. '
+                    'For project initiators they are still visible in the '
+                    'dashboard.'),
     )
     topics = TopicField(
         verbose_name=_('Project topics'),


Test patch:
Repository: liqd/adhocracy4

Issue:
adding multiple answer text to answer page



Discussion:

Resolving patch:
diff --git a/adhocracy4/comments_async/serializers.py b/adhocracy4/comments_async/serializers.py
--- a/adhocracy4/comments_async/serializers.py
+++ b/adhocracy4/comments_async/serializers.py
@@ -21,7 +21,8 @@ class Meta:
         model = Comment
         read_only_fields = ('modified', 'created', 'id',
                             'user_name', 'user_pk', 'user_image',
-                            'ratings', 'content_type', 'object_pk')
+                            'user_image_fallback', 'ratings',
+                            'content_type', 'object_pk')
         exclude = ('creator', 'is_censored', 'is_removed')
 
     def to_representation(self, instance):
@@ -77,6 +78,17 @@ def get_user_name(self, obj):
             return _('unknown user')
         return obj.creator.get_short_name()
 
+    def get_user_image_fallback(self, obj):
+        """Load small thumbnail images for default user images."""
+        if(obj.is_censored or obj.is_removed):
+            return None
+        try:
+            if obj.creator.avatar_fallback:
+                return obj.creator.avatar_fallback
+        except AttributeError:
+            pass
+        return None
+
     def get_user_image(self, obj):
         """Load small thumbnail images for user images."""
         if(obj.is_censored or obj.is_removed):
@@ -87,7 +99,7 @@ def get_user_image(self, obj):
                 return avatar.url
         except AttributeError:
             pass
-        return None
+        return self.get_user_image_fallback(obj)
 
     def get_is_moderator(self, obj):
         return obj.project.has_moderator(obj.creator)


Test patch:
Repository: liqd/adhocracy4

Issue:
error handling intial slide
like https://github.com/liqd/a4-meinberlin/issues/3153


Discussion:

Resolving patch:
diff --git a/adhocracy4/projects/mixins.py b/adhocracy4/projects/mixins.py
--- a/adhocracy4/projects/mixins.py
+++ b/adhocracy4/projects/mixins.py
@@ -148,7 +148,9 @@ def extends(self):
     def initial_slide(self):
         initial_slide = self.request.GET.get('initialSlide')
         if initial_slide:
-            return int(initial_slide)
+            initial_slide = ''.join(i for i in initial_slide if i.isdigit())
+            if initial_slide:
+                return int(initial_slide)
         elif self.project.get_current_participation_date():
             return self.project.get_current_participation_date()
         return 0


Test patch:
Repository: liqd/adhocracy4

Issue:
increase max_length of project image fields
**URL:** 
**user:** 
**expected behaviour:** 
**behaviour:** 
**important screensize:**
**device & browser:** 
**Comment/Question:** The image and tile_image fields of the project model should have a max_length of 200 instead of the default 100.

Screenshot?



Discussion:
Sooo, they need 300...

Resolving patch:
diff --git a/adhocracy4/projects/migrations/0032_increase_image_name_max_length.py b/adhocracy4/projects/migrations/0032_increase_image_name_max_length.py
new file mode 100644
--- /dev/null
+++ b/adhocracy4/projects/migrations/0032_increase_image_name_max_length.py
@@ -0,0 +1,24 @@
+# Generated by Django 2.2.19 on 2021-03-29 11:55
+
+import adhocracy4.images.fields
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('a4projects', '0031_remove_access_helptext'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='project',
+            name='image',
+            field=adhocracy4.images.fields.ConfiguredImageField('heroimage', blank=True, help_prefix='The image will be shown as a decorative background image.', max_length=300, upload_to='projects/backgrounds', verbose_name='Header image'),
+        ),
+        migrations.AlterField(
+            model_name='project',
+            name='tile_image',
+            field=adhocracy4.images.fields.ConfiguredImageField('tileimage', blank=True, help_prefix='The image will be shown in the project tile.', max_length=300, upload_to='projects/tiles', verbose_name='Tile image'),
+        ),
+    ]
diff --git a/adhocracy4/projects/models.py b/adhocracy4/projects/models.py
--- a/adhocracy4/projects/models.py
+++ b/adhocracy4/projects/models.py
@@ -225,7 +225,8 @@ class Project(ProjectContactDetailMixin,
             'The image will be shown as a decorative background image.'
         ),
         upload_to='projects/backgrounds',
-        blank=True)
+        blank=True,
+        max_length=300)
     image_copyright = fields.ImageCopyrightField(image_name=_('Header image'))
     tile_image = fields.ConfiguredImageField(
         'tileimage',
@@ -234,7 +235,8 @@ class Project(ProjectContactDetailMixin,
             'The image will be shown in the project tile.'
         ),
         upload_to='projects/tiles',
-        blank=True)
+        blank=True,
+        max_length=300)
     tile_image_copyright = fields.ImageCopyrightField(
         image_name=_('Tile image'))
     participants = models.ManyToManyField(


Test patch:
Repository: liqd/adhocracy4

Issue:
make sure the next-module thing works for the polls
**URL:** https://meinberlin-dev.liqd.net/projekte/this-tests-two-polls-in-one-project/
**user:** 
**expected behaviour:** 
**behaviour:** The poll module from mB uses the get_detail_url (I think) and can thus display the next-module thing, and a back-button. Using the poll app from a4 in mB this breaks.
**important screensize:**
**device & browser:** 
**Comment/Question:** 

Screenshot?



Discussion:

Resolving patch:
diff --git a/adhocracy4/polls/views.py b/adhocracy4/polls/views.py
--- a/adhocracy4/polls/views.py
+++ b/adhocracy4/polls/views.py
@@ -4,6 +4,7 @@
 from django.views import generic
 
 from adhocracy4.dashboard import mixins as dashboard_mixins
+from adhocracy4.projects.mixins import DisplayProjectOrModuleMixin
 from adhocracy4.projects.mixins import ProjectMixin
 from adhocracy4.rules import mixins as rules_mixins
 
@@ -12,7 +13,8 @@
 
 class PollDetailView(ProjectMixin,
                      rules_mixins.PermissionRequiredMixin,
-                     generic.DetailView):
+                     generic.DetailView,
+                     DisplayProjectOrModuleMixin):
     model = models.Poll
     permission_required = 'a4polls.view_poll'
 
diff --git a/adhocracy4/projects/mixins.py b/adhocracy4/projects/mixins.py
--- a/adhocracy4/projects/mixins.py
+++ b/adhocracy4/projects/mixins.py
@@ -133,6 +133,15 @@ def get_context_data(self, **kwargs):
 
 
 class DisplayProjectOrModuleMixin(generic.base.ContextMixin):
+    """Use the appropriate project or module view with timeline/cluster logic.
+
+    On platforms with multiple module projects, this should be used
+    with the phase view to display the module instead of the project
+    detail where appropriate. To do that, the template should extend
+    'extends' instead of a specific base template.
+    This mixin also makes sure the project view is shown with the
+    appropriate timeline tile activated.
+    """
 
     @cached_property
     def url_name(self):


Test patch:
Repository: liqd/adhocracy4

Issue:
django-admin: place comment's is_blocked next to is_censored
**URL:** 
**user:** 
**expected behaviour:** As is_removed, is_censored and is_blocked have a very similar behaviour, the is_blocked field should be next to the first two fields. In the detail as well as in the list view
**behaviour:** 
**important screensize:**
**device & browser:** 
**Comment/Question:** 

Screenshot?
![Screenshot from 2021-11-12 11-20-55](https://user-images.githubusercontent.com/8178179/141452772-f03df35f-b6e4-45d6-8703-c587ff0baef5.png)
![Screenshot from 2021-11-12 11-20-37](https://user-images.githubusercontent.com/8178179/141452773-c511dc84-3c92-49e4-abe8-dbb8022794be.png)




Discussion:

Resolving patch:
diff --git a/adhocracy4/comments/admin.py b/adhocracy4/comments/admin.py
--- a/adhocracy4/comments/admin.py
+++ b/adhocracy4/comments/admin.py
@@ -7,13 +7,13 @@
 class CommentAdmin(admin.ModelAdmin):
     fields = (
         'content_type', 'content_object', 'comment', 'is_removed',
-        'is_censored', 'is_moderator_marked', 'creator', 'comment_categories',
-        'is_blocked'
+        'is_censored', 'is_blocked', 'is_moderator_marked',
+        'creator', 'comment_categories'
     )
     readonly_fields = ('creator', 'content_type', 'content_object')
     list_display = (
-        '__str__', 'creator', 'is_removed', 'is_censored', 'created',
-        'is_blocked'
+        '__str__', 'creator', 'is_removed', 'is_censored',
+        'is_blocked', 'created'
     )
     search_fields = ('comment',)
     date_hierarchy = 'created'


Test patch:
Repository: liqd/adhocracy4

Issue:
Custom model delete method deprecated: after django upgrade
**expected behaviour:** Custom deletion logic should move to form_valid() for django > 4

**behaviour:** During the upgrade, we missed updating one of the custom deletion methods in dashboard/mixins.py

`https://github.com/liqd/adhocracy4/blob/main/adhocracy4/dashboard/mixins.py#L132`

**Comment/Question:** *Is this easy to do? What ideas do you have? Would this be a story?* 
It is easy to fix.

![image](https://github.com/liqd/adhocracy4/assets/5695572/a6467657-8383-442b-89dc-16d58aa6a84b)




Discussion:

Resolving patch:
diff --git a/adhocracy4/dashboard/mixins.py b/adhocracy4/dashboard/mixins.py
--- a/adhocracy4/dashboard/mixins.py
+++ b/adhocracy4/dashboard/mixins.py
@@ -129,13 +129,13 @@ def form_valid(self, form):
 
 
 class DashboardComponentDeleteSignalMixin(edit.DeletionMixin):
-    def delete(self, request, *args, **kwargs):
+    def form_valid(self, request, *args, **kwargs):
         # Project and module have to be stored before delete is called as
         # they may rely on the still existing db object.
         project = self.project
         module = self.module
 
-        response = super().delete(request, *args, **kwargs)
+        response = super().form_valid(request, *args, **kwargs)
 
         component = self.component
         if component.identifier in components.projects:


Test patch:
Repository: ansible-collections/community.general

Issue:
manageiq_provider fails creating AWS provider on python 3 environment with serialization error
<!--- Verify first that your issue is not already reported on GitHub -->
<!--- Also test if the latest release and devel branch are affected too -->
<!--- Complete *all* sections as described, this form is processed automatically -->

##### SUMMARY
mangeiq_provider fails creating an AWS provider if executed with python 3. It works without as expected on python 2. Other providers were not tested.

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
manageiq_provider

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```paste below
2.9
```

##### CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```paste below

```

##### OS / ENVIRONMENT
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->
Doesn't work on python 3 environment. Neither on AWX 10.0.0 nor on local installation in python 3 virtual environment


##### STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->

<!--- Paste example playbooks or commands between quotes below -->
```yaml
---
- hosts: localhost
  gather_facts: no
  tasks:
    - manageiq_provider:
        name: test1234
        type: Amazon
        state: present
        zone: AWS
        provider_region: eu-central-1
        provider:
          hostname: apigateway.eu-central-1.amazonaws.com
          userid: "{{ accesskey }}"
          password: "{{ secretkey }}"
        manageiq_connection:
          url: "{{ manageiqserver }}"
          username: "{{ manageiqsuser }}"
          password: "{{ manageiqpassword }}"

```

<!--- HINT: You can paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- Describe what you expected to happen when running the steps above -->
Successful run

##### ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes -->
```paste below
fatal: [localhost]: FAILED! => {"changed": false, "msg": "failed to update provider test1234: Object of type map is not JSON serializable"}
```



Discussion:

Resolving patch:
diff --git a/plugins/modules/remote_management/manageiq/manageiq_provider.py b/plugins/modules/remote_management/manageiq/manageiq_provider.py
--- a/plugins/modules/remote_management/manageiq/manageiq_provider.py
+++ b/plugins/modules/remote_management/manageiq/manageiq_provider.py
@@ -571,7 +571,7 @@ def delete_nulls(h):
         a hash without nulls
     """
     if isinstance(h, list):
-        return map(delete_nulls, h)
+        return [delete_nulls(i) for i in h]
     if isinstance(h, dict):
         return dict((k, delete_nulls(v)) for k, v in h.items() if v is not None)
 


Test patch: