internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: digitalfabrik/integreat-cms

Issue:
Changed date of page with live content
### Describe the Bug
<!-- A clear and concise description of what the bug is. -->
At the moment, live content is not taken into account by the `modified_gmt`/`last_updated` field in the API. 

### Steps to Reproduce

1. Add live content to a page 
2. Retrieve page api endpoint 
3. See that the `modified_gmt` field did not change 

### Expected Behavior
<!-- A clear and concise description of what you expected to happen. -->
- Use the source page time stamp, if the source page is making up 100% of the content
- Use the target page timestamp if content is mixed.


### Actual Behavior
<!-- A clear and concise description of what actually happened. -->
The live content page does not impact the changed date. 

### Additional Information
<!-- Add any other context (e.g. logs, screenshots, etc.) about the problem here. -->




Discussion:

Resolving patch:
diff --git a/src/api/v3/pages.py b/src/api/v3/pages.py
--- a/src/api/v3/pages.py
+++ b/src/api/v3/pages.py
@@ -40,7 +40,7 @@ def transform_page(page_translation):
         "url": page_translation.permalink,
         "path": page_translation.slug,
         "title": page_translation.title,
-        "modified_gmt": page_translation.last_updated,
+        "modified_gmt": page_translation.combined_last_updated,
         "excerpt": page_translation.text,
         "content": page_translation.combined_text,
         "parent": parent,
diff --git a/src/cms/models/pages/page.py b/src/cms/models/pages/page.py
--- a/src/cms/models/pages/page.py
+++ b/src/cms/models/pages/page.py
@@ -137,7 +137,7 @@ def get_mirrored_page(self, language_code):
         :rtype: str
         """
         if self.mirrored_page:
-            return self.mirrored_page.get_translation(language_code)
+            return self.mirrored_page.get_public_translation(language_code)
         return None
 
     class Meta:
diff --git a/src/cms/models/pages/page_translation.py b/src/cms/models/pages/page_translation.py
--- a/src/cms/models/pages/page_translation.py
+++ b/src/cms/models/pages/page_translation.py
@@ -119,6 +119,20 @@ def combined_text(self):
             return attached_text + self.text
         return self.text + attached_text
 
+    @property
+    def combined_last_updated(self):
+        """
+        This function combines the last_updated date from this PageTranslation and from a mirrored page.
+        If this translation has no content, then the date from the mirrored translation will be used. In
+        other cases, the date from this translation will be used.
+
+        :return: The last_upated date of this or the mirrored page translation
+        :rtype: ~datetime.datetime
+        """
+        if self.page.get_mirrored_page and not self.text:
+            return self.page.get_mirrored_page(self.language.code).last_updated
+        return self.last_updated
+
     @classmethod
     def get_translations(cls, region, language):
         """


Test patch:
Repository: digitalfabrik/integreat-cms

Issue:
Deliver fallback of missing imprint translations in API
### Motivation
<!-- A clear and concise description of what the motivation for the new feature is, and what problem it is solving. -->
The imprint is mandatory for all regions and languages.

### Proposed Solution
<!-- A clear and concise description of the feature you would like to add, and how it solves the motivating problem. -->
Always return a result in the [imprint API](https://github.com/Integreat/integreat-cms/blob/develop/src/api/v3/imprint.py). If the translation is missing, deliver the imprint in the region's default language.

### Alternatives
<!-- A clear and concise description of any alternative solutions or features you've considered, and why you're proposed solution is better. -->


### Additional Context
<!-- Add any other information or screenshots about the feature request here. -->




Discussion:

Resolving patch:
diff --git a/src/api/v3/imprint.py b/src/api/v3/imprint.py
--- a/src/api/v3/imprint.py
+++ b/src/api/v3/imprint.py
@@ -41,7 +41,9 @@ def transform_imprint(imprint_translation):
 # pylint: disable=unused-argument
 def imprint(request, region_slug, language_code):
     """
-    Get imprint for language and return JSON object to client
+    Get imprint for language and return JSON object to client. If no imprint translation
+    is available in the selected language, try to return the translation in the region
+    default language.
 
     :param request: Django request
     :type request: ~django.http.HttpRequest
@@ -58,5 +60,11 @@ def imprint(request, region_slug, language_code):
         imprint_translation = region.imprint.get_public_translation(language_code)
         if imprint_translation:
             return JsonResponse(transform_imprint(imprint_translation))
+        if region.default_language:
+            imprint_default_translation = region.imprint.get_public_translation(
+                region.default_language.code
+            )
+            if imprint_default_translation:
+                return JsonResponse(transform_imprint(imprint_default_translation))
     # If imprint does not exist, return an empty response. Turn off Safe-Mode to allow serializing arrays
     return JsonResponse([], safe=False)


Test patch:
Repository: digitalfabrik/integreat-cms

Issue:
Clarify hierarchy in page tree
### Motivation
<!-- A clear and concise description of what the motivation for the new feature is, and what problem it is solving. -->
At the moment, it is not completely clear how pages are structured in the page tree and how the page order can be changed.

### Proposed Solution
<!-- A clear and concise description of the feature you would like to add, and how it solves the motivating problem. -->
Label the first page tree column with "hierarchy" and add a message box or tooltip to point out the possibility of drag & drop in the page tree.

### Alternatives
<!-- A clear and concise description of any alternative solutions or features you've considered, and why you're proposed solution is better. -->
If you have better ideas how to achieve this goal, give them a try!


Discussion:

Resolving patch:
diff --git a/src/cms/forms/pages/page_form.py b/src/cms/forms/pages/page_form.py
--- a/src/cms/forms/pages/page_form.py
+++ b/src/cms/forms/pages/page_form.py
@@ -7,6 +7,7 @@
 from django.contrib.auth.models import Permission
 from django.db.models import Q
 from django.urls import reverse
+from django.utils.text import capfirst
 from django.utils.translation import ugettext as _, get_language
 from django.utils.safestring import mark_safe
 
@@ -179,7 +180,10 @@ class PageForm(forms.ModelForm):
     """
 
     parent = ParentField(
-        queryset=Page.objects.all(), required=False, widget=ParentFieldWidget()
+        queryset=Page.objects.all(),
+        required=False,
+        widget=ParentFieldWidget(),
+        label=capfirst(Page._meta.get_field("parent").verbose_name),
     )
     related_page = forms.ModelChoiceField(
         queryset=Page.objects.all(), required=False, widget=forms.HiddenInput()
diff --git a/src/cms/templatetags/tree_filters.py b/src/cms/templatetags/tree_filters.py
--- a/src/cms/templatetags/tree_filters.py
+++ b/src/cms/templatetags/tree_filters.py
@@ -19,3 +19,17 @@ def get_descendants(node):
     :rtype: list [ int ]
     """
     return [descendant.id for descendant in node.get_descendants(include_self=True)]
+
+
+@register.filter
+def get_children(node):
+    """
+    This filter returns the ids of all the node's direct children.
+
+    :param node: The requested node
+    :type node: ~cms.models.pages.page.Page or ~cms.models.languages.language_tree_node.LanguageTreeNode
+
+    :return: The list of all the node's children's ids
+    :rtype: list [ int ]
+    """
+    return [child.id for child in node.children.all()]


Test patch:
Repository: digitalfabrik/integreat-cms

Issue:
Support multi-line feedback
### Motivation
<!-- A clear and concise description of what the motivation for the new feature is, and what problem it is solving. -->
When users sent multiple lines of feedback, the lines are shown wrapped in the backend list. It would make the feedback more readable if the feedback was shown exactly like the user submitted it.

### Proposed Solution
<!-- A clear and concise description of the feature you would like to add, and how it solves the motivating problem. -->
- Change `CharField` to `TextField`
- Use the css class `whitespace-pre-line` when rendering feedback
- Collapse feedback which has multiple lines

### Alternatives
<!-- A clear and concise description of any alternative solutions or features you've considered, and why you're proposed solution is better. -->


### Additional Context
<!-- Add any other information or screenshots about the feature request here. -->




Discussion:

Resolving patch:
diff --git a/src/cms/models/feedback/feedback.py b/src/cms/models/feedback/feedback.py
--- a/src/cms/models/feedback/feedback.py
+++ b/src/cms/models/feedback/feedback.py
@@ -36,7 +36,7 @@ class Feedback(models.Model):
         verbose_name=_("rating"),
         help_text=_("Whether the feedback is positive or negative"),
     )
-    comment = models.CharField(max_length=1000, blank=True, verbose_name=_("comment"))
+    comment = models.TextField(blank=True, verbose_name=_("comment"))
     is_technical = models.BooleanField(
         verbose_name=_("technical"),
         help_text=_("Whether or not the feedback is targeted at the developers"),


Test patch:
Repository: digitalfabrik/integreat-cms

Issue:
Improve POI list and form
### Motivation
<!-- A clear and concise description of what the motivation for the new feature is, and what problem it is solving. -->


### Proposed Solution
<!-- A clear and concise description of the feature you would like to add, and how it solves the motivating problem. -->
List:

- Remove id and version columns
- Sort alphabetically after title in region's default language

Form:
- Add field to not show the location on the map (used for event locations, e.g. multiple instances of the same address but different rooms etc)
- Use the same dynamic slug/link update mechanism like for pages

### Alternatives
<!-- A clear and concise description of any alternative solutions or features you've considered, and why you're proposed solution is better. -->


### Additional Context
<!-- Add any other information or screenshots about the feature request here. -->




Discussion:

Resolving patch:
diff --git a/src/cms/forms/pois/poi_form.py b/src/cms/forms/pois/poi_form.py
--- a/src/cms/forms/pois/poi_form.py
+++ b/src/cms/forms/pois/poi_form.py
@@ -29,6 +29,7 @@ class Meta:
             "country",
             "latitude",
             "longitude",
+            "location_not_on_map",
             "icon",
         ]
         #: The widgets which are used in this form
diff --git a/src/cms/models/pois/poi.py b/src/cms/models/pois/poi.py
--- a/src/cms/models/pois/poi.py
+++ b/src/cms/models/pois/poi.py
@@ -29,6 +29,11 @@ class POI(models.Model):
     longitude = models.FloatField(
         verbose_name=_("longitude"), help_text=_("The longitude coordinate")
     )
+    location_not_on_map = models.BooleanField(
+        default=False,
+        verbose_name=_("Do not show this location on map"),
+        help_text=_("Tick if you do not show this location on map"),
+    )
     icon = models.ImageField(
         null=True,
         blank=True,


Test patch:
Repository: digitalfabrik/integreat-cms

Issue:
Improve push notification form
### Motivation
<!-- A clear and concise description of what the motivation for the new feature is, and what problem it is solving. -->


### Proposed Solution
<!-- A clear and concise description of the feature you would like to add, and how it solves the motivating problem. -->
- [x] Make input field to text area
- [x] Show how many characters are remaining
- [x] Rename "Push-Notifications" to "News" / "Nachrichten"
- [x] Change not sent symbol "x" to text "Message not sent yet"


### Additional Context
![Bildschirmfoto vom 2021-04-13 16-42-11](https://user-images.githubusercontent.com/15608678/114572956-3be7fd00-9c78-11eb-928e-b156602af7ac.png)

Files that need some editing for that issue are:

- src/cms/templates/push_notifications/push_notification_form.html (for everything related to the HTML-Input Field)
- src/cms/locale/de/LC_MESSAGES/django.po (for everything that needs some new translation. Search for "Push Notification" and change the german translation to "Nachricht/Nachrichten"





Discussion:

Resolving patch:
diff --git a/src/cms/models/push_notifications/push_notification_translation.py b/src/cms/models/push_notifications/push_notification_translation.py
--- a/src/cms/models/push_notifications/push_notification_translation.py
+++ b/src/cms/models/push_notifications/push_notification_translation.py
@@ -16,7 +16,7 @@ class PushNotificationTranslation(models.Model):
         blank=True,
         verbose_name=_("title"),
     )
-    text = models.CharField(
+    text = models.TextField(
         max_length=250,
         blank=True,
         verbose_name=_("content"),


Test patch:
Repository: digitalfabrik/integreat-cms

Issue:
Do not serve `node_modules` under `/static`
### Motivation
<!-- A clear and concise description of what the motivation for the new feature is, and what problem it is solving. -->
It's a bit overkill to serve the complete `node_modules` directory under `/static` just to make our npm dependencies work as expected.

### Proposed Solution
<!-- A clear and concise description of the feature you would like to add, and how it solves the motivating problem. -->
Instead, we should use browserify in combination with babel to bundle all npm dependencies we need (tinymce, umbrellajs, feather-icons, base64-js and chart.js) in the default static directory.

### Alternatives
<!-- A clear and concise description of any alternative solutions or features you've considered, and why you're proposed solution is better. -->
We could also use another framework than browserify, but as we use this already for other tasks, we might as well stick with it.

### Additional Context
<!-- Add any other information or screenshots about the feature request here. -->

- For tailwind, we could use [django-tailwind](https://pypi.org/project/django-tailwind/)
- After this task is done, remove `STATICFILES_DIRS` from `settings.py`.



Discussion:

Resolving patch:
diff --git a/src/backend/settings.py b/src/backend/settings.py
--- a/src/backend/settings.py
+++ b/src/backend/settings.py
@@ -612,12 +612,6 @@
 #: (see :setting:`django:STATIC_URL` and :doc:`Managing static files <django:howto/static-files/index>`)
 STATIC_URL = "/static/"
 
-#: This setting defines the additional locations the staticfiles app will traverse
-#: (see :setting:`django:STATICFILES_DIRS` and :doc:`Managing static files <django:howto/static-files/index>`)
-STATICFILES_DIRS = [
-    os.path.join(BASE_DIR, "../node_modules"),
-]
-
 #: The list of finder backends that know how to find static files in various locations
 #: (see :setting:`django:STATICFILES_FINDERS`)
 STATICFILES_FINDERS = (


Test patch:
Repository: digitalfabrik/integreat-cms

Issue:
Admin menu visible in user settings
### Describe the Bug
<!-- A clear and concise description of what the bug is. -->
Since the user settings are region-independent, we didn't include the region parameter in the [user_settings](https://github.com/Integreat/integreat-cms/blob/0d623d97bfd2bc91765fbc3e93c4f37a7f15b0dc/src/cms/urls.py#L258) url.
However, even for non-staff users, this means there are links to the admin dashboard which shouldn't be the case.

### Steps to Reproduce

1. Create a non-staff user
2. Go to the user settings

### Expected Behavior
<!-- A clear and concise description of what you expected to happen. -->
The menu should correspond to one region of the user. Ideally the same region in which the user was before he clicked on the user settings

### Actual Behavior
<!-- A clear and concise description of what actually happened. -->
Even non-staff users are in the network settings

### Additional Information

Probably it would be sufficient to add a new url route which contains the `region_slug` paramter if users visit the user settings coming from a region. If possible, admin users should still see the admin menu when they access the user settings while they are in the network settings.
<!-- Add any other context (e.g. logs, screenshots, etc.) about the problem here. -->
![Screenshot_2021-04-19 Integreat Redaktionssystem](https://user-images.githubusercontent.com/16021269/115249843-4f3c1200-a129-11eb-930c-6bc78f5e6657.png)



Discussion:

Resolving patch:
diff --git a/src/cms/urls.py b/src/cms/urls.py
--- a/src/cms/urls.py
+++ b/src/cms/urls.py
@@ -938,6 +938,11 @@
                         ]
                     ),
                 ),
+                url(
+                    r"^user_settings/$",
+                    settings.UserSettingsView.as_view(),
+                    name="user_settings",
+                ),
             ]
         ),
     ),
diff --git a/src/cms/views/settings/mfa/register_user_mfa_key_view.py b/src/cms/views/settings/mfa/register_user_mfa_key_view.py
--- a/src/cms/views/settings/mfa/register_user_mfa_key_view.py
+++ b/src/cms/views/settings/mfa/register_user_mfa_key_view.py
@@ -87,4 +87,14 @@ def post(self, request, *args, **kwargs):
                 'The 2-factor authentication key "{}" was successfully registered.'
             ).format(new_key.name),
         )
-        return JsonResponse({"success": True, "successUrl": reverse("user_settings")})
+        # Determine success url
+        if request.user.is_superuser or request.user.is_staff:
+            # If user is superuser, return to user settings in network area
+            success_url = reverse("user_settings")
+        else:
+            # If user is region-user, return to user settings in first region
+            success_url = reverse(
+                "user_settings",
+                kwargs={"region_slug": request.user.profile.regions.first().slug},
+            )
+        return JsonResponse({"success": True, "successUrl": success_url})


Test patch:
Repository: digitalfabrik/integreat-cms

Issue:
Implement WordPress API endpoint URL patterns
### Motivation
With Django we decided to introduce a new, clean API URL pattern. However, the apps do not use this API yet. We already have exports of the content and the app team could start end to end testing, as soon as the app can interface with the CMS.


### Proposed Solution
We need to implement the URL pattern defined in https://github.com/Integreat/cms/wiki/REST-APIv3-Documentation
The WordPress URL pattern should be available in addition to the current (clean) URLs, so that the app team can switch over.

Please test the integration with the web app by [changing the back end URL](https://github.com/Integreat/cms/wiki/REST-APIv3-Documentation#test-api-with-webapp) to the Django system. If you need help finding issues or interpreting error messages, feel free to contact the app team for help.

### Alternatives
None, needs to be done.



Discussion:

Resolving patch:
diff --git a/src/api/urls.py b/src/api/urls.py
--- a/src/api/urls.py
+++ b/src/api/urls.py
@@ -27,11 +27,7 @@
 from .v3.offers import offers
 from .v3.single_page import single_page
 
-urlpatterns = [
-    url(r"^regions/?$", regions, name="api_regions"),
-    url(r"^regions/live/?$", liveregions, name="api_regions_live"),
-    url(r"^regions/hidden/?$", hiddenregions, name="api_regions_hidden"),
-    url(r"^regions/pushnew/?$", pushnew, name="api_pushnew"),
+api_urlpatterns = [
     url(
         r"^(?P<region_slug>[-\w]+)/",
         include(
@@ -135,3 +131,18 @@
         ),
     ),
 ]
+
+region_api_urlpatterns = [
+    url(r"^$", regions, name="api_regions"),
+    url(r"^live/?$", liveregions, name="api_regions_live"),
+    url(r"^hidden/?$", hiddenregions, name="api_regions_hidden"),
+    url(r"^pushnew/?$", pushnew, name="api_pushnew"),
+]
+
+
+urlpatterns = [
+    url(r"^api/", include(api_urlpatterns)),
+    url(r"^api/regions/", include(region_api_urlpatterns)),
+    url(r"^wp-json/extensions/v3/", include(api_urlpatterns)),
+    url(r"^wp-json/extensions/v3/sites/", include(region_api_urlpatterns)),
+]
diff --git a/src/backend/urls.py b/src/backend/urls.py
--- a/src/backend/urls.py
+++ b/src/backend/urls.py
@@ -22,7 +22,7 @@
 
 
 urlpatterns = [
-    url(r"^api/", include("api.urls")),
+    url(r"^", include("api.urls")),
     url(r"^i18n/", include("django.conf.urls.i18n")),
 ]
 


Test patch:
Repository: digitalfabrik/integreat-cms

Issue:
Crash when trying to delete a region
### Describe the Bug
Deleting a region via this page: 
![grafik](https://user-images.githubusercontent.com/78504586/122641895-558a4280-d108-11eb-93db-2bd36f8b3ce2.png)
fails with a `FieldError`:
![grafik](https://user-images.githubusercontent.com/78504586/122641888-42777280-d108-11eb-9344-86ecfb40b78a.png)


### Steps to Reproduce

1. Go to the regions tab
2. Edit any region
3. Scroll down and click on delete. Click ok on the warning.
4. See the error

### Expected Behavior
The server does not fail and deletes the region


### Actual Behavior
The server crashes and does not delete the region


### Additional Information
/


Discussion:

Resolving patch:
diff --git a/src/cms/models/languages/language_tree_node.py b/src/cms/models/languages/language_tree_node.py
--- a/src/cms/models/languages/language_tree_node.py
+++ b/src/cms/models/languages/language_tree_node.py
@@ -194,4 +194,4 @@ class Meta:
         #: The custom permissions for this model
         permissions = (("manage_language_tree", "Can manage language tree"),)
         #: The fields which are used to sort the returned objects of a QuerySet
-        ordering = ["region", "level", "parent"]
+        ordering = ["region", "level", "parent__pk"]
diff --git a/src/cms/views/regions/region_actions.py b/src/cms/views/regions/region_actions.py
--- a/src/cms/views/regions/region_actions.py
+++ b/src/cms/views/regions/region_actions.py
@@ -45,6 +45,8 @@ def delete_region(request, *args, **kwargs):
     # Remove hierarchy to prevent ProtectedError when children get deleted before their parents
     region.pages.update(parent=None)
     region.language_tree_nodes.update(parent=None)
+    # Prevent ProtectedError when location gets deleted before their events
+    region.events.update(location=None)
     # Delete region and cascade delete all contents
     deleted_objects = region.delete()
     logger.info(


Test patch:
Repository: digitalfabrik/integreat-cms

Issue:
Provide default order for region model
### Motivation
Currently the region and user lists does not have a default order when they get queried. This results in lists with entries that are hard to find. I suggest that we provide a default alphabetical order by the name.

![grafik](https://user-images.githubusercontent.com/15608678/125632813-53ed3865-c4f1-4dba-bab0-c831515261d8.png)




Discussion:

Resolving patch:
diff --git a/src/cms/models/regions/region.py b/src/cms/models/regions/region.py
--- a/src/cms/models/regions/region.py
+++ b/src/cms/models/regions/region.py
@@ -408,3 +408,5 @@ class Meta:
         verbose_name_plural = _("regions")
         #: The default permissions for this model
         default_permissions = ("change", "delete", "view")
+        #: The default sorting for this model
+        ordering = ["name"]
diff --git a/src/cms/views/regions/region_list_view.py b/src/cms/views/regions/region_list_view.py
--- a/src/cms/views/regions/region_list_view.py
+++ b/src/cms/views/regions/region_list_view.py
@@ -44,7 +44,7 @@ def get(self, request, *args, **kwargs):
         """
         regions = Region.objects.all()
         # for consistent pagination querysets should be ordered
-        paginator = Paginator(regions.order_by("created_date"), PER_PAGE)
+        paginator = Paginator(regions, PER_PAGE)
         chunk = request.GET.get("page")
         region_chunk = paginator.get_page(chunk)
         return render(


Test patch: