~netlandish/django-wiki

d5c8c5dc4a7350a6d59a1166c26eb1c4375ff0b1 — Benjamin Bach 8 years ago ff61923
Remove old deprecated stuff
M wiki/conf/settings.py => wiki/conf/settings.py +1 -7
@@ 1,6 1,5 @@
from __future__ import absolute_import, unicode_literals

import django
from django.conf import settings as django_settings
from django.core.files.storage import default_storage
from django.core.urlresolvers import reverse_lazy


@@ 10,7 9,6 @@ from django.utils.translation import ugettext_lazy as _
URL_CASE_SENSITIVE = getattr(django_settings, 'WIKI_URL_CASE_SENSITIVE', False)

# Non-configurable (at the moment)
APP_LABEL = 'wiki'
WIKI_LANGUAGE = 'markdown'

# The editor class to use -- maybe a 3rd party or your own...? You can always


@@ 175,11 173,7 @@ SEARCH_VIEW = getattr(
CACHE_TIMEOUT = getattr(django_settings, 'WIKI_CACHE_TIMEOUT', 600)

# Choose the Group model to use. Defaults to django's auth.Group
# This requires `django.apps` which was introduced in Django 1.7.
if django.VERSION < (1, 7):
    GROUP_MODEL = 'auth.Group'
else:
    GROUP_MODEL = getattr(django_settings, 'WIKI_GROUP_MODEL', 'auth.Group')
GROUP_MODEL = getattr(django_settings, 'WIKI_GROUP_MODEL', 'auth.Group')

###################
# SPAM PROTECTION #

M wiki/core/compat.py => wiki/core/compat.py +3 -31
@@ 2,27 2,16 @@
compatibility with several Django versions simultaneously."""
from __future__ import absolute_import, unicode_literals

from django import VERSION as DJANGO_VERSION
from django.conf import settings as django_settings
from django.db import transaction

# Django 1.5+
if DJANGO_VERSION >= (1, 5):
    USER_MODEL = getattr(django_settings, 'AUTH_USER_MODEL', 'auth.User')
else:
    USER_MODEL = 'auth.User'
USER_MODEL = getattr(django_settings, 'AUTH_USER_MODEL', 'auth.User')


def get_user_model():

    if DJANGO_VERSION >= (1, 5):
        from django.contrib.auth import get_user_model as gum
        return gum()
    else:
        from django.contrib.auth.models import User
        if 'USERNAME_FIELD' not in User.__dict__:
            User.USERNAME_FIELD = 'username'
        return User
    from django.contrib.auth import get_user_model as gum
    return gum()


# Django 1.6 transaction API, required for 1.8+


@@ 38,20 27,3 @@ try:
except AttributeError:
    atomic = nop_decorator
    transaction_commit_on_success = transaction.commit_on_success


if DJANGO_VERSION < (1, 8):
    from django.template.loader import render_to_string as django_render_to_string
    from django.template import Context, RequestContext

    # Similar to 1.8 signature, but with things we can support
    # under 1.7 and less.
    def render_to_string(template_name, context=None, request=None):
        if request is not None:
            context_instance = RequestContext(request, context)
        else:
            context_instance = Context(context)
        return django_render_to_string(template_name,
                                       context_instance=context_instance)
else:
    from django.template.loader import render_to_string  # noqa @UnusedImport

M wiki/decorators.py => wiki/decorators.py +1 -1
@@ 8,10 8,10 @@ from django.core.urlresolvers import reverse
from django.http import (HttpResponse, HttpResponseForbidden,
                         HttpResponseNotFound, HttpResponseRedirect)
from django.shortcuts import get_object_or_404, redirect
from django.template.loader import render_to_string
from django.utils.http import urlquote
from six.moves import filter
from wiki.conf import settings
from wiki.core.compat import render_to_string
from wiki.core.exceptions import NoRootURL



M wiki/forms.py => wiki/forms.py +2 -8
@@ 7,6 7,7 @@ from datetime import timedelta
from itertools import chain

from django import forms
from django.apps import apps
from django.contrib.auth.forms import UserCreationForm
from django.core.urlresolvers import Resolver404, resolve
from django.forms.widgets import HiddenInput


@@ 32,14 33,7 @@ except ImportError:


User = get_user_model()

# Backwards compatibility with Django < 1.7
try:
    from django.apps import apps
except ImportError:
    from django.contrib.auth.models import Group
else:
    Group = apps.get_model(settings.GROUP_MODEL)
Group = apps.get_model(settings.GROUP_MODEL)

# Due to deprecation of django.forms.util in Django 1.9
try:

M wiki/models/article.py => wiki/models/article.py +0 -3
@@ 192,7 192,6 @@ class Article(models.Model):
        return str(obj_name)

    class Meta:
        app_label = settings.APP_LABEL
        permissions = (
            ("moderate", _("Can edit all articles and lock/unlock/restore")),
            ("assign", _("Can change ownership of any article")),


@@ 253,7 252,6 @@ class ArticleForObject(models.Model):
        return "{}".format(self.article)

    class Meta:
        app_label = settings.APP_LABEL
        verbose_name = _('Article for object')
        verbose_name_plural = _('Articles for object')
        # Do not allow several objects


@@ 372,7 370,6 @@ class ArticleRevision(BaseRevisionMixin, models.Model):
        self.locked = predecessor.locked

    class Meta:
        app_label = settings.APP_LABEL
        get_latest_by = 'revision_number'
        ordering = ('created',)
        unique_together = ('article', 'revision_number')

M wiki/models/pluginbase.py => wiki/models/pluginbase.py +0 -22
@@ 24,7 24,6 @@ from __future__ import absolute_import, unicode_literals
from django.db import models
from django.db.models import signals
from django.utils.translation import ugettext_lazy as _
from wiki.conf import settings
from wiki.decorators import disable_signal_for_loaddata

from .article import ArticleRevision, BaseRevisionMixin


@@ 62,11 61,6 @@ class ArticlePlugin(models.Model):
        """Remove related contents completely, ie. media files."""
        pass

    class Meta:
        # Override this setting with app_label = '' in your extended model
        # if it lives outside the wiki app.
        app_label = settings.APP_LABEL


class ReusablePlugin(ArticlePlugin):



@@ 108,11 102,6 @@ class ReusablePlugin(ArticlePlugin):
    def can_moderate(self, user):
        return self.article.can_moderate(user) if self.article else False

    class Meta:
        # Override this setting with app_label = '' in your extended model
        # if it lives outside the wiki app.
        app_label = settings.APP_LABEL


class SimplePluginCreateError(Exception):
    pass


@@ 156,11 145,6 @@ class SimplePlugin(ArticlePlugin):
    def get_logmessage(self):
        return _("A plugin was changed")

    class Meta:
        # Override this setting with app_label = '' in your extended model
        # if it lives outside the wiki app.
        app_label = settings.APP_LABEL


class RevisionPlugin(ArticlePlugin):



@@ 208,11 192,6 @@ class RevisionPlugin(ArticlePlugin):
        if save:
            self.save()

    class Meta:
        # Override this setting with app_label = '' in your extended model
        # if it lives outside the wiki app.
        app_label = settings.APP_LABEL


class RevisionPluginRevision(BaseRevisionMixin, models.Model):



@@ 228,7 207,6 @@ class RevisionPluginRevision(BaseRevisionMixin, models.Model):
    class Meta:
        # Override this setting with app_label = '' in your extended model
        # if it lives outside the wiki app.
        app_label = settings.APP_LABEL
        get_latest_by = 'revision_number'
        ordering = ('-created',)


M wiki/models/urlpath.py => wiki/models/urlpath.py +0 -1
@@ 201,7 201,6 @@ class URLPath(MPTTModel):
        verbose_name = _('URL path')
        verbose_name_plural = _('URL paths')
        unique_together = ('site', 'parent', 'slug')
        app_label = settings.APP_LABEL

    def clean(self, *args, **kwargs):
        if self.slug and not self.parent:

M wiki/plugins/attachments/markdown_extensions.py => wiki/plugins/attachments/markdown_extensions.py +1 -1
@@ 5,7 5,7 @@ import re
import markdown
from django.contrib.auth.models import AnonymousUser
from django.core.urlresolvers import reverse
from wiki.core.compat import render_to_string
from django.template.loader import render_to_string
from wiki.core.permissions import can_read
from wiki.plugins.attachments import models


M wiki/plugins/attachments/models.py => wiki/plugins/attachments/models.py +0 -4
@@ 54,8 54,6 @@ class Attachment(ReusablePlugin):
        verbose_name_plural = _('attachments')
        # Matches label of upcoming 0.1 release
        db_table = 'wiki_attachments_attachment'
        if settings.APP_LABEL:
            app_label = settings.APP_LABEL

    def __str__(self):
        from wiki.models import Article


@@ 140,8 138,6 @@ class AttachmentRevision(BaseRevisionMixin, models.Model):
        get_latest_by = 'revision_number'
        # Matches label of upcoming 0.1 release
        db_table = 'wiki_attachments_attachmentrevision'
        if settings.APP_LABEL:
            app_label = settings.APP_LABEL

    def get_filename(self):
        """Used to retrieve the filename of a revision.

M wiki/plugins/attachments/settings.py => wiki/plugins/attachments/settings.py +3 -3
@@ 1,12 1,12 @@
from __future__ import absolute_import, unicode_literals

from django import VERSION
from django.conf import settings as django_settings
from django.core.exceptions import ImproperlyConfigured
from wiki.conf import settings as wiki_settings

# This is not used in django 1.7+
APP_LABEL = 'attachments' if VERSION < (1, 7) else None
# Deprecated
APP_LABEL = None

SLUG = "attachments"

# Please see this note about support for UTF-8 files on django/apache:

M wiki/plugins/images/markdown_extensions.py => wiki/plugins/images/markdown_extensions.py +1 -1
@@ 4,7 4,7 @@ from __future__ import absolute_import, unicode_literals
import re

import markdown
from wiki.core.compat import render_to_string
from django.template.loader import render_to_string
from wiki.plugins.images import models

IMAGE_RE = re.compile(

M wiki/plugins/images/models.py => wiki/plugins/images/models.py +0 -4
@@ 49,8 49,6 @@ class Image(RevisionPlugin):
        verbose_name = _('image')
        verbose_name_plural = _('images')
        db_table = 'wiki_images_image'  # Matches label of upcoming 0.1 release
        if settings.APP_LABEL:
            app_label = settings.APP_LABEL

    def __str__(self):
        if self.current_revision:


@@ 114,8 112,6 @@ class ImageRevision(RevisionPluginRevision):
        verbose_name_plural = _('image revisions')
        # Matches label of upcoming 0.1 release
        db_table = 'wiki_images_imagerevision'
        if settings.APP_LABEL:
            app_label = settings.APP_LABEL
        ordering = ('-created',)

    def __str__(self):

M wiki/plugins/images/settings.py => wiki/plugins/images/settings.py +2 -3
@@ 1,13 1,12 @@
from __future__ import absolute_import, unicode_literals

from django import VERSION
from django.conf import settings as django_settings
from wiki.conf import settings as wiki_settings

SLUG = 'images'

# This is deprecated in django 1.7+
APP_LABEL = 'images' if VERSION < (1, 7) else None
# Deprecated
APP_LABEL = None

# Where to store images
IMAGE_PATH = getattr(django_settings, 'WIKI_IMAGES_PATH', "wiki/images/%aid/")

M wiki/plugins/macros/mdx/macro.py => wiki/plugins/macros/mdx/macro.py +1 -1
@@ 4,9 4,9 @@ from __future__ import absolute_import, unicode_literals
import re

import markdown
from django.template.loader import render_to_string
from django.utils.translation import ugettext as _
from six import string_types
from wiki.core.compat import render_to_string
from wiki.plugins.macros import settings

# See:

M wiki/plugins/notifications/models.py => wiki/plugins/notifications/models.py +0 -2
@@ 32,8 32,6 @@ class ArticleSubscription(ArticlePlugin):
        unique_together = ('subscription', 'articleplugin_ptr')
        # Matches label of upcoming 0.1 release
        db_table = 'wiki_notifications_articlesubscription'
        if settings.APP_LABEL:
            app_label = settings.APP_LABEL


def default_url(article, urlpath=None):

M wiki/plugins/notifications/settings.py => wiki/plugins/notifications/settings.py +2 -3
@@ 1,9 1,8 @@
from __future__ import absolute_import, unicode_literals

from django import VERSION

# This is deprecated in django 1.7+
APP_LABEL = 'notifications' if VERSION < (1, 7) else None
# Deprecated
APP_LABEL = None

# Key for django_nyt - changing it will break any existing notifications.
ARTICLE_EDIT = "article_edit"

M wiki/tests/test_models.py => wiki/tests/test_models.py +5 -12
@@ 1,26 1,19 @@
from __future__ import absolute_import, unicode_literals

from django.apps import apps
from django.conf.urls import url
from django.contrib.auth import get_user_model
from django.contrib.sites.models import Site
from django.test.testcases import TestCase

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()




# Backwards compatibility with Django < 1.7
try:
    from django.apps import apps
except ImportError:
    from django.contrib.auth.models import Group
else:
    from wiki.conf import settings
    Group = apps.get_model(settings.GROUP_MODEL)
User = get_user_model()
Group = apps.get_model(settings.GROUP_MODEL)


class WikiCustomUrlPatterns(WikiURLPatterns):