internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: django-wiki/django-wiki

Issue:
404 on initital user create with /wiki
Python Version: 3.5.2
Django version: 1.10
Wiki version: 0.2.4

Wiki URL's are configured to direct to /wiki as indicated in the installation instructions.

When a user goes to the wiki and creates an account, they are able to successfully, at which point they are directed to the login page. On that initial login, they are sent to http://foo.net/accounts/profile/

This results in a 404 error. Django debug giving:

```
Using the URLconf defined in foo.urls, Django tried these URL patterns, in this order:
^$ [name='index']
^admin/
^wiki/
^notifications/
The current URL, accounts/profile/, didn't match any of these.
```

If they return to http://foo.net/wiki they are logged in and are able to log out/in normally without trouble.


Discussion:
You should set this in your project's settings:

```
from django.core.urlresolvers import reverse_lazy
LOGIN_REDIRECT_URL = reverse_lazy('wiki:get', kwargs={'path': ''})
```

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -213,7 +213,7 @@ def setup(app):
 # Add any paths that contain custom static files (such as style sheets) here,
 # relative to this directory. They are copied after the builtin static files,
 # so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
+html_static_path = []
 
 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
 # using the given strftime format.


Test patch:
Repository: django-wiki/django-wiki

Issue:
HTML not marked safe when pulled from cache
get_cached_content() in models/article.py does not mark content as safe when content is found in cache. This results in HTML being printed to the screen instead of the formatted text. 

The following fixes the problem:
```
    def get_cached_content(self):
	"""Returns cached """
        cache_key = self.get_cache_key()
        cached_content = cache.get(cache_key)
        if cached_content is None:
	    cached_content = self.render()
            cache.set(cache_key, cached_content, settings.CACHE_TIMEOUT)
	else:
            cached_content = mark_safe(cached_content)
        return cached_content
```



Discussion:

Resolving patch:
diff --git a/src/wiki/models/article.py b/src/wiki/models/article.py
--- a/src/wiki/models/article.py
+++ b/src/wiki/models/article.py
@@ -217,12 +217,14 @@ def get_cache_key(self):
         )
 
     def get_cached_content(self):
-        """Returns cached """
+        """Returns cached version of rendered article"""
         cache_key = self.get_cache_key()
         cached_content = cache.get(cache_key)
         if cached_content is None:
             cached_content = self.render()
             cache.set(cache_key, cached_content, settings.CACHE_TIMEOUT)
+        else:
+            cached_content = mark_safe(cached_content)
         return cached_content
 
     def clear_cache(self):
@@ -354,7 +356,7 @@ class ArticleRevision(BaseRevisionMixin, models.Model):
 
     # TODO:
     # Allow a revision to redirect to another *article*. This
-    # way, we can redirects and still maintain old content.
+    # way, we can have redirects and still maintain old content.
     # redirect = models.ForeignKey('Article', null=True, blank=True,
     #                             verbose_name=_('redirect'),
     #                             help_text=_('If set, the article will redirect to the contents of another article.'),


Test patch:
diff --git a/tests/core/test_models.py b/tests/core/test_models.py
--- a/tests/core/test_models.py
+++ b/tests/core/test_models.py
@@ -132,3 +132,11 @@ def test_article_is_related_to_group(self):
 
         self.assertEqual(a.group, g)
         self.assertIn(a, g.article_set.all())
+
+    def test_cache(self):
+        a = Article.objects.create()
+        ArticleRevision.objects.create(
+            article=a, title="test", content="# header"
+        )
+        self.assertEqual(a.get_cached_content(), """<h1 id="wiki-toc-header">header</h1>""")
+        self.assertEqual(a.get_cached_content(), """<h1 id="wiki-toc-header">header</h1>""")
Repository: django-wiki/django-wiki

Issue:
Bootstrap 3 class for message tags
In #651, we just added a quick fix for the test project.

But it's probably better to have a template filter to handle the behaviour only for the html templates that django-wiki uses, rather than to showcase some site-wide pattern.


Discussion:

Resolving patch:
diff --git a/src/wiki/conf/settings.py b/src/wiki/conf/settings.py
--- a/src/wiki/conf/settings.py
+++ b/src/wiki/conf/settings.py
@@ -3,6 +3,7 @@
 import bleach
 
 from django.conf import settings as django_settings
+from django.contrib.messages import constants as messages
 from django.core.files.storage import default_storage
 from django.core.urlresolvers import reverse_lazy
 from django.utils.translation import ugettext_lazy as _
@@ -146,6 +147,19 @@
 #: Do we want to log IPs of logged in users?
 LOG_IPS_USERS = getattr(django_settings, 'WIKI_LOG_IPS_USERS', False)
 
+#: Map from message.tag to bootstrap class name
+MESSAGE_TAG_CSS_CLASS = getattr(
+    django_settings,
+    'WIKI_MESSAGE_TAG_CSS_CLASS',
+    {
+        messages.DEFAULT_TAGS[messages.DEBUG]: "alert alert-info",
+        messages.DEFAULT_TAGS[messages.ERROR]: "alert alert-danger",
+        messages.DEFAULT_TAGS[messages.INFO]: "alert alert-info",
+        messages.DEFAULT_TAGS[messages.SUCCESS]: "alert alert-success",
+        messages.DEFAULT_TAGS[messages.WARNING]: "alert alert-warning",
+    }
+)
+
 ####################################
 # PERMISSIONS AND ACCOUNT HANDLING #
 ####################################
diff --git a/src/wiki/templatetags/wiki_tags.py b/src/wiki/templatetags/wiki_tags.py
--- a/src/wiki/templatetags/wiki_tags.py
+++ b/src/wiki/templatetags/wiki_tags.py
@@ -75,6 +75,22 @@ def wiki_form(context, form_obj):
     return context
 
 
+@register.inclusion_tag('wiki/includes/messages.html', takes_context=True)
+def wiki_messages(context):
+
+    messages = context.get('messages', [])
+    for message in messages:
+        message.css_class = ""
+        for tag in message.tags.split(" "):
+            # Drop KeyError if MESSAGE_TAG_CSS_CLASS doesn't have the tag,
+            # that seems valuable.
+            message.css_class += " " + settings.MESSAGE_TAG_CSS_CLASS[tag]
+    context.update({
+        'messages': messages
+    })
+    return context
+
+
 # XXX html strong tag is hardcoded
 @register.filter
 def get_content_snippet(content, keyword, max_words=30):
diff --git a/testproject/testproject/settings/base.py b/testproject/testproject/settings/base.py
--- a/testproject/testproject/settings/base.py
+++ b/testproject/testproject/settings/base.py
@@ -13,7 +13,6 @@
 
 import os
 
-from django.contrib.messages import constants as messages
 from django.core.urlresolvers import reverse_lazy
 
 
@@ -153,9 +152,6 @@
 MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
 MEDIA_URL = '/media/'
 
-MESSAGE_TAGS = {
-    messages.ERROR: 'danger'
-}
 
 WIKI_ANONYMOUS_WRITE = True
 WIKI_ANONYMOUS_CREATE = False


Test patch:
Repository: django-wiki/django-wiki

Issue:
markdow error <sup id = "fnref: 1"> duplicate (footnotes)
now
![1](https://fotos.subefotos.com/c83c25687ddca44c7a2b7b8ab3cf78f4o.png)

![2](https://fotos.subefotos.com/8e46f36b4f13d53f6a6655556f0b7620o.png)

Here is an example with wiki == 0.2b2
![3](https://fotos.subefotos.com/b21939eaa52be55ed81d6171e8fadd4co.png)




Discussion:

Resolving patch:
diff --git a/src/wiki/conf/settings.py b/src/wiki/conf/settings.py
--- a/src/wiki/conf/settings.py
+++ b/src/wiki/conf/settings.py
@@ -63,6 +63,7 @@
     'img',
     'pre',
     'span',
+    'sup',
     'table',
     'thead',
     'tbody',


Test patch:
Repository: django-wiki/django-wiki

Issue:
Installation of 0.2.3 using pip seems to be missing a file
specifically the glyphicons font from bootstrap, located at: `/wiki/static/wiki/bootstrap/fonts/glyphicons-halflings-regular.woff2` within the repository

causes a bug when calling `collectstatic`.. I've verified it by manually downloading the `.whl` archive from pypi and it seems to be missing there.., maybe something went wrong while publishing, since the file is in the repository in the `0.2.3` tag? 


Discussion:
I guess the MANIFEST should include also `.woff2` in addition to `.woff` and others.
Yes, thanks for spotting this!

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -4,6 +4,7 @@
 
 import os
 import sys
+
 from setuptools import find_packages, setup
 
 from wiki import __version__
@@ -30,7 +31,7 @@ def read_file(fname):
     "Django>=1.8,<1.11",
     "bleach>=1.5,<2",
     "Pillow",
-    "django-nyt>=1.0b1",
+    "django-nyt>=1.0b1,<1.1",
     "six",
     "django-mptt>=0.8.6,<0.9",
     "django-sekizai>=0.10",
diff --git a/wiki/__init__.py b/wiki/__init__.py
--- a/wiki/__init__.py
+++ b/wiki/__init__.py
@@ -19,5 +19,5 @@
 
 from wiki.core.version import get_version
 
-VERSION = (0, 2, 3, 'final', 0)
+VERSION = (0, 2, 5, 'final', 0)
 __version__ = get_version(VERSION)


Test patch:
Repository: django-wiki/django-wiki

Issue:
Installation of 0.2.3 using pip seems to be missing a file
specifically the glyphicons font from bootstrap, located at: `/wiki/static/wiki/bootstrap/fonts/glyphicons-halflings-regular.woff2` within the repository

causes a bug when calling `collectstatic`.. I've verified it by manually downloading the `.whl` archive from pypi and it seems to be missing there.., maybe something went wrong while publishing, since the file is in the repository in the `0.2.3` tag? 


Discussion:
I guess the MANIFEST should include also `.woff2` in addition to `.woff` and others.
Yes, thanks for spotting this!

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -37,7 +37,7 @@ def read_file(fname):
     "Django>=1.8,<2.0",
     "bleach>=1.5,<2",
     "Pillow",
-    "django-nyt>=1.0b1",
+    "django-nyt>=1.0b1,<1.1",
     "six",
     "django-mptt>=0.8.6,<0.9",
     "django-sekizai>=0.10",


Test patch:
Repository: django-wiki/django-wiki

Issue:
Translations out-of-date
I noticed the string "Search whole wiki..." has not been translated on my wiki because the translation file has not been updated since December 2017. Would you update the `django.po` file so I can work on the translation in Transifex? Thanks.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -50,7 +50,9 @@ def get_path(fname):
     'pytest-runner',
 ]
 
-development_requirements = test_requirements + test_lint_requirements
+development_requirements = test_requirements + test_lint_requirements + [
+    'pre-commit',
+]
 
 extras_requirements = {
     'devel': development_requirements,


Test patch:
Repository: django-wiki/django-wiki

Issue:
"Back to article" button links to itself on protected articles
It works like expected on special pages like `_create`, but not on wiki articles the user doesn't have access to. 
For example https://demo.django.wiki/HiddenArticle/ links to `/HiddenArticle/`. 
It should probably link to `../` or not display the back button if that doesn't make sense. 


Discussion:
I get the login page? How does the "permission denied" thing arise?
Ah, forgot to include that. 
You need to login as a user without access to the page. For example the `test` user with the password `test`. 

Resolving patch:
diff --git a/src/wiki/decorators.py b/src/wiki/decorators.py
--- a/src/wiki/decorators.py
+++ b/src/wiki/decorators.py
@@ -9,7 +9,7 @@
 from wiki.core.exceptions import NoRootURL
 
 
-def response_forbidden(request, article, urlpath):
+def response_forbidden(request, article, urlpath, read_denied=False):
     if request.user.is_anonymous:
         qs = request.META.get('QUERY_STRING', '')
         if qs:
@@ -21,14 +21,18 @@ def response_forbidden(request, article, urlpath):
         return HttpResponseForbidden(
             render_to_string(
                 "wiki/permission_denied.html",
-                context={'article': article, 'urlpath': urlpath},
+                context={
+                    'article': article,
+                    'urlpath': urlpath,
+                    'read_denied': read_denied
+                },
                 request=request
             )
         )
 
 
 # TODO: This decorator is too complex (C901)
-def get_article(func=None, can_read=True, can_write=False,  # noqa
+def get_article(func=None, can_read=True, can_write=False,  # noqa: max-complexity=13
                 deleted_contents=False, not_locked=False,
                 can_delete=False, can_moderate=False,
                 can_create=False):
@@ -130,7 +134,7 @@ def wrapper(request, *args, **kwargs):
             return response_forbidden(request, article, urlpath)
 
         if can_read and not article.can_read(request.user):
-            return response_forbidden(request, article, urlpath)
+            return response_forbidden(request, article, urlpath, read_denied=True)
 
         if (can_write or can_create) and not article.can_write(request.user):
             return response_forbidden(request, article, urlpath)


Test patch:
Repository: django-wiki/django-wiki

Issue:
jquery 1.12.4 is bundled, some security holes exist
see [CVE-2015-9251](https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=CVE-2015-9251) and others




Discussion:
Thanks! Even worse is that for some perceived convenience I removed the version string from the file name. Which makes the problem harder to spot.

https://github.com/django-wiki/django-wiki/tree/master/src/wiki/static/wiki/js

Quick work-around: Put a fixed version of JQuery in a static path `wiki/js/jquery.min.js`, for instance by using `STATIC_DIRS`.

Resolving patch:
diff --git a/src/wiki/__init__.py b/src/wiki/__init__.py
--- a/src/wiki/__init__.py
+++ b/src/wiki/__init__.py
@@ -19,5 +19,5 @@
 
 default_app_config = 'wiki.apps.WikiConfig'
 
-VERSION = (0, 4, 0, 'final', 0)
+VERSION = (0, 4, 1, 'final', 0)
 __version__ = get_version(VERSION)


Test patch:
Repository: django-wiki/django-wiki

Issue:
Tests are failing in Travis
```
Traceback (most recent call last):

  File "/home/travis/build/django-wiki/django-wiki/.tox/py36-django22/bin/pytest", line 7, in <module>

    from pytest import main

  File "/home/travis/build/django-wiki/django-wiki/.tox/py36-django22/lib/python3.6/site-packages/pytest.py", line 13, in <module>

    from _pytest.fixtures import fixture, yield_fixture

  File "/home/travis/build/django-wiki/django-wiki/.tox/py36-django22/lib/python3.6/site-packages/_pytest/fixtures.py", line 845, in <module>

    class FixtureFunctionMarker(object):

  File "/home/travis/build/django-wiki/django-wiki/.tox/py36-django22/lib/python3.6/site-packages/_pytest/fixtures.py", line 847, in FixtureFunctionMarker

    params = attr.ib(convert=attr.converters.optional(tuple))

TypeError: attrib() got an unexpected keyword argument 'convert'
```

I suspect that it has something to do with the `attrs` 19.2.0 package. The requirements in setup.py haven't been updated in a while. 
https://stackoverflow.com/questions/58189683/typeerror-attrib-got-an-unexpected-keyword-argument-convert 
Tests are failing in Travis
```
Traceback (most recent call last):

  File "/home/travis/build/django-wiki/django-wiki/.tox/py36-django22/bin/pytest", line 7, in <module>

    from pytest import main

  File "/home/travis/build/django-wiki/django-wiki/.tox/py36-django22/lib/python3.6/site-packages/pytest.py", line 13, in <module>

    from _pytest.fixtures import fixture, yield_fixture

  File "/home/travis/build/django-wiki/django-wiki/.tox/py36-django22/lib/python3.6/site-packages/_pytest/fixtures.py", line 845, in <module>

    class FixtureFunctionMarker(object):

  File "/home/travis/build/django-wiki/django-wiki/.tox/py36-django22/lib/python3.6/site-packages/_pytest/fixtures.py", line 847, in FixtureFunctionMarker

    params = attr.ib(convert=attr.converters.optional(tuple))

TypeError: attrib() got an unexpected keyword argument 'convert'
```

I suspect that it has something to do with the `attrs` 19.2.0 package. The requirements in setup.py haven't been updated in a while. 
https://stackoverflow.com/questions/58189683/typeerror-attrib-got-an-unexpected-keyword-argument-convert 


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -36,14 +36,14 @@ def get_path(fname):
 
 test_requirements = [
     'django-functest>=1.0.3,<1.1',
-    'pytest>=3.4,<3.5',
-    'pytest-django>=3.1,<3.2',
-    'pytest-cov>=2.4,<2.5',
-    'pytest-pythonpath>=0.7,<0.8',
+    'pytest>=5.2,<5.3',
+    'pytest-django',
+    'pytest-cov',
+    'pytest-pythonpath',
 ]
 
 test_lint_requirements = [
-    'flake8>=3.5,<3.6',
+    'flake8>=3.7,<3.8',
     'flake8-isort',
 ]
 


Test patch:
Repository: django-wiki/django-wiki

Issue:
Markdown version bump needed for rest framework
restframework requires markdown 3.1.1 resulting in this error with restframework.

https://stackoverflow.com/questions/57479412/attributeerror-at-ordereddict-object-has-no-attribute-register-in-django-r


Discussion:
Thanks for filing this @olymk2 - have you investigated this? Try opening a PR with the version bump and see how the tests react.
I ended up just pointing pip at master as I needed things fixed, seems its fixed in master so we probably just need a release to actually fix things

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -31,7 +31,7 @@ def get_path(fname):
     "django-mptt>=0.9,<0.10",
     "django-sekizai>=0.10",
     "sorl-thumbnail>=12,<13",
-    "Markdown>=3.0.0,<3.1.0"
+    "Markdown>=3.1,<3.2.0"
 ]
 
 test_requirements = [


Test patch:
Repository: django-wiki/django-wiki

Issue:
Fix simple typo: occurances -> occurrences
# Issue Type

[x] Bug (Typo)

# Steps to Replicate

1. Examine src/wiki/plugins/editsection/views.py.
2. Search for `occurances`.

# Expected Behaviour

1. Should read `occurrences`.




Discussion:

Resolving patch:
diff --git a/src/wiki/plugins/editsection/views.py b/src/wiki/plugins/editsection/views.py
--- a/src/wiki/plugins/editsection/views.py
+++ b/src/wiki/plugins/editsection/views.py
@@ -29,7 +29,7 @@
 
 class FindHeader:
     """Locate the start, header text, and end of the header text of the next
-    possible section starting from pos. Finds too many occurances for SeText
+    possible section starting from pos. Finds too many occurrences for SeText
     headers which are filtered out later in the markdown extension.
     Returns: start pos header sure_header level"""
 


Test patch:
Repository: django-wiki/django-wiki

Issue:
Remove Django 2.1 support
CC: @atombrella 


Discussion:

Resolving patch:
diff --git a/src/wiki/__init__.py b/src/wiki/__init__.py
--- a/src/wiki/__init__.py
+++ b/src/wiki/__init__.py
@@ -17,5 +17,5 @@
 
 default_app_config = "wiki.apps.WikiConfig"
 
-VERSION = (0, 6, 0, "final", 0)
+VERSION = (0, 7, 0, "alpha", 0)
 __version__ = get_version(VERSION)
diff --git a/src/wiki/decorators.py b/src/wiki/decorators.py
--- a/src/wiki/decorators.py
+++ b/src/wiki/decorators.py
@@ -1,4 +1,5 @@
 from functools import wraps
+from urllib.parse import quote as urlquote
 
 from django.http import HttpResponseForbidden
 from django.http import HttpResponseNotFound
@@ -7,7 +8,6 @@
 from django.shortcuts import redirect
 from django.template.loader import render_to_string
 from django.urls import reverse
-from django.utils.http import urlquote
 from wiki.conf import settings
 from wiki.core.exceptions import NoRootURL
 
diff --git a/src/wiki/templatetags/wiki_tags.py b/src/wiki/templatetags/wiki_tags.py
--- a/src/wiki/templatetags/wiki_tags.py
+++ b/src/wiki/templatetags/wiki_tags.py
@@ -1,4 +1,5 @@
 import re
+from urllib.parse import quote as urlquote
 
 from django import template
 from django.apps import apps
@@ -7,7 +8,6 @@
 from django.db.models import Model
 from django.forms import BaseForm
 from django.template.defaultfilters import striptags
-from django.utils.http import urlquote
 from django.utils.safestring import mark_safe
 from wiki import models
 from wiki.conf import settings


Test patch:
Repository: django-wiki/django-wiki

Issue:
Memcached portability error — use cleaner cache keys for users?
I noticed that django-wiki is susceptible to this Django error:
https://code.djangoproject.com/ticket/31654

Which was fixed here:
https://github.com/django/django/commit/b2b2723512dd0024567fba0c680424ebb7fa1149

But I wanted to bring up the actual cause of the error, which might be worth fixing, because the Django fix above only masks the problem (which is that it attempts to warn the developer when you're using cache keys that would cause errors if you ever wanted to use memcached for your cache backend).

Specifically, django-wiki uses cache keys like:

':1:wiki:article:1:en-us:Brian Tiemann'

Which has a space in it, which is apparently incompatible with memcached (hence the warning message in Django).

For distinguishing cache keys based on user, how about using something sanitized or slugified, or even just go by the username or User.id field?



Discussion:

Resolving patch:
diff --git a/src/wiki/models/article.py b/src/wiki/models/article.py
--- a/src/wiki/models/article.py
+++ b/src/wiki/models/article.py
@@ -10,6 +10,7 @@
 from django.urls import reverse
 from django.utils import translation
 from django.utils.safestring import mark_safe
+from django.utils.text import slugify
 from django.utils.translation import gettext_lazy as _
 from mptt.models import MPTTModel
 from wiki import managers
@@ -219,15 +220,19 @@ def get_cache_key(self):
         """Returns per-article cache key."""
         lang = translation.get_language()
 
-        return "wiki:article:{id}:{lang}".format(
+        key_raw = "wiki:article:{id}:{lang}".format(
             id=self.current_revision.id if self.current_revision else self.id, lang=lang
         )
+        # https://github.com/django-wiki/django-wiki/issues/1065
+        return slugify(key_raw, allow_unicode=True)
 
     def get_cache_content_key(self, user=None):
         """Returns per-article-user cache key."""
-        return "{key}:{user}".format(
+        key_raw = "{key}:{user}".format(
             key=self.get_cache_key(), user=user.get_username() if user else ""
         )
+        # https://github.com/django-wiki/django-wiki/issues/1065
+        return slugify(key_raw, allow_unicode=True)
 
     def get_cached_content(self, user=None):
         """Returns cached version of rendered article.


Test patch:
Repository: django-wiki/django-wiki

Issue:
Release to support django 3.1
Hi,

The current release on pypi is limiting the ability to upgrade to django 3.1. And, as far as I can tell, there's no incompatibilities with the version 0.6 and django 3.1.

Would it be possible to release a 0.6.1 release or something like that loosening that requirement?


Discussion:

Resolving patch:
diff --git a/src/wiki/__init__.py b/src/wiki/__init__.py
--- a/src/wiki/__init__.py
+++ b/src/wiki/__init__.py
@@ -17,5 +17,5 @@
 
 default_app_config = "wiki.apps.WikiConfig"
 
-VERSION = (0, 7, 0, "alpha", 0)
+VERSION = (0, 7, 0, "final", 0)
 __version__ = get_version(VERSION)


Test patch: