diff --git a/django_notify/admin.py b/django_notify/admin.py
index 957946de8..19eaee01e 100644
--- a/django_notify/admin.py
+++ b/django_notify/admin.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
from django.contrib import admin
from django_notify import models
@@ -5,4 +7,4 @@
admin.site.register(models.NotificationType)
admin.site.register(models.Notification)
admin.site.register(models.Settings)
-admin.site.register(models.Subscription)
\ No newline at end of file
+admin.site.register(models.Subscription)
diff --git a/django_notify/decorators.py b/django_notify/decorators.py
index 7e94c90ee..a07b17db3 100644
--- a/django_notify/decorators.py
+++ b/django_notify/decorators.py
@@ -1,10 +1,14 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
import json
-from django.http import HttpResponse
+
from django.contrib.auth.decorators import login_required
+from django.http import HttpResponse
import django_notify
+
def disable_notify(func):
"""Disable notifications. Example:
@@ -41,4 +45,3 @@ def wrap(request, *args, **kwargs):
response.write(data)
return response
return wrap
-
diff --git a/django_notify/migrations/0001_initial.py b/django_notify/migrations/0001_initial.py
index b2fd056e4..4820c8889 100644
--- a/django_notify/migrations/0001_initial.py
+++ b/django_notify/migrations/0001_initial.py
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
-from django.db import models, migrations
import django.db.models.deletion
from django.conf import settings
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django_notify/models.py b/django_notify/models.py
index 01105085e..4a6cc5000 100644
--- a/django_notify/models.py
+++ b/django_notify/models.py
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
-from django.db import models
-from django.db.models import Q, Model
-from django.contrib.auth.models import User
-from django.utils.translation import ugettext_lazy as _
+from __future__ import absolute_import
+from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
+from django.db import models
+from django.db.models import Model, Q
+from django.utils.translation import ugettext_lazy as _
from django_notify import settings
diff --git a/django_notify/settings.py b/django_notify/settings.py
index a2a1c3859..70dcc232b 100644
--- a/django_notify/settings.py
+++ b/django_notify/settings.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
from django.conf import settings as django_settings
_ = lambda x: x
diff --git a/django_notify/tests.py b/django_notify/tests.py
index 501deb776..1ddecbc38 100644
--- a/django_notify/tests.py
+++ b/django_notify/tests.py
@@ -5,6 +5,8 @@
Replace this with more appropriate tests for your application.
"""
+from __future__ import absolute_import
+
from django.test import TestCase
diff --git a/django_notify/urls.py b/django_notify/urls.py
index 65663264f..1eebd3f3b 100644
--- a/django_notify/urls.py
+++ b/django_notify/urls.py
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
from django.conf.urls import url
+
from django_notify import views
urlpatterns = [
@@ -14,4 +17,4 @@ def get_pattern(app_name="notify", namespace="notify"):
"""Every url resolution takes place as "notify:view_name".
https://docs.djangoproject.com/en/dev/topics/http/urls/#topics-http-reversing-url-namespaces
"""
- return urlpatterns, app_name, namespace
\ No newline at end of file
+ return urlpatterns, app_name, namespace
diff --git a/django_notify/views.py b/django_notify/views.py
index 9b7489f29..e4866dcf5 100644
--- a/django_notify/views.py
+++ b/django_notify/views.py
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
-from django_notify.decorators import json_view, login_required_ajax
-from django_notify import models
+from __future__ import absolute_import
+
from django.contrib.auth.decorators import login_required
-from django.shortcuts import redirect, get_object_or_404
+from django.shortcuts import get_object_or_404, redirect
+
+from django_notify import models
+from django_notify.decorators import json_view, login_required_ajax
+
@login_required_ajax
@json_view
@@ -55,4 +59,4 @@ def mark_read(request, up_to_id, notification_type_id=None):
notifications.update(is_viewed=True)
- return {'success': True}
\ No newline at end of file
+ return {'success': True}
diff --git a/docs/conf.py b/docs/conf.py
index fb261143d..9456640de 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -11,7 +11,10 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
-import sys, os
+from __future__ import absolute_import
+
+import os
+import sys
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
diff --git a/openedx.yaml b/openedx.yaml
new file mode 100644
index 000000000..69b973180
--- /dev/null
+++ b/openedx.yaml
@@ -0,0 +1,11 @@
+# This file describes this Open edX repo, as described in OEP-2:
+# https://open-edx-proposals.readthedocs.io/en/latest/oep-0002-bp-repo-metadata.html#specification:
+
+nick: django-wiki
+supporting_teams:
+ - platform-core
+tags:
+ - core
+ - library
+oeps:
+ oep-7: True
diff --git a/setup.py b/setup.py
index 5e92f546d..b45a604b5 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,10 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
import os
-from setuptools import setup, find_packages
+
+from setuptools import find_packages, setup
+from six.moves import range
def read(fname):
@@ -17,12 +21,15 @@ def read(fname):
def build_media_pattern(base_folder, file_extension):
return ["%s/%s*.%s" % (base_folder, "*/"*x, file_extension) for x in range(10)]
-template_patterns = ( build_media_pattern("templates", "html") +
- build_media_pattern("static", "js") +
- build_media_pattern("static", "css") +
- build_media_pattern("static", "png") +
- build_media_pattern("static", "jpeg") +
- build_media_pattern("static", "gif"))
+
+template_patterns = (
+ build_media_pattern("templates", "html") +
+ build_media_pattern("static", "js") +
+ build_media_pattern("static", "css") +
+ build_media_pattern("static", "png") +
+ build_media_pattern("static", "jpeg") +
+ build_media_pattern("static", "gif")
+)
packages = find_packages()
@@ -33,7 +40,7 @@ def build_media_pattern(base_folder, file_extension):
setup(
name = "django-wiki",
- version="0.0.20",
+ version="0.0.22",
author="Benjamin Bach",
author_email="benjamin@overtag.dk",
description=("A wiki system written for the Django framework."),
@@ -55,7 +62,10 @@ def build_media_pattern(base_folder, file_extension):
'Framework :: Django',
'Intended Audience :: Developers',
'Operating System :: OS Independent',
- 'Programming Language :: Python',
+ 'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries :: Application Frameworks',
diff --git a/testproject/manage.py b/testproject/manage.py
index 97ed576b6..8c9f710b6 100755
--- a/testproject/manage.py
+++ b/testproject/manage.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+from __future__ import absolute_import
+
import os
import sys
diff --git a/testproject/testproject/settings.py b/testproject/testproject/settings.py
index ba3ddc9b3..4b428be32 100644
--- a/testproject/testproject/settings.py
+++ b/testproject/testproject/settings.py
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
from os import path as os_path
+
PROJECT_PATH = os_path.abspath(os_path.split(__file__)[0])
DEBUG = True
diff --git a/testproject/testproject/urls.py b/testproject/testproject/urls.py
index 684a628ae..590d5d32a 100644
--- a/testproject/testproject/urls.py
+++ b/testproject/testproject/urls.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
from django.conf.urls import include, url
from django.conf import settings
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
diff --git a/testproject/testproject/wsgi.py b/testproject/testproject/wsgi.py
index fc4f30d7d..cba768928 100644
--- a/testproject/testproject/wsgi.py
+++ b/testproject/testproject/wsgi.py
@@ -13,6 +13,7 @@
framework.
"""
+from __future__ import absolute_import
import os
import sys
diff --git a/testproject/vmanage.py b/testproject/vmanage.py
index 0377dbe7b..2a831bb22 100755
--- a/testproject/vmanage.py
+++ b/testproject/vmanage.py
@@ -1,4 +1,6 @@
#!virtualenv/bin/python
+from __future__ import absolute_import
+
import os
import sys
diff --git a/wiki/admin.py b/wiki/admin.py
index 693f014c9..6dcbc2d53 100644
--- a/wiki/admin.py
+++ b/wiki/admin.py
@@ -1,17 +1,20 @@
+from __future__ import absolute_import
+
+from django import forms
from django.contrib import admin
from django.contrib.contenttypes.admin import GenericTabularInline
from django.utils.translation import ugettext_lazy as _
from mptt.admin import MPTTModelAdmin
-from django import forms
-import models
-import editors
+from wiki import editors, models
+
class ArticleObjectAdmin(GenericTabularInline):
model = models.ArticleForObject
extra = 1
max_num = 1
+
class ArticleRevisionForm(forms.ModelForm):
class Meta:
@@ -24,12 +27,14 @@ def __init__(self, *args, **kwargs):
editor = editors.getEditor()
self.fields['content'].widget = editor.get_admin_widget()
+
class ArticleRevisionAdmin(admin.ModelAdmin):
form = ArticleRevisionForm
class Media:
js = editors.getEditorClass().AdminMedia.js
css = editors.getEditorClass().AdminMedia.css
+
class ArticleRevisionInline(admin.TabularInline):
model = models.ArticleRevision
form = ArticleRevisionForm
@@ -41,6 +46,7 @@ class Media:
js = editors.getEditorClass().AdminMedia.js
css = editors.getEditorClass().AdminMedia.css
+
class ArticleForm(forms.ModelForm):
class Meta:
@@ -56,10 +62,12 @@ def __init__(self, *args, **kwargs):
self.fields['current_revision'].queryset = models.ArticleRevision.objects.get_empty_query_set()
self.fields['current_revision'].widget = forms.HiddenInput()
+
class ArticleAdmin(admin.ModelAdmin):
inlines = [ArticleRevisionInline]
form = ArticleForm
+
class URLPathAdmin(MPTTModelAdmin):
inlines = [ArticleObjectAdmin]
list_filter = ('site', 'articles__article__current_revision__deleted',
@@ -70,7 +78,8 @@ class URLPathAdmin(MPTTModelAdmin):
def get_created(self, instance):
return instance.article.created
get_created.short_description = _(u'created')
-
+
+
admin.site.register(models.URLPath, URLPathAdmin)
admin.site.register(models.Article, ArticleAdmin)
-admin.site.register(models.ArticleRevision, ArticleRevisionAdmin)
\ No newline at end of file
+admin.site.register(models.ArticleRevision, ArticleRevisionAdmin)
diff --git a/wiki/conf/settings.py b/wiki/conf/settings.py
index d265ddb3e..46f0b3cfc 100644
--- a/wiki/conf/settings.py
+++ b/wiki/conf/settings.py
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
from django.conf import settings as django_settings
from django.core.urlresolvers import reverse_lazy
diff --git a/wiki/core/__init__.py b/wiki/core/__init__.py
index 7bc7846a5..de5adcdf3 100644
--- a/wiki/core/__init__.py
+++ b/wiki/core/__init__.py
@@ -1,5 +1,7 @@
-import markdown
+from __future__ import absolute_import
+
import bleach
+import markdown
class ArticleMarkdown(markdown.Markdown):
diff --git a/wiki/core/diff.py b/wiki/core/diff.py
index 061c543c4..e19bdac18 100644
--- a/wiki/core/diff.py
+++ b/wiki/core/diff.py
@@ -1,5 +1,8 @@
+from __future__ import absolute_import
+
import difflib
+
def simple_merge(txt1, txt2):
"""Merges two texts"""
differ = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK)
@@ -7,4 +10,4 @@ def simple_merge(txt1, txt2):
content = "".join([l[2:] for l in diff])
- return content
\ No newline at end of file
+ return content
diff --git a/wiki/core/extensions.py b/wiki/core/extensions.py
index f93833506..9fa6a9385 100644
--- a/wiki/core/extensions.py
+++ b/wiki/core/extensions.py
@@ -1,12 +1,13 @@
+from __future__ import absolute_import
+
from markdown.extensions import Extension
-from .processors import AnchorTagProcessor
+from wiki.core.processors import AnchorTagProcessor
class AnchorTagExtension(Extension):
"""
Custom extension to register anchor tag processor with Markdown.
"""
-
def extendMarkdown(self, md, md_globals):
md.treeprocessors.add('AnchorTagProcessor', AnchorTagProcessor(md), '>inline')
diff --git a/wiki/core/http.py b/wiki/core/http.py
index 15a2622fc..3ad4160c3 100644
--- a/wiki/core/http.py
+++ b/wiki/core/http.py
@@ -1,10 +1,13 @@
-import os
+from __future__ import absolute_import
+
import mimetypes
+import os
from datetime import datetime
from django.http import HttpResponse
-from django.utils.http import http_date
from django.utils import dateformat
+from django.utils.http import http_date
+
def send_file(request, filepath, last_modified=None, filename=None):
fullpath = filepath
diff --git a/wiki/core/permissions.py b/wiki/core/permissions.py
index 89658fcd9..c637e560b 100644
--- a/wiki/core/permissions.py
+++ b/wiki/core/permissions.py
@@ -1,5 +1,8 @@
+from __future__ import absolute_import
+
from wiki.conf import settings
+
# Article settings.
def can_assign(article, user):
return not user.is_anonymous() and settings.CAN_ASSIGN(article, user)
diff --git a/wiki/core/plugins/base.py b/wiki/core/plugins/base.py
index 533ecc1e2..eca464da6 100644
--- a/wiki/core/plugins/base.py
+++ b/wiki/core/plugins/base.py
@@ -1,5 +1,8 @@
+from __future__ import absolute_import
+
from django.utils.translation import ugettext_lazy as _
+
"""Base classes for different plugin objects.
* BasePlugin: Create a wiki_plugin.py with a class that inherits from BasePlugin.
@@ -47,4 +50,3 @@ class PluginSettingsFormMixin(object):
def get_usermessage(self):
pass
-
diff --git a/wiki/core/plugins/loader.py b/wiki/core/plugins/loader.py
index 71e647bb4..6e61aa2a4 100644
--- a/wiki/core/plugins/loader.py
+++ b/wiki/core/plugins/loader.py
@@ -5,9 +5,13 @@
Thanks for the technique!
"""
-from django.conf import settings
+from __future__ import absolute_import, print_function
+
from importlib import import_module
+from django.conf import settings
+
+
def get_module(app, modname, verbose, failfast):
"""
Internal function to load a module from a single app.
@@ -15,14 +19,14 @@ def get_module(app, modname, verbose, failfast):
module_name = '%s.%s' % (app, modname)
try:
module = import_module(module_name)
- except ImportError, e:
+ except ImportError as e:
if failfast:
raise e
elif verbose:
- print "Could not load %r from %r: %s" % (modname, app, e)
+ print("Could not load %r from %r: %s" % (modname, app, e))
return None
if verbose:
- print "Loaded %r from %r" % (modname, app)
+ print("Loaded %r from %r" % (modname, app))
return module
def load(modname, verbose=False, failfast=False):
diff --git a/wiki/core/plugins/registry.py b/wiki/core/plugins/registry.py
index 41b7f190f..6b3afb817 100644
--- a/wiki/core/plugins/registry.py
+++ b/wiki/core/plugins/registry.py
@@ -1,6 +1,10 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
from importlib import import_module
+import six
+
_cache = {}
_settings_forms = []
_markdown_extensions = []
@@ -12,14 +16,14 @@ def register(PluginClass):
Register a plugin class. This function will call back your plugin's
constructor.
"""
- if PluginClass in _cache.keys():
+ if PluginClass in list(_cache.keys()):
raise Exception("Plugin class already registered")
plugin = PluginClass()
_cache[PluginClass] = plugin
settings_form = getattr(PluginClass, 'settings_form', None)
if settings_form:
- if isinstance(settings_form, basestring):
+ if isinstance(settings_form, six.string_types):
klassname = settings_form.split(".")[-1]
modulename = ".".join(settings_form.split(".")[:-1])
form_module = import_module(modulename)
@@ -52,4 +56,4 @@ def get_sidebar():
return _sidebar
def get_settings_forms():
- return _settings_forms
\ No newline at end of file
+ return _settings_forms
diff --git a/wiki/core/processors.py b/wiki/core/processors.py
index d1b00a8e6..216c01f15 100644
--- a/wiki/core/processors.py
+++ b/wiki/core/processors.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
from markdown.treeprocessors import Treeprocessor
diff --git a/wiki/decorators.py b/wiki/decorators.py
index 5bb65f1d3..493c17f89 100644
--- a/wiki/decorators.py
+++ b/wiki/decorators.py
@@ -1,15 +1,20 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
+import json
+
from django.conf import settings as django_settings
from django.core.urlresolvers import reverse
-from django.http import HttpResponse, HttpResponseNotFound, \
- HttpResponseForbidden
-from django.shortcuts import redirect, get_object_or_404
+from django.http import (HttpResponse, HttpResponseForbidden,
+ HttpResponseNotFound)
+from django.shortcuts import get_object_or_404, redirect
from django.template.context import RequestContext
from django.template.loader import render_to_string
-import json
+from six.moves import filter
from wiki.core.exceptions import NoRootURL
+
def json_view(func):
def wrap(request, *args, **kwargs):
obj = func(request, *args, **kwargs)
@@ -20,6 +25,7 @@ def wrap(request, *args, **kwargs):
return response
return wrap
+
def response_forbidden(request, article, urlpath):
if request.user.is_anonymous():
return redirect(django_settings.LOGIN_URL)
@@ -28,6 +34,7 @@ def response_forbidden(request, article, urlpath):
render_to_string("wiki/permission_denied.html", context={'article': article, 'urlpath': urlpath},
request=request))
+
def get_article(func=None, can_read=True, can_write=False,
deleted_contents=False, not_locked=False,
can_delete=False, can_moderate=False):
@@ -55,7 +62,7 @@ def get_article(func=None, can_read=True, can_write=False,
"""
def wrapper(request, *args, **kwargs):
- import models
+ from wiki import models
path = kwargs.pop('path', None)
article_id = kwargs.pop('article_id', None)
@@ -70,7 +77,7 @@ def wrapper(request, *args, **kwargs):
return redirect('wiki:root_create')
except models.URLPath.DoesNotExist:
try:
- pathlist = filter(lambda x: x!="", path.split("/"),)
+ pathlist = list(filter(lambda x: x!="", path.split("/"),))
path = "/".join(pathlist[:-1])
parent = models.URLPath.get_by_path(path)
return redirect(reverse("wiki:create", kwargs={'path': parent.path,}) + "?slug=%s" % pathlist[-1])
@@ -96,7 +103,7 @@ def wrapper(request, *args, **kwargs):
article = get_object_or_404(articles, id=article_id)
try:
urlpath = models.URLPath.objects.get(articles__article=article)
- except models.URLPath.DoesNotExist, models.URLPath.MultipleObjectsReturned:
+ except (models.URLPath.DoesNotExist, models.URLPath.MultipleObjectsReturned):
urlpath = None
@@ -139,4 +146,3 @@ def wrapper(request, *args, **kwargs):
deleted_contents=deleted_contents,
not_locked=not_locked,can_delete=can_delete,
can_moderate=can_moderate)
-
diff --git a/wiki/editors/__init__.py b/wiki/editors/__init__.py
index d7f08e008..d95eb0dbd 100644
--- a/wiki/editors/__init__.py
+++ b/wiki/editors/__init__.py
@@ -1,6 +1,9 @@
-from wiki.conf import settings
+from __future__ import absolute_import
+
from django.core.urlresolvers import get_callable
+from wiki.conf import settings
+
_EditorClass = None
_editor = None
diff --git a/wiki/editors/base.py b/wiki/editors/base.py
index 985ad5814..94687e39f 100644
--- a/wiki/editors/base.py
+++ b/wiki/editors/base.py
@@ -1,5 +1,8 @@
+from __future__ import absolute_import
+
from django import forms
+
class BaseEditor():
"""Editors should inherit from this. See wiki.editors for examples."""
@@ -22,5 +25,3 @@ class AdminMedia:
class Media:
css = {}
js = ()
-
-
diff --git a/wiki/editors/markitup.py b/wiki/editors/markitup.py
index 8c6d2ed33..98caba009 100644
--- a/wiki/editors/markitup.py
+++ b/wiki/editors/markitup.py
@@ -1,6 +1,8 @@
+from __future__ import absolute_import
+
from django import forms
from django.forms.utils import flatatt
-from django.utils.encoding import force_unicode
+from django.utils.encoding import force_text
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
@@ -22,7 +24,7 @@ def render(self, name, value, attrs=None):
if value is None: value = ''
final_attrs = self.build_attrs_compat(attrs, name=name)
return mark_safe(u'' % (flatatt(final_attrs),
- conditional_escape(force_unicode(value))))
+ conditional_escape(force_text(value))))
class MarkItUpWidget(BuildAttrsCompat, forms.Widget):
@@ -38,7 +40,7 @@ def render(self, name, value, attrs=None):
if value is None: value = ''
final_attrs = self.build_attrs_compat(attrs, name=name)
return mark_safe(u'
' % (flatatt(final_attrs),
- conditional_escape(force_unicode(value))))
+ conditional_escape(force_text(value))))
class MarkItUp(BaseEditor):
editor_id = 'markitup'
@@ -68,4 +70,3 @@ class Media:
"wiki/markitup/jquery.markitup.js",
"wiki/markitup/sets/frontend/set.js",
)
-
diff --git a/wiki/forms.py b/wiki/forms.py
index d2f7a1b41..ffd11e296 100644
--- a/wiki/forms.py
+++ b/wiki/forms.py
@@ -1,22 +1,25 @@
# -*- coding: utf-8 -*-
-from django import forms
-from django.utils.translation import ugettext_lazy as _
-from django.utils.safestring import mark_safe
-from django.forms.utils import flatatt
-from django.utils.encoding import force_unicode
-from django.utils.html import escape, conditional_escape, strip_tags
+from __future__ import absolute_import, print_function
from itertools import chain
+from django import forms
+from django.contrib.auth.models import User
+from django.forms.utils import flatatt
+from django.forms.widgets import HiddenInput
+from django.utils.encoding import force_text
+from django.utils.html import conditional_escape, escape, strip_tags
+from django.utils.safestring import mark_safe
+from django.utils.translation import ugettext_lazy as _
+
from wiki import models
from wiki.conf import settings
-from wiki.editors import getEditor
-from wiki.core.diff import simple_merge
-from django.forms.widgets import HiddenInput
-from wiki.core.plugins.base import PluginSettingsFormMixin
-from django.contrib.auth.models import User
from wiki.core import permissions
from wiki.core.compat import BuildAttrsCompat
+from wiki.core.diff import simple_merge
+from wiki.core.plugins.base import PluginSettingsFormMixin
+from wiki.editors import getEditor
+
class SpamProtectionMixin():
@@ -166,19 +169,19 @@ def render(self, name, value, attrs=None, choices=()):
return mark_safe(u'\n'.join(output))
def render_option(self, selected_choices, option_value, option_label):
- option_value = force_unicode(option_value)
+ option_value = force_text(option_value)
selected_html = (option_value in selected_choices) and u' selected="selected"' or ''
return u'%s' % (
escape(option_value), selected_html,
- conditional_escape(force_unicode(option_label)))
+ conditional_escape(force_text(option_label)))
def render_options(self, choices, selected_choices):
# Normalize to strings.
- selected_choices = set([force_unicode(v) for v in selected_choices])
+ selected_choices = set([force_text(v) for v in selected_choices])
output = []
for option_value, option_label in chain(self.choices, choices):
if isinstance(option_label, (list, tuple)):
- output.append(u'' % escape(force_unicode(option_value)))
+ output.append(u'' % escape(force_text(option_value)))
for option in option_label:
output.append(self.render_option(selected_choices, *option))
else:
@@ -295,7 +298,7 @@ def __init__(self, article, request, *args, **kwargs):
self.can_change_groups = False
self.can_assign = False
- print "checking can_assing", permissions.can_assign(article, request.user), request.user.is_staff
+ print("checking can_assing", permissions.can_assign(article, request.user), request.user.is_staff)
if permissions.can_assign(article, request.user):
self.can_assign = True
self.fields['group'].queryset = models.Group.objects.all()
diff --git a/wiki/management/commands/wikiviz.py b/wiki/management/commands/wikiviz.py
index d94566009..9e6c53563 100644
--- a/wiki/management/commands/wikiviz.py
+++ b/wiki/management/commands/wikiviz.py
@@ -43,6 +43,21 @@
-e, --inheritance
show inheritance arrows.
"""
+from __future__ import absolute_import, print_function
+
+import os
+import sys
+from optparse import make_option
+
+from django.core.management.base import BaseCommand
+from django.db import models
+from django.db.models import get_models
+from django.db.models.fields.related import (ForeignKey, ManyToManyField,
+ OneToOneField, RelatedField)
+from django.template import Context, loader
+from django.utils.safestring import mark_safe
+from django.utils.translation import activate as activate_language
+
__version__ = "0.99"
__svnid__ = "$Id$"
__license__ = "Python"
@@ -59,17 +74,7 @@
"Benjamin Bach ",
]
-import sys, os
-from django.core.management.base import BaseCommand
-from optparse import make_option
-from django.utils.translation import activate as activate_language
-from django.utils.safestring import mark_safe
-from django.template import Context, loader
-from django.db import models
-from django.db.models import get_models
-from django.db.models.fields.related import \
- ForeignKey, OneToOneField, ManyToManyField, RelatedField
try:
from django.db.models.fields.generic import GenericRelation
@@ -406,8 +411,7 @@ class Command(BaseCommand):
def handle(self, *args, **options):
if not args and not options.get('all_applications', False):
- print __doc__
+ print(__doc__)
sys.exit()
- print generate_dot(args, **options)
-
+ print(generate_dot(args, **options))
diff --git a/wiki/managers.py b/wiki/managers.py
index 4ba864b94..5d02d3244 100644
--- a/wiki/managers.py
+++ b/wiki/managers.py
@@ -1,8 +1,11 @@
+from __future__ import absolute_import
+
from django.db import models
from django.db.models import Q
-from django.db.models.query import QuerySet, EmptyQuerySet
+from django.db.models.query import EmptyQuerySet, QuerySet
from mptt.managers import TreeManager
+
class ArticleEmptyQuerySet(QuerySet):
def can_read(self, user):
return self
diff --git a/wiki/middleware.py b/wiki/middleware.py
index 05076f93f..0c4e36b5d 100644
--- a/wiki/middleware.py
+++ b/wiki/middleware.py
@@ -1,5 +1,7 @@
-import threading
+from __future__ import absolute_import
+
import importlib
+import threading
from django.conf import settings
diff --git a/wiki/migrations/0001_initial.py b/wiki/migrations/0001_initial.py
index a51a0dc19..678bb3a2d 100644
--- a/wiki/migrations/0001_initial.py
+++ b/wiki/migrations/0001_initial.py
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
-from django.db import models, migrations
import mptt.fields
from django.conf import settings
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/wiki/migrations/0002_remove_article_subscription.py b/wiki/migrations/0002_remove_article_subscription.py
index e66fd029b..be93ad704 100644
--- a/wiki/migrations/0002_remove_article_subscription.py
+++ b/wiki/migrations/0002_remove_article_subscription.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
from django.db import migrations, models
diff --git a/wiki/migrations/0003_ip_address_conv.py b/wiki/migrations/0003_ip_address_conv.py
index 92a107fbf..22612fb9c 100644
--- a/wiki/migrations/0003_ip_address_conv.py
+++ b/wiki/migrations/0003_ip_address_conv.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
from django.db import migrations, models
diff --git a/wiki/migrations/0004_increase_slug_size.py b/wiki/migrations/0004_increase_slug_size.py
index b9fae30be..ef5038f0d 100644
--- a/wiki/migrations/0004_increase_slug_size.py
+++ b/wiki/migrations/0004_increase_slug_size.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
from django.db import migrations, models
diff --git a/wiki/migrations/0005_remove_attachments_and_images.py b/wiki/migrations/0005_remove_attachments_and_images.py
index e0a3f443f..c44b9105d 100644
--- a/wiki/migrations/0005_remove_attachments_and_images.py
+++ b/wiki/migrations/0005_remove_attachments_and_images.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-09-07 19:03
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
from django.db import migrations
diff --git a/wiki/models/__init__.py b/wiki/models/__init__.py
index 85f5a4860..f3e37ad8f 100644
--- a/wiki/models/__init__.py
+++ b/wiki/models/__init__.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
from django.conf import settings as django_settings
from django.core.exceptions import ImproperlyConfigured
diff --git a/wiki/models/article.py b/wiki/models/article.py
index 4cb7de5a6..3588b86bd 100644
--- a/wiki/models/article.py
+++ b/wiki/models/article.py
@@ -1,19 +1,21 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
import bleach
-from django.contrib.contenttypes.models import ContentType
+from django.contrib.auth.models import Group, User
from django.contrib.contenttypes import fields
-from django.contrib.auth.models import User, Group
-from django.db.models.fields import GenericIPAddressField
+from django.contrib.contenttypes.models import ContentType
from django.db import models
+from django.db.models.fields import GenericIPAddressField
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
+from mptt.models import MPTTModel
+from wiki import managers
from wiki.conf import settings
from wiki.core import article_markdown, permissions
from wiki.core.extensions import AnchorTagExtension
from wiki.core.plugins import registry as plugin_registry
-from wiki import managers
-from mptt.models import MPTTModel
class Article(models.Model):
diff --git a/wiki/models/pluginbase.py b/wiki/models/pluginbase.py
index 7f493fee7..9346ffefa 100644
--- a/wiki/models/pluginbase.py
+++ b/wiki/models/pluginbase.py
@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
from django.db import models
-from django.utils.translation import ugettext_lazy as _
from django.db.models import signals
+from django.utils.translation import ugettext_lazy as _
+
from wiki.models.article import BaseRevisionMixin
+
"""
There are three kinds of plugin base models:
@@ -25,7 +29,7 @@
"""
-from article import Article, ArticleRevision
+from .article import Article, ArticleRevision
class ArticlePlugin(models.Model):
diff --git a/wiki/models/urlpath.py b/wiki/models/urlpath.py
index 00a7ec17e..1bef4d08d 100644
--- a/wiki/models/urlpath.py
+++ b/wiki/models/urlpath.py
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import, print_function
+
import logging
from django.contrib.contenttypes import fields
@@ -8,17 +10,17 @@
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.db import models, transaction
-from django.db.models.signals import pre_delete, post_save
-from django.utils.translation import ugettext_lazy as _, ugettext
-
+from django.db.models.signals import post_save, pre_delete
+from django.utils.translation import ugettext
+from django.utils.translation import ugettext_lazy as _
from mptt.fields import TreeForeignKey
from mptt.models import MPTTModel
from wiki import managers
from wiki.conf import settings
-from wiki.core.exceptions import NoRootURL, MultipleRootURLs
+from wiki.core.exceptions import MultipleRootURLs, NoRootURL
from wiki.middleware import get_current_request
-from wiki.models.article import ArticleRevision, ArticleForObject, Article
+from wiki.models.article import Article, ArticleForObject, ArticleRevision
log = logging.getLogger(__name__)
@@ -82,7 +84,7 @@ def set_cached_ancestors_from_parent(self, parent):
def path(self):
if not self.parent: return ""
- ancestors = filter(lambda ancestor: ancestor.parent is not None, self.cached_ancestors)
+ ancestors = [ancestor for ancestor in self.cached_ancestors if ancestor.parent is not None]
slugs = [obj.slug if obj.slug else "" for obj in ancestors + [self] ]
return "/".join(slugs) + "/"
@@ -107,7 +109,7 @@ def delete_subtree(self):
try:
with transaction.atomic():
for descendant in self.get_descendants(include_self=True).order_by("-level"):
- print "deleting " , descendant
+ print("deleting " , descendant)
descendant.article.delete()
except:
log.exception("Exception deleting article subtree.")
diff --git a/wiki/plugins/attachments/__init__.py b/wiki/plugins/attachments/__init__.py
index 2d234bc74..44433dce7 100644
--- a/wiki/plugins/attachments/__init__.py
+++ b/wiki/plugins/attachments/__init__.py
@@ -1,2 +1,3 @@
from __future__ import unicode_literals
+
default_app_config = 'wiki.apps.AttachmentsConfig'
diff --git a/wiki/plugins/attachments/admin.py b/wiki/plugins/attachments/admin.py
index b9e23d78c..0f6ccdf50 100644
--- a/wiki/plugins/attachments/admin.py
+++ b/wiki/plugins/attachments/admin.py
@@ -1,12 +1,16 @@
+from __future__ import absolute_import
+
from django.contrib import admin
-import models
+from wiki.plugins.attachments import models
+
class AttachmentRevisionAdmin(admin.TabularInline):
model = models.AttachmentRevision
extra = 1
fields = ('file', 'user', 'user_message')
+
class AttachmentAdmin(admin.ModelAdmin):
inlines = [AttachmentRevisionAdmin]
@@ -16,4 +20,5 @@ class AttachmentAdmin(admin.ModelAdmin):
#def has_add_permission(self, request):
# return False
-admin.site.register(models.Attachment, AttachmentAdmin)
\ No newline at end of file
+
+admin.site.register(models.Attachment, AttachmentAdmin)
diff --git a/wiki/plugins/attachments/forms.py b/wiki/plugins/attachments/forms.py
index 47ac27954..8163afe67 100644
--- a/wiki/plugins/attachments/forms.py
+++ b/wiki/plugins/attachments/forms.py
@@ -1,9 +1,12 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
from django import forms
from django.utils.translation import ugettext_lazy as _
from wiki.plugins.attachments import models
+
class AttachmentForm(forms.ModelForm):
description = forms.CharField(label=_(u'Description'),
diff --git a/wiki/plugins/attachments/markdown_extensions.py b/wiki/plugins/attachments/markdown_extensions.py
index 97f633dc0..b6004e805 100644
--- a/wiki/plugins/attachments/markdown_extensions.py
+++ b/wiki/plugins/attachments/markdown_extensions.py
@@ -1,12 +1,15 @@
-import markdown
+from __future__ import absolute_import
+
import re
+import markdown
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
+from wiki.plugins.attachments import models
+
ATTACHMENT_RE = re.compile(r'.*(\[attachment\:(?P\d+)\]).*', re.IGNORECASE)
-from wiki.plugins.attachments import models
class AttachmentExtension(markdown.Extension):
""" Abbreviation Extension for Python-Markdown. """
@@ -35,4 +38,3 @@ def run(self, lines):
line = line.replace(m.group(1), u"""Attachment with ID #%s is deleted.""" % attachment_id)
new_text.append(line)
return new_text
-
diff --git a/wiki/plugins/attachments/migrations/0001_initial.py b/wiki/plugins/attachments/migrations/0001_initial.py
index 7f7b5fc66..cde1feea5 100644
--- a/wiki/plugins/attachments/migrations/0001_initial.py
+++ b/wiki/plugins/attachments/migrations/0001_initial.py
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
-from django.db import models, migrations
-import wiki.plugins.attachments.models
from django.conf import settings
+from django.db import migrations, models
+
+import wiki.plugins.attachments.models
class Migration(migrations.Migration):
diff --git a/wiki/plugins/attachments/models.py b/wiki/plugins/attachments/models.py
index 5a137c63e..200f4c380 100644
--- a/wiki/plugins/attachments/models.py
+++ b/wiki/plugins/attachments/models.py
@@ -1,11 +1,14 @@
+from __future__ import absolute_import
+
from django.db import models
from django.utils.translation import ugettext_lazy as _
-from . import settings
-
from wiki import managers
-from wiki.models.pluginbase import ReusablePlugin
from wiki.models.article import BaseRevisionMixin
+from wiki.models.pluginbase import ReusablePlugin
+
+from . import settings
+
class IllegalFileExtension(Exception):
"""File extension on upload is not allowed"""
@@ -49,7 +52,7 @@ def upload_path(instance, filename):
raise IllegalFileExtension("No file extension found in filename. That's not okay!")
# Must be an allowed extension
- if not extension.lower() in map(lambda x: x.lower(), settings.FILE_EXTENSIONS):
+ if not extension.lower() in [x.lower() for x in settings.FILE_EXTENSIONS]:
raise IllegalFileExtension("The following filename is illegal: %s. Extension has to be one of %s" %
(filename, ", ".join(settings.FILE_EXTENSIONS)))
@@ -121,7 +124,7 @@ def save(self, *args, **kwargs):
previous_revision = self.attachment.attachmentrevision_set.latest()
self.revision_number = previous_revision.revision_number + 1
# NB! The above should not raise the below exception, but somehow it does.
- except AttachmentRevision.DoesNotExist, Attachment.DoesNotExist:
+ except (AttachmentRevision.DoesNotExist, Attachment.DoesNotExist):
self.revision_number = 1
super(AttachmentRevision, self).save(*args, **kwargs)
diff --git a/wiki/plugins/attachments/settings.py b/wiki/plugins/attachments/settings.py
index 00e2c50ca..e0fa297ab 100644
--- a/wiki/plugins/attachments/settings.py
+++ b/wiki/plugins/attachments/settings.py
@@ -1,4 +1,7 @@
+from __future__ import absolute_import
+
from django.conf import settings as django_settings
+from django.core.files.storage import default_storage
SLUG = "attachments"
@@ -28,5 +31,4 @@
# to allow. For your own safety.
FILE_EXTENSIONS = getattr(django_settings, 'WIKI_FILE_EXTENSIONS', ['pdf', 'doc', 'odt', 'docx', 'txt'])
-from django.core.files.storage import default_storage
-STORAGE_BACKEND = getattr(django_settings, 'WIKI_STORAGE_BACKEND', default_storage)
\ No newline at end of file
+STORAGE_BACKEND = getattr(django_settings, 'WIKI_STORAGE_BACKEND', default_storage)
diff --git a/wiki/plugins/attachments/views.py b/wiki/plugins/attachments/views.py
index 274b48131..56aad1970 100644
--- a/wiki/plugins/attachments/views.py
+++ b/wiki/plugins/attachments/views.py
@@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
from django.contrib import messages
from django.db import transaction
from django.db.models import Q
from django.http import Http404
-from django.shortcuts import redirect, get_object_or_404
+from django.shortcuts import get_object_or_404, redirect
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext as _
from django.views.generic.base import TemplateView, View
@@ -12,7 +14,7 @@
from wiki.core.http import send_file
from wiki.decorators import get_article, response_forbidden
-from wiki.plugins.attachments import models, settings, forms
+from wiki.plugins.attachments import forms, models, settings
from wiki.views.mixins import ArticleMixin
@@ -47,7 +49,7 @@ def form_valid(self, form):
attachment_revision.set_from_request(self.request)
attachment_revision.save()
messages.success(self.request, _(u'%s was successfully added.') % attachment_revision.get_filename())
- except models.IllegalFileExtension, e:
+ except models.IllegalFileExtension as e:
messages.error(self.request, _(u'Your file could not be saved: %s') % e)
except Exception:
messages.error(self.request, _(u'Your file could not be saved, probably because of a permission error on the web server.'))
@@ -112,7 +114,7 @@ def form_valid(self, form):
self.attachment.current_revision = attachment_revision
self.attachment.save()
messages.success(self.request, _(u'%s uploaded and replaces old attachment.') % attachment_revision.get_filename())
- except models.IllegalFileExtension, e:
+ except models.IllegalFileExtension as e:
messages.error(self.request, _(u'Your file could not be saved: %s') % e)
return redirect("wiki:attachments_replace", attachment_id=self.attachment.id,
path=self.urlpath.path, article_id=self.article.id)
diff --git a/wiki/plugins/attachments/wiki_plugin.py b/wiki/plugins/attachments/wiki_plugin.py
index 1627ef4e6..4a3900590 100644
--- a/wiki/plugins/attachments/wiki_plugin.py
+++ b/wiki/plugins/attachments/wiki_plugin.py
@@ -1,15 +1,16 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
from django.conf.urls import url
from django.utils.translation import ugettext_lazy as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
-from wiki.plugins.attachments import views
-from wiki.plugins.attachments import models
-from wiki.plugins.attachments import settings
+from wiki.plugins.attachments import models, settings, views
from wiki.plugins.attachments.markdown_extensions import AttachmentExtension
from wiki.plugins.notifications import ARTICLE_EDIT
+
class AttachmentPlugin(BasePlugin):
#settings_form = 'wiki.plugins.notifications.forms.SubscriptionForm'
@@ -46,4 +47,3 @@ def __init__(self):
pass
registry.register(AttachmentPlugin)
-
diff --git a/wiki/plugins/help/models.py b/wiki/plugins/help/models.py
index 71a836239..dbe627f0e 100644
--- a/wiki/plugins/help/models.py
+++ b/wiki/plugins/help/models.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
from django.db import models
# Create your models here.
diff --git a/wiki/plugins/help/tests.py b/wiki/plugins/help/tests.py
index 501deb776..1ddecbc38 100644
--- a/wiki/plugins/help/tests.py
+++ b/wiki/plugins/help/tests.py
@@ -5,6 +5,8 @@
Replace this with more appropriate tests for your application.
"""
+from __future__ import absolute_import
+
from django.test import TestCase
diff --git a/wiki/plugins/help/wiki_plugin.py b/wiki/plugins/help/wiki_plugin.py
index b59bd12d0..b56c79950 100644
--- a/wiki/plugins/help/wiki_plugin.py
+++ b/wiki/plugins/help/wiki_plugin.py
@@ -1,9 +1,12 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
from django.utils.translation import ugettext_lazy as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
+
class HelpPlugin(BasePlugin):
slug = 'help'
@@ -19,6 +22,6 @@ class HelpPlugin(BasePlugin):
def __init__(self):
pass
-
-registry.register(HelpPlugin)
+
+registry.register(HelpPlugin)
diff --git a/wiki/plugins/images/admin.py b/wiki/plugins/images/admin.py
index 534bbbfc4..ed6d5a176 100644
--- a/wiki/plugins/images/admin.py
+++ b/wiki/plugins/images/admin.py
@@ -1,6 +1,8 @@
+from __future__ import absolute_import
from django.contrib import admin
from django import forms
-import models
+from wiki.plugins.images import models
+
class ImageForm(forms.ModelForm):
@@ -22,9 +24,11 @@ class ImageRevisionInline(admin.TabularInline):
model = models.ImageRevision
extra = 1
fields = ('image', 'locked', 'deleted')
-
+
+
class ImageAdmin(admin.ModelAdmin):
form = ImageForm
inlines = (ImageRevisionInline,)
+
admin.site.register(models.Image, ImageAdmin)
\ No newline at end of file
diff --git a/wiki/plugins/images/forms.py b/wiki/plugins/images/forms.py
index 8debc7049..d10b9c363 100644
--- a/wiki/plugins/images/forms.py
+++ b/wiki/plugins/images/forms.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
from django import forms
from django.utils.translation import ugettext_lazy as _
diff --git a/wiki/plugins/images/markdown_extensions.py b/wiki/plugins/images/markdown_extensions.py
index 8cca18c18..49d310909 100644
--- a/wiki/plugins/images/markdown_extensions.py
+++ b/wiki/plugins/images/markdown_extensions.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
import markdown
import re
diff --git a/wiki/plugins/images/migrations/0001_initial.py b/wiki/plugins/images/migrations/0001_initial.py
index f1f002b47..e9c9c8511 100644
--- a/wiki/plugins/images/migrations/0001_initial.py
+++ b/wiki/plugins/images/migrations/0001_initial.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
+from __future__ import absolute_import
from django.db import models, migrations
import wiki.plugins.images.models
diff --git a/wiki/plugins/images/models.py b/wiki/plugins/images/models.py
index 9e7e8348c..72635fd0f 100644
--- a/wiki/plugins/images/models.py
+++ b/wiki/plugins/images/models.py
@@ -1,15 +1,18 @@
+from __future__ import absolute_import
from django.conf import settings as django_settings
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.utils.translation import ugettext_lazy as _
-import settings
+from wiki.plugins.images import settings
from wiki.models.pluginbase import RevisionPlugin, RevisionPluginRevision
+
if not "sorl.thumbnail" in django_settings.INSTALLED_APPS:
raise ImproperlyConfigured('wiki.plugins.images: needs sorl.thumbnail in INSTALLED_APPS')
+
def upload_path(instance, filename):
from os import path
# Has to match original extension filename
@@ -22,6 +25,7 @@ def upload_path(instance, filename):
upload_path = path.join(upload_path, m.hexdigest())
return path.join(upload_path, filename)
+
class Image(RevisionPlugin):
# The plugin system is so awesome that the inheritor doesn't need to do
@@ -45,6 +49,7 @@ def __unicode__(self):
title = (_(u'Image: %s') % self.current_revision.imagerevision.get_filename()) if self.current_revision else _(u'Current revision not set!!')
return title
+
class ImageRevision(RevisionPluginRevision):
image = models.ImageField(upload_to=upload_path,
diff --git a/wiki/plugins/images/settings.py b/wiki/plugins/images/settings.py
index 7bcc27e7b..9dac168ee 100644
--- a/wiki/plugins/images/settings.py
+++ b/wiki/plugins/images/settings.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
from django.conf import settings as django_settings
# Where to store images
diff --git a/wiki/plugins/images/templatetags/wiki_images_tags.py b/wiki/plugins/images/templatetags/wiki_images_tags.py
index c3a3feb1b..5e0f5f7b0 100644
--- a/wiki/plugins/images/templatetags/wiki_images_tags.py
+++ b/wiki/plugins/images/templatetags/wiki_images_tags.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
from django import template
from wiki.plugins.images import models
diff --git a/wiki/plugins/images/views.py b/wiki/plugins/images/views.py
index c86f65b9e..ca0f47e9b 100644
--- a/wiki/plugins/images/views.py
+++ b/wiki/plugins/images/views.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
from django.contrib import messages
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404, redirect
diff --git a/wiki/plugins/images/wiki_plugin.py b/wiki/plugins/images/wiki_plugin.py
index d57104bff..4eeaa0613 100644
--- a/wiki/plugins/images/wiki_plugin.py
+++ b/wiki/plugins/images/wiki_plugin.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
from django.conf.urls import url
from django.utils.translation import ugettext_lazy as _
diff --git a/wiki/plugins/links/mdx/djangowikilinks.py b/wiki/plugins/links/mdx/djangowikilinks.py
index 2b5a37c2e..9316d8e4f 100755
--- a/wiki/plugins/links/mdx/djangowikilinks.py
+++ b/wiki/plugins/links/mdx/djangowikilinks.py
@@ -20,6 +20,7 @@
'''
+from __future__ import absolute_import
import markdown
from os import path as os_path
@@ -124,9 +125,9 @@ def _getMeta(self):
base_url = self.config['base_url'][0]
html_class = self.config['html_class'][0]
if hasattr(self.md, 'Meta'):
- if self.md.Meta.has_key('wiki_base_url'):
+ if 'wiki_base_url' in self.md.Meta:
base_url = self.md.Meta['wiki_base_url'][0]
- if self.md.Meta.has_key('wiki_html_class'):
+ if 'wiki_html_class' in self.md.Meta:
html_class = self.md.Meta['wiki_html_class'][0]
return base_url, html_class
diff --git a/wiki/plugins/links/mdx/urlize.py b/wiki/plugins/links/mdx/urlize.py
index 5b43c84e2..a800f283b 100644
--- a/wiki/plugins/links/mdx/urlize.py
+++ b/wiki/plugins/links/mdx/urlize.py
@@ -39,6 +39,7 @@
"""
+from __future__ import absolute_import
import markdown
import re
diff --git a/wiki/plugins/links/models.py b/wiki/plugins/links/models.py
index 71a836239..00539216d 100644
--- a/wiki/plugins/links/models.py
+++ b/wiki/plugins/links/models.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
from django.db import models
# Create your models here.
diff --git a/wiki/plugins/links/tests.py b/wiki/plugins/links/tests.py
index 501deb776..e585808ad 100644
--- a/wiki/plugins/links/tests.py
+++ b/wiki/plugins/links/tests.py
@@ -5,6 +5,7 @@
Replace this with more appropriate tests for your application.
"""
+from __future__ import absolute_import
from django.test import TestCase
diff --git a/wiki/plugins/links/views.py b/wiki/plugins/links/views.py
index f17578d84..c955db7d4 100644
--- a/wiki/plugins/links/views.py
+++ b/wiki/plugins/links/views.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
from wiki.decorators import json_view, get_article
from django.views.generic.base import View
from django.utils.decorators import method_decorator
diff --git a/wiki/plugins/links/wiki_plugin.py b/wiki/plugins/links/wiki_plugin.py
index b91bdad15..f92ea1ec8 100644
--- a/wiki/plugins/links/wiki_plugin.py
+++ b/wiki/plugins/links/wiki_plugin.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
from django.conf.urls import url
from django.utils.translation import ugettext_lazy as _
diff --git a/wiki/plugins/notifications/forms.py b/wiki/plugins/notifications/forms.py
index 8594d909a..b4121185f 100644
--- a/wiki/plugins/notifications/forms.py
+++ b/wiki/plugins/notifications/forms.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
from django import forms
from django.utils.translation import ugettext_lazy as _
@@ -8,6 +9,7 @@
from wiki.plugins.notifications import ARTICLE_EDIT
from wiki.core.plugins.base import PluginSettingsFormMixin
+
class SubscriptionForm(PluginSettingsFormMixin, forms.Form):
settings_form_headline = _(u'Notifications')
@@ -43,7 +45,8 @@ def get_usermessage(self):
return _('Your notification settings were unchanged, so nothing saved.')
def save(self, *args, **kwargs):
- import models
+ from wiki.plugins.notifications import models
+
cd = self.cleaned_data
if not self.changed_data:
return
diff --git a/wiki/plugins/notifications/migrations/0001_initial.py b/wiki/plugins/notifications/migrations/0001_initial.py
index 3052fa1e8..7feaa518d 100644
--- a/wiki/plugins/notifications/migrations/0001_initial.py
+++ b/wiki/plugins/notifications/migrations/0001_initial.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
+from __future__ import absolute_import
from django.db import models, migrations
diff --git a/wiki/plugins/notifications/models.py b/wiki/plugins/notifications/models.py
index 848c00f9b..215a9e240 100644
--- a/wiki/plugins/notifications/models.py
+++ b/wiki/plugins/notifications/models.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from django.db.models import signals
@@ -11,6 +12,7 @@
from wiki.plugins.notifications import ARTICLE_EDIT #TODO: Is this bad practice?
from wiki.plugins.notifications import settings
+
class ArticleSubscription(ArticlePlugin, Subscription):
def __unicode__(self):
@@ -22,6 +24,7 @@ def __unicode__(self):
class Meta:
db_table = 'wiki_notifications_articlesubscription'
+
def default_url(article, urlpath=None):
try:
if not urlpath:
@@ -31,6 +34,7 @@ def default_url(article, urlpath=None):
url = reverse('wiki:get', kwargs={'article_id': article.id})
return url
+
def post_article_revision_save(instance, **kwargs):
if kwargs.get('created', False):
url = default_url(instance.article)
@@ -43,7 +47,8 @@ def post_article_revision_save(instance, **kwargs):
else:
notify(_(u'New article created: %s') % instance.title, ARTICLE_EDIT,
target_object=instance, url=url)
-
+
+
# Whenever a new revision is created, we notifĂ˝ users that an article
# was edited
signals.post_save.connect(post_article_revision_save, sender=wiki_models.ArticleRevision,)
@@ -63,7 +68,7 @@ def plugin_notification(instance, **kwargs):
return
if kwargs.get('created', False) == notification_dict.get('created', True):
url = None
- if notification_dict.has_key('get_url'):
+ if 'get_url' in notification_dict:
url = notification_dict['get_url'](instance)
else:
url = default_url(notification_dict['get_article'](instance))
diff --git a/wiki/plugins/notifications/tests.py b/wiki/plugins/notifications/tests.py
index 501deb776..e585808ad 100644
--- a/wiki/plugins/notifications/tests.py
+++ b/wiki/plugins/notifications/tests.py
@@ -5,6 +5,7 @@
Replace this with more appropriate tests for your application.
"""
+from __future__ import absolute_import
from django.test import TestCase
diff --git a/wiki/plugins/notifications/wiki_plugin.py b/wiki/plugins/notifications/wiki_plugin.py
index e2cf3be5d..5f284059f 100644
--- a/wiki/plugins/notifications/wiki_plugin.py
+++ b/wiki/plugins/notifications/wiki_plugin.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
diff --git a/wiki/templatetags/wiki_tags.py b/wiki/templatetags/wiki_tags.py
index 4089d0133..1bb4f5070 100644
--- a/wiki/templatetags/wiki_tags.py
+++ b/wiki/templatetags/wiki_tags.py
@@ -1,14 +1,17 @@
-from django.conf import settings as django_settings
+from __future__ import absolute_import
+
from django import template
+from django.conf import settings as django_settings
from django.contrib.contenttypes.models import ContentType
from django.db.models import Model
from django.forms import BaseForm
-register = template.Library()
-
from wiki import models
from wiki.core.plugins import registry as plugin_registry
+register = template.Library()
+
+
# Cache for looking up objects for articles... article_for_object is
# called more than once per page in multiple template blocks.
_cache = {}
@@ -22,7 +25,7 @@ def article_for_object(context, obj):
# TODO: This is disabled for now, as it should only fire once per request
# Maybe store cache in the request object?
- if True or not obj in _cache.keys():
+ if True or not obj in list(_cache.keys()):
try:
article = models.ArticleForObject.objects.get(content_type=content_type, object_id=obj.pk).article
except models.ArticleForObject.DoesNotExist:
diff --git a/wiki/tests.py b/wiki/tests.py
index 501deb776..1ddecbc38 100644
--- a/wiki/tests.py
+++ b/wiki/tests.py
@@ -5,6 +5,8 @@
Replace this with more appropriate tests for your application.
"""
+from __future__ import absolute_import
+
from django.test import TestCase
diff --git a/wiki/urls.py b/wiki/urls.py
index 394ccb80b..fc19bbf54 100644
--- a/wiki/urls.py
+++ b/wiki/urls.py
@@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
-from django.conf.urls import url, include
+from __future__ import absolute_import
+
+from django.conf.urls import include, url
-from wiki.views import article, accounts
from wiki.conf import settings
from wiki.core.plugins import registry
+from wiki.views import accounts, article
urlpatterns = [
url(r'^$', article.ArticleView.as_view(), name='root', kwargs={'path': ''}),
@@ -73,4 +75,4 @@ def get_pattern(app_name="wiki", namespace="wiki"):
single Django project.
https://docs.djangoproject.com/en/dev/topics/http/urls/#topics-http-reversing-url-namespaces
"""
- return urlpatterns, app_name, namespace
\ No newline at end of file
+ return urlpatterns, app_name, namespace
diff --git a/wiki/views/accounts.py b/wiki/views/accounts.py
index 1def9a969..ce9e4f051 100644
--- a/wiki/views/accounts.py
+++ b/wiki/views/accounts.py
@@ -2,9 +2,12 @@
"""This is nothing but the usual handling of django user accounts, so
go ahead and replace it or disable it!"""
+from __future__ import absolute_import
+
from django.conf import settings as django_settings
from django.contrib import messages
-from django.contrib.auth import logout as auth_logout, login as auth_login
+from django.contrib.auth import login as auth_login
+from django.contrib.auth import logout as auth_logout
from django.contrib.auth.forms import AuthenticationForm, UserCreationForm
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
@@ -63,4 +66,3 @@ def form_valid(self, form, *args, **kwargs):
if not self.referer:
return redirect('wiki:get', path='')
return redirect(self.referer)
-
\ No newline at end of file
diff --git a/wiki/views/article.py b/wiki/views/article.py
index 29c5cf325..086fb0d90 100644
--- a/wiki/views/article.py
+++ b/wiki/views/article.py
@@ -1,27 +1,31 @@
# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
import difflib
from django.contrib import messages
from django.contrib.auth.decorators import login_required
+from django.core.urlresolvers import reverse
+from django.db import transaction
from django.db.models import Q
-from django.shortcuts import render_to_response, redirect, get_object_or_404
+from django.shortcuts import get_object_or_404, redirect, render_to_response
from django.template.context import RequestContext
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext as _
from django.views.generic.base import TemplateView, View
from django.views.generic.edit import FormView
from django.views.generic.list import ListView
+from six.moves import range
-from wiki.views.mixins import ArticleMixin
from wiki import editors, forms, models
from wiki.conf import settings
-from wiki.core.plugins import registry as plugin_registry
+from wiki.core import permissions
from wiki.core.diff import simple_merge
-from wiki.decorators import get_article, json_view
-from django.core.urlresolvers import reverse
-from django.db import transaction
from wiki.core.exceptions import NoRootURL
-from wiki.core import permissions
+from wiki.core.plugins import registry as plugin_registry
+from wiki.decorators import get_article, json_view
+from wiki.views.mixins import ArticleMixin
+
class ArticleView(ArticleMixin, TemplateView):
@@ -35,6 +39,7 @@ def get_context_data(self, **kwargs):
kwargs['selected_tab'] = 'view'
return ArticleMixin.get_context_data(self, **kwargs)
+
class Create(FormView, ArticleMixin):
form_class = forms.CreateForm
@@ -87,7 +92,7 @@ def form_valid(self, form):
messages.success(self.request, _(u"New article '%s' created.") % self.newpath.article.current_revision.title)
# TODO: Handle individual exceptions better and give good feedback.
- except Exception, e:
+ except Exception as e:
if self.request.user.is_superuser:
messages.error(self.request, _(u"There was an error creating this article: %s") % str(e))
else:
@@ -676,4 +681,3 @@ def root_create(request):
c = RequestContext(request, {'create_form': create_form,
'editor': editors.getEditor(),})
return render_to_response("wiki/article/create_root.html", context_instance=c)
-
diff --git a/wiki/views/mixins.py b/wiki/views/mixins.py
index 7b0d71e26..45cd0cfbc 100644
--- a/wiki/views/mixins.py
+++ b/wiki/views/mixins.py
@@ -1,7 +1,10 @@
+from __future__ import absolute_import
+
from django.views.generic.base import TemplateResponseMixin
-from wiki.core.plugins import registry
from wiki.conf import settings
+from wiki.core.plugins import registry
+
class ArticleMixin(TemplateResponseMixin):
"""A mixin that receives an article object as a parameter (usually from a wiki