~netlandish/django-wiki

d992844c7456c86f0f4da4165ba0bfe08d2fb475 — Raffaele Salmaso 6 years ago 0244ad9
Run isort
46 files changed, 48 insertions(+), 90 deletions(-)

M src/wiki/conf/settings.py
M src/wiki/core/markdown/__init__.py
M src/wiki/core/permissions.py
M src/wiki/decorators.py
M src/wiki/editors/__init__.py
M src/wiki/editors/markitup.py
M src/wiki/forms.py
M src/wiki/managers.py
M src/wiki/migrations/0001_initial.py
M src/wiki/models/__init__.py
M src/wiki/models/article.py
M src/wiki/models/pluginbase.py
M src/wiki/models/urlpath.py
M src/wiki/plugins/attachments/forms.py
M src/wiki/plugins/attachments/markdown_extensions.py
M src/wiki/plugins/attachments/migrations/0001_initial.py
M src/wiki/plugins/attachments/models.py
M src/wiki/plugins/haystack/__init__.py
M src/wiki/plugins/images/forms.py
M src/wiki/plugins/images/models.py
M src/wiki/plugins/images/views.py
M src/wiki/plugins/links/mdx/djangowikilinks.py
M src/wiki/plugins/notifications/forms.py
M src/wiki/plugins/notifications/management/commands/wiki_notifications_create_defaults.py
M src/wiki/templatetags/wiki_tags.py
M src/wiki/views/accounts.py
M src/wiki/views/article.py
M testproject/testproject/settings/base.py
M testproject/testproject/settings/customauthuser.py
M testproject/testproject/settings/haystack.py
M testproject/testproject/settings/sendfile.py
M tests/base.py
M tests/core/test_accounts.py
M tests/core/test_basic.py
M tests/core/test_checks.py
M tests/core/test_forms.py
M tests/core/test_models.py
M tests/core/test_template_filters.py
M tests/core/test_template_tags.py
M tests/core/test_urls.py
M tests/core/test_views.py
M tests/plugins/attachments/test_views.py
M tests/plugins/globalhistory/test_globalhistory.py
M tests/plugins/images/test_views.py
M tests/plugins/links/test_links.py
M tests/settings.py
M src/wiki/conf/settings.py => src/wiki/conf/settings.py +0 -1
@@ 1,5 1,4 @@
import bleach

from django.apps import apps
from django.conf import settings as django_settings
from django.contrib.messages import constants as messages

M src/wiki/core/markdown/__init__.py => src/wiki/core/markdown/__init__.py +1 -2
@@ 1,10 1,9 @@
import bleach
import markdown

from wiki.conf import settings
from wiki.core.markdown.mdx.codehilite import WikiCodeHiliteExtension
from wiki.core.markdown.mdx.previewlinks import PreviewLinksExtension
from wiki.core.markdown.mdx.responsivetable import ResponsiveTableExtension
from wiki.core.markdown.mdx.codehilite import WikiCodeHiliteExtension
from wiki.core.plugins import registry as plugin_registry



M src/wiki/core/permissions.py => src/wiki/core/permissions.py +0 -1
@@ 1,6 1,5 @@
from wiki.conf import settings


###############################
# ARTICLE PERMISSION HANDLING #
###############################

M src/wiki/decorators.py => src/wiki/decorators.py +2 -3
@@ 1,10 1,9 @@
from functools import wraps

from django.urls import reverse
from django.http import (HttpResponseForbidden, HttpResponseNotFound,
                         HttpResponseRedirect)
from django.http import HttpResponseForbidden, HttpResponseNotFound, HttpResponseRedirect
from django.shortcuts import get_object_or_404, 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

M src/wiki/editors/__init__.py => src/wiki/editors/__init__.py +1 -1
@@ 1,5 1,5 @@
from wiki.conf import settings
from django.urls import get_callable
from wiki.conf import settings

_EditorClass = None
_editor = None

M src/wiki/editors/markitup.py => src/wiki/editors/markitup.py +0 -1
@@ 3,7 3,6 @@ from django.forms.utils import flatatt
from django.utils.encoding import force_text
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe

from wiki.compat import BuildAttrsCompat
from wiki.editors.base import BaseEditor


M src/wiki/forms.py => src/wiki/forms.py +3 -6
@@ 8,22 8,19 @@ from django.apps import apps
from django.contrib.auth import get_user_model
from django.contrib.auth.forms import UserCreationForm
from django.core import validators
from django.urls import Resolver404, resolve
from django.core.validators import RegexValidator
from django.forms.utils import flatatt
from django.forms.widgets import HiddenInput
from django.shortcuts import get_object_or_404
from django.urls import Resolver404, resolve
from django.utils import timezone
from django.utils.encoding import force_text
from django.utils.html import conditional_escape, escape
from django.utils.safestring import mark_safe
from django.utils.translation import pgettext_lazy
from django.utils.translation import gettext
from django.utils.translation import gettext_lazy as _

from django.utils.translation import gettext, gettext_lazy as _, pgettext_lazy
from wiki import models
from wiki.conf import settings
from wiki.compat import BuildAttrsCompat
from wiki.conf import settings
from wiki.core import permissions
from wiki.core.diff import simple_merge
from wiki.core.plugins.base import PluginSettingsFormMixin

M src/wiki/managers.py => src/wiki/managers.py +1 -1
@@ 1,5 1,5 @@
from django.db import models
from django.db.models import Q, Count
from django.db.models import Count, Q
from django.db.models.query import EmptyQuerySet, QuerySet
from mptt.managers import TreeManager


M src/wiki/migrations/0001_initial.py => src/wiki/migrations/0001_initial.py +0 -1
@@ 3,7 3,6 @@ import mptt.fields
from django.conf import settings
from django.db import migrations, models
from django.db.models.fields import GenericIPAddressField as IPAddressField

from wiki.conf.settings import GROUP_MODEL



M src/wiki/models/__init__.py => src/wiki/models/__init__.py +2 -4
@@ 1,12 1,10 @@
from django import shortcuts, urls
from django.urls import base
from django import urls
from django import shortcuts
from django.utils.functional import lazy

from .article import *  # noqa
from .pluginbase import *  # noqa
from .urlpath import *  # noqa
from django.utils.functional import lazy


original_django_reverse = urls.reverse


M src/wiki/models/article.py => src/wiki/models/article.py +1 -2
@@ 2,10 2,10 @@ from django.conf import settings as django_settings
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.core.cache import cache
from django.urls import reverse
from django.db import models
from django.db.models.fields import GenericIPAddressField as IPAddressField
from django.db.models.signals import post_save, pre_delete, pre_save
from django.urls import reverse
from django.utils import translation
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _


@@ 16,7 16,6 @@ from wiki.core import permissions
from wiki.core.markdown import article_markdown
from wiki.decorators import disable_signal_for_loaddata


__all__ = [
    'Article', 'ArticleForObject', 'ArticleRevision',
    'BaseRevisionMixin',

M src/wiki/models/pluginbase.py => src/wiki/models/pluginbase.py +0 -1
@@ 25,7 25,6 @@ from wiki.decorators import disable_signal_for_loaddata

from .article import ArticleRevision, BaseRevisionMixin


__all__ = [
    'ArticlePlugin',
    'SimplePlugin', 'SimplePluginCreateError',

M src/wiki/models/urlpath.py => src/wiki/models/urlpath.py +2 -4
@@ 5,12 5,11 @@ from django.contrib.contenttypes.fields import GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.core.exceptions import ValidationError
from django.urls import reverse
from django.db import models, transaction
from django.db.models.signals import post_save, pre_delete
from django.urls import reverse
# Django 1.6 transaction API, required for 1.8+
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext
from django.utils.translation import gettext, gettext_lazy as _
from mptt.fields import TreeForeignKey
from mptt.models import MPTTModel
from wiki import managers


@@ 19,7 18,6 @@ from wiki.core.exceptions import MultipleRootURLs, NoRootURL
from wiki.decorators import disable_signal_for_loaddata
from wiki.models.article import Article, ArticleForObject, ArticleRevision


__all__ = [
    'URLPath',
]

M src/wiki/plugins/attachments/forms.py => src/wiki/plugins/attachments/forms.py +1 -2
@@ 3,8 3,7 @@ import zipfile

from django import forms
from django.core.files.uploadedfile import File
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext
from django.utils.translation import gettext, gettext_lazy as _
from wiki.core.permissions import can_moderate
from wiki.plugins.attachments import models
from wiki.plugins.attachments.models import IllegalFileExtension

M src/wiki/plugins/attachments/markdown_extensions.py => src/wiki/plugins/attachments/markdown_extensions.py +1 -1
@@ 2,8 2,8 @@ import re

import markdown
from django.contrib.auth.models import AnonymousUser
from django.urls import reverse
from django.template.loader import render_to_string
from django.urls import reverse
from wiki.core.permissions import can_read
from wiki.plugins.attachments import models


M src/wiki/plugins/attachments/migrations/0001_initial.py => src/wiki/plugins/attachments/migrations/0001_initial.py +1 -2
@@ 1,10 1,9 @@
import django.db.models.deletion
import wiki.plugins.attachments.models
from django.conf import settings
from django.db import migrations, models
from django.db.models.fields import GenericIPAddressField as IPAddressField

import wiki.plugins.attachments.models


class Migration(migrations.Migration):


M src/wiki/plugins/attachments/models.py => src/wiki/plugins/attachments/models.py +1 -2
@@ 3,8 3,7 @@ import os
from django.conf import settings as django_settings
from django.db import models
from django.db.models import signals
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext
from django.utils.translation import gettext, gettext_lazy as _
from wiki import managers
from wiki.decorators import disable_signal_for_loaddata
from wiki.models.article import BaseRevisionMixin

M src/wiki/plugins/haystack/__init__.py => src/wiki/plugins/haystack/__init__.py +5 -6
@@ 1,11 1,10 @@
from wiki.conf import settings
from wiki.core import permissions
from wiki import models

from haystack import views as haystack_views
from django.db.models import Q
from django.utils.decorators import classonlymethod
from django.shortcuts import redirect
from django.utils.decorators import classonlymethod
from haystack import views as haystack_views
from wiki import models
from wiki.conf import settings
from wiki.core import permissions


class SearchViewHaystack(haystack_views.SearchView):

M src/wiki/plugins/images/forms.py => src/wiki/plugins/images/forms.py +1 -2
@@ 1,6 1,5 @@
from django import forms
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext
from django.utils.translation import gettext, gettext_lazy as _
from wiki.core.plugins.base import PluginSidebarFormMixin
from wiki.plugins.images import models


M src/wiki/plugins/images/models.py => src/wiki/plugins/images/models.py +1 -2
@@ 5,8 5,7 @@ from django.conf import settings as django_settings
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.db.models import signals
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext
from django.utils.translation import gettext, gettext_lazy as _
from wiki.models.pluginbase import RevisionPlugin, RevisionPluginRevision

from . import settings

M src/wiki/plugins/images/views.py => src/wiki/plugins/images/views.py +1 -1
@@ 1,8 1,8 @@
import logging

from django.contrib import messages
from django.urls import reverse
from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _
from django.views.generic.base import RedirectView

M src/wiki/plugins/links/mdx/djangowikilinks.py => src/wiki/plugins/links/mdx/djangowikilinks.py +0 -1
@@ 23,7 23,6 @@ from os import path as os_path

import markdown
from markdown.util import etree

from wiki import models



M src/wiki/plugins/notifications/forms.py => src/wiki/plugins/notifications/forms.py +1 -2
@@ 2,8 2,7 @@ from django import forms
from django.contrib.contenttypes.models import ContentType
from django.forms.models import BaseModelFormSet, modelformset_factory
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext
from django.utils.translation import gettext, gettext_lazy as _
from django_nyt.models import NotificationType, Settings, Subscription
from wiki.core.plugins.base import PluginSettingsFormMixin
from wiki.plugins.notifications import models

M src/wiki/plugins/notifications/management/commands/wiki_notifications_create_defaults.py => src/wiki/plugins/notifications/management/commands/wiki_notifications_create_defaults.py +0 -1
@@ 4,7 4,6 @@ from django.core.management.base import BaseCommand
from django.utils import translation
from django_nyt.models import Settings
from django_nyt.utils import subscribe

from wiki.models import Article
from wiki.plugins.notifications import models
from wiki.plugins.notifications.settings import ARTICLE_EDIT

M src/wiki/templatetags/wiki_tags.py => src/wiki/templatetags/wiki_tags.py +1 -1
@@ 1,7 1,7 @@
import re

from django.apps import apps
from django import template
from django.apps import apps
from django.conf import settings as django_settings
from django.contrib.contenttypes.models import ContentType
from django.db.models import Model

M src/wiki/views/accounts.py => src/wiki/views/accounts.py +2 -3
@@ 11,11 11,10 @@ SETTINGS.LOGOUT_URL

from django.conf import settings as django_settings
from django.contrib import messages
from django.contrib.auth import get_user_model, login as auth_login
from django.contrib.auth import logout as auth_logout
from django.contrib.auth import get_user_model, login as auth_login, logout as auth_logout
from django.contrib.auth.forms import AuthenticationForm
from django.urls import reverse
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
from django.utils.translation import gettext as _
from django.views.generic.base import View
from django.views.generic.edit import CreateView, FormView, UpdateView

M src/wiki/views/article.py => src/wiki/views/article.py +2 -3
@@ 4,14 4,13 @@ from urllib.parse import urljoin

from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.urls import reverse
from django.db import transaction
from django.db.models import Q
from django.http import Http404
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _
from django.utils.translation import ngettext
from django.utils.translation import gettext as _, ngettext
from django.views.generic import DetailView
from django.views.generic.base import RedirectView, TemplateView, View
from django.views.generic.edit import FormView

M testproject/testproject/settings/base.py => testproject/testproject/settings/base.py +0 -1
@@ 12,7 12,6 @@ import os

from django.urls import reverse_lazy


PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)


M testproject/testproject/settings/customauthuser.py => testproject/testproject/settings/customauthuser.py +0 -1
@@ 2,7 2,6 @@ import os  # noqa @UnusedImport

from .base import *  # noqa @UnusedWildImport


DATABASES = {
    'default': {
        # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.

M testproject/testproject/settings/haystack.py => testproject/testproject/settings/haystack.py +0 -1
@@ 1,6 1,5 @@
from .base import *  # noqa @UnusedWildImport


# Django Haystack

HAYSTACK_WHOOSH_PATH = os.path.join(PROJECT_DIR, 'index_woosh')

M testproject/testproject/settings/sendfile.py => testproject/testproject/settings/sendfile.py +0 -1
@@ 1,6 1,5 @@
from .base import *  # noqa @UnusedWildImport


INSTALLED_APPS += ['sendfile']

WIKI_ATTACHMENTS_USE_SENDFILE = True

M tests/base.py => tests/base.py +1 -2
@@ 3,10 3,9 @@ import unittest

import django_functest
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.urls import reverse
from django.template import Context, Template
from django.test import TestCase, override_settings

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

SUPERUSER1_USERNAME = 'admin'

M tests/core/test_accounts.py => tests/core/test_accounts.py +3 -3
@@ 6,9 6,9 @@ from django.shortcuts import resolve_url
from wiki.conf import settings as wiki_settings
from wiki.models import reverse

from ..base import (SUPERUSER1_PASSWORD, SUPERUSER1_USERNAME,
                    ArticleWebTestUtils, DjangoClientTestBase,
                    RequireRootArticleMixin, TestBase, wiki_override_settings)
from ..base import (
    SUPERUSER1_PASSWORD, SUPERUSER1_USERNAME, ArticleWebTestUtils, DjangoClientTestBase, RequireRootArticleMixin, TestBase, wiki_override_settings,
)
from ..testdata.models import CustomUser



M tests/core/test_basic.py => tests/core/test_basic.py +1 -1
@@ 1,8 1,8 @@
from django.test import TestCase

from wiki.conf import settings as wiki_settings
from wiki.forms import Group
from wiki.models import URLPath

from ..base import wiki_override_settings
from ..testdata.models import CustomGroup


M tests/core/test_checks.py => tests/core/test_checks.py +2 -2
@@ 1,9 1,9 @@
import copy

from django.conf import settings
from django.test import TestCase
from django.core.checks import Error, registry
from wiki.checks import REQUIRED_CONTEXT_PROCESSORS, REQUIRED_INSTALLED_APPS, OBSOLETE_INSTALLED_APPS, Tags
from django.test import TestCase
from wiki.checks import OBSOLETE_INSTALLED_APPS, REQUIRED_CONTEXT_PROCESSORS, REQUIRED_INSTALLED_APPS, Tags


class CheckTests(TestCase):

M tests/core/test_forms.py => tests/core/test_forms.py +0 -1
@@ 1,6 1,5 @@
from django.test import TestCase
from django.utils.translation import gettext

from tests.base import DjangoClientTestBase, RequireRootArticleMixin
from wiki.forms import DeleteForm, UserCreationForm


M tests/core/test_models.py => tests/core/test_models.py +0 -2
@@ 2,14 2,12 @@ from django.apps import apps
from django.contrib.auth import get_user_model
from django.contrib.sites.models import Site
from django.test.testcases import TestCase

from wiki.compat import include, url
from wiki.conf import settings
from wiki.managers import ArticleManager
from wiki.models import Article, ArticleRevision, URLPath
from wiki.urls import WikiURLPatterns


User = get_user_model()
Group = apps.get_model(settings.GROUP_MODEL)


M tests/core/test_template_filters.py => tests/core/test_template_filters.py +2 -3
@@ 1,8 1,7 @@
from django.contrib.auth import get_user_model
from wiki.models import Article, ArticleRevision
from wiki.templatetags.wiki_tags import (can_delete, can_moderate, can_read,
                                         can_write, get_content_snippet,
                                         is_locked)
from wiki.templatetags.wiki_tags import can_delete, can_moderate, can_read, can_write, get_content_snippet, is_locked

from ..base import TemplateTestCase, wiki_override_settings

User = get_user_model()

M tests/core/test_template_tags.py => tests/core/test_template_tags.py +2 -3
@@ 4,12 4,11 @@ Almost all test cases covers both tag calling and template using.
from django.conf import settings as django_settings
from django.contrib.contenttypes.models import ContentType
from django.http import HttpRequest

from wiki.conf import settings
from wiki.forms import CreateRootForm
from wiki.models import Article, ArticleForObject, ArticleRevision
from wiki.templatetags.wiki_tags import (article_for_object, login_url,
                                         wiki_form, wiki_render)
from wiki.templatetags.wiki_tags import article_for_object, login_url, wiki_form, wiki_render

from ..base import TemplateTestCase

if not django_settings.configured:

M tests/core/test_urls.py => tests/core/test_urls.py +1 -3
@@ 4,12 4,10 @@ from django.test.testcases import TestCase
from django_nyt.urls import get_pattern as get_notify_pattern
from wiki.compat import include, url
from wiki.models import Article, URLPath
from wiki.urls import get_pattern as get_wiki_pattern
from wiki.urls import WikiURLPatterns
from wiki.urls import WikiURLPatterns, get_pattern as get_wiki_pattern

from ..base import wiki_override_settings


User = get_user_model()



M tests/core/test_views.py => tests/core/test_views.py +1 -2
@@ 8,8 8,7 @@ from wiki import models
from wiki.forms import validate_slug_numbers
from wiki.models import ArticleRevision, URLPath, reverse

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


class RootArticleViewTestsBase(FuncBaseMixin):

M tests/plugins/attachments/test_views.py => tests/plugins/attachments/test_views.py +1 -1
@@ 4,7 4,7 @@ from django.core.files.uploadedfile import InMemoryUploadedFile
from django.urls import reverse
from wiki.models import URLPath

from ...base import RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase
from ...base import ArticleWebTestUtils, DjangoClientTestBase, RequireRootArticleMixin


class AttachmentTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase):

M tests/plugins/globalhistory/test_globalhistory.py => tests/plugins/globalhistory/test_globalhistory.py +1 -2
@@ 1,8 1,7 @@
from django.urls import reverse
from wiki.models import URLPath

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


class GlobalhistoryTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase):

M tests/plugins/images/test_views.py => tests/plugins/images/test_views.py +1 -2
@@ 8,8 8,7 @@ from wiki.models import URLPath
from wiki.plugins.images import models
from wiki.plugins.images.wiki_plugin import ImagePlugin

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


class ImageTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase):

M tests/plugins/links/test_links.py => tests/plugins/links/test_links.py +1 -1
@@ 1,6 1,6 @@
import markdown
from django.urls import reverse_lazy
from django.test import TestCase
from django.urls import reverse_lazy
from wiki.models import URLPath
from wiki.plugins.links.mdx.djangowikilinks import WikiPathExtension


M tests/settings.py => tests/settings.py +0 -1
@@ 2,7 2,6 @@ import os

from django.urls import reverse_lazy


TESTS_DATA_ROOT = os.path.dirname(__file__)

MEDIA_ROOT = os.path.join(TESTS_DATA_ROOT, 'media')