~netlandish/django-wiki

5afbc397bc279d14fe5228f629abf9f38e52536f — Frank Loemker 4 years ago cd8b3b6
Incorporated review comments:
- Switched to Python 3's super() syntax.
- Trailing comma for a config set.
- Removed unneded ().
- Line breaks for some long lines.
- Removed "import __future__".
M src/wiki/plugins/editsection/markdown_extensions.py => src/wiki/plugins/editsection/markdown_extensions.py +2 -2
@@ 11,9 11,9 @@ class EditSectionExtension(Extension):
            'level': [settings.MAX_LEVEL, 'Allow to edit sections till this level'],
            'headers': None,     # List of FindHeader, all headers with there positions
            'location': None,    # To be extracted header
            'header_id': None    # Header text ID of the to be extracted header
            'header_id': None,   # Header text ID of the to be extracted header
        }
        super(EditSectionExtension, self).__init__(**kwargs)
        super().__init__(**kwargs)

    def extendMarkdown(self, md, md_globals):
        ext = EditSectionProcessor(md)

M src/wiki/plugins/editsection/views.py => src/wiki/plugins/editsection/views.py +2 -2
@@ 117,10 117,10 @@ class EditSection(EditView):
            kwargs['content'] = request.session.get('editSection_content')
            self.orig_section = kwargs.get('content')

        return super(EditSection, self).dispatch(request, article, *args, **kwargs)
        return super().dispatch(request, article, *args, **kwargs)

    def form_valid(self, form):
        super(EditSection, self).form_valid(form)
        super().form_valid(form)

        section = self.article.current_revision.content
        if not section.endswith("\n"):

M testproject/testproject/db/prepopulated.db => testproject/testproject/db/prepopulated.db +0 -0
M tests/plugins/editsection/test_editsection.py => tests/plugins/editsection/test_editsection.py +9 -7
@@ 1,10 1,8 @@
from __future__ import print_function, unicode_literals

from django.urls import reverse
from django_functest import FuncBaseMixin
from wiki.models import URLPath

from ...base import (DjangoClientTestBase, RequireRootArticleMixin, WebTestBase)
from ...base import DjangoClientTestBase, RequireRootArticleMixin, WebTestBase

TEST_CONTENT = (
    'Title 1\n'


@@ 39,12 37,14 @@ class EditSectionTests(RequireRootArticleMixin, DjangoClientTestBase):
        self.assertRegex(output, expected)

        # Test wrong header text. Editing should fail with a redirect.
        url = reverse('wiki:editsection', kwargs={'path': 'testedit/', 'location': '1-2-1', 'header': 'Test'})
        url = reverse('wiki:editsection',
                      kwargs={'path': 'testedit/', 'location': '1-2-1', 'header': 'Test'})
        response = self.client.get(url)
        self.assertRedirects(response, reverse('wiki:get', kwargs={'path': 'testedit/'}))

        # Test extracting sections for editing
        url = reverse('wiki:editsection', kwargs={'path': 'testedit/', 'location': '1-2-1', 'header': 'T4'})
        url = reverse('wiki:editsection',
                      kwargs={'path': 'testedit/', 'location': '1-2-1', 'header': 'T4'})
        response = self.client.get(url)
        expected = (
            '>### Title 4[\r\n]*'


@@ 52,7 52,8 @@ class EditSectionTests(RequireRootArticleMixin, DjangoClientTestBase):
        )
        self.assertRegex(response.rendered_content, expected)

        url = reverse('wiki:editsection', kwargs={'path': 'testedit/', 'location': '1-2-0', 'header': 'T3'})
        url = reverse('wiki:editsection',
                      kwargs={'path': 'testedit/', 'location': '1-2-0', 'header': 'T3'})
        response = self.client.get(url)
        expected = (
            '>Title 3[\r\n]*'


@@ 77,7 78,8 @@ class EditSectionEditTests(EditSectionEditBase, WebTestBase):
                                         title="TestEdit", content=TEST_CONTENT)
        old_number = urlpath.article.current_revision.revision_number

        self.get_literal_url(reverse('wiki:editsection', kwargs={'path': 'testedit/', 'location': '1-2-0', 'header': 'T3'}))
        self.get_literal_url(reverse('wiki:editsection',
                                     kwargs={'path': 'testedit/', 'location': '1-2-0', 'header': 'T3'}))
        self.fill({
            '#id_content': '# Header 1\nContent of the new section'
        })