~netlandish/django-wiki

459307c9bdfe668ff26fa00baa75ac7fa76a99dd — Raffaele Salmaso 6 years ago e355b02
Use regular gettext functions instead of unicode version.
M src/wiki/admin.py => src/wiki/admin.py +1 -1
@@ 1,7 1,7 @@
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 django.utils.translation import gettext_lazy as _
from mptt.admin import MPTTModelAdmin

from . import editors, models

M src/wiki/apps.py => src/wiki/apps.py +1 -1
@@ 1,5 1,5 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class WikiConfig(AppConfig):

M src/wiki/conf/settings.py => src/wiki/conf/settings.py +1 -1
@@ 5,7 5,7 @@ from django.conf import settings as django_settings
from django.contrib.messages import constants as messages
from django.core.files.storage import default_storage
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

#: Should urls be case sensitive?
URL_CASE_SENSITIVE = getattr(django_settings, 'WIKI_URL_CASE_SENSITIVE', False)

M src/wiki/core/plugins/base.py => src/wiki/core/plugins/base.py +1 -1
@@ 1,5 1,5 @@
from django import forms
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _


"""Base classes for different plugin objects.

M src/wiki/forms.py => src/wiki/forms.py +15 -15
@@ 18,8 18,8 @@ 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 ugettext
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext
from django.utils.translation import gettext_lazy as _

from wiki import models
from wiki.conf import settings


@@ 58,10 58,10 @@ class WikiSlugField(forms.SlugField):
def _clean_slug(slug, urlpath):
    if slug.startswith("_"):
        raise forms.ValidationError(
            ugettext('A slug may not begin with an underscore.'))
            gettext('A slug may not begin with an underscore.'))
    if slug == 'admin':
        raise forms.ValidationError(
            ugettext("'admin' is not a permitted slug name."))
            gettext("'admin' is not a permitted slug name."))

    if settings.URL_CASE_SENSITIVE:
        already_existing_slug = models.URLPath.objects.filter(


@@ 76,11 76,11 @@ def _clean_slug(slug, urlpath):
        already_urlpath = already_existing_slug[0]
        if already_urlpath.article and already_urlpath.article.current_revision.deleted:
            raise forms.ValidationError(
                ugettext('A deleted article with slug "%s" already exists.') %
                gettext('A deleted article with slug "%s" already exists.') %
                already_urlpath.slug)
        else:
            raise forms.ValidationError(
                ugettext('A slug named "%s" already exists.') %
                gettext('A slug named "%s" already exists.') %
                already_urlpath.slug)

    if settings.CHECK_SLUG_URL_AVAILABLE:


@@ 89,7 89,7 @@ def _clean_slug(slug, urlpath):
            match = resolve(urlpath.path + '/' + slug + '/')
            if match.app_name != 'wiki':
                raise forms.ValidationError(
                    ugettext('This slug conflicts with an existing URL.'))
                    gettext('This slug conflicts with an existing URL.'))
        except Resolver404:
            pass



@@ 123,7 123,7 @@ class SpamProtectionMixin(object):

        if not (user or ip_address):
            raise forms.ValidationError(
                ugettext(
                gettext(
                    'Spam protection failed to find both a logged in user and an IP address.'))

        def check_interval(from_time, max_count, interval_name):


@@ 139,7 139,7 @@ class SpamProtectionMixin(object):
            revisions = revisions.count()
            if revisions >= max_count:
                raise forms.ValidationError(
                    ugettext('Spam protection: You are only allowed to create or edit %(revisions)d article(s) per %(interval_name)s.') % {
                    gettext('Spam protection: You are only allowed to create or edit %(revisions)d article(s) per %(interval_name)s.') % {
                        'revisions': max_count,
                        'interval_name': interval_name,
                    })


@@ 266,7 266,7 @@ class EditForm(forms.Form, SpamProtectionMixin):
        title = self.cleaned_data.get('title', None)
        title = (title or "").strip()
        if not title:
            raise forms.ValidationError(ugettext('Article is missing title or has an invalid title'))
            raise forms.ValidationError(gettext('Article is missing title or has an invalid title'))
        return title

    def clean(self):


@@ 279,11 279,11 @@ class EditForm(forms.Form, SpamProtectionMixin):
            return cd
        if not str(self.initial_revision.id) == str(self.presumed_revision):
            raise forms.ValidationError(
                ugettext(
                gettext(
                    'While you were editing, someone else changed the revision. Your contents have been automatically merged with the new contents. Please review the text below.'))
        if ('title' in cd) and cd['title'] == self.initial_revision.title and cd[
                'content'] == self.initial_revision.content:
            raise forms.ValidationError(ugettext('No changes made. Nothing to save.'))
            raise forms.ValidationError(gettext('No changes made. Nothing to save.'))
        self.check_spam()
        return cd



@@ 421,10 421,10 @@ class DeleteForm(forms.Form):
    def clean(self):
        cd = super().clean()
        if not cd['confirm']:
            raise forms.ValidationError(ugettext('You are not sure enough!'))
            raise forms.ValidationError(gettext('You are not sure enough!'))
        if cd['revision'] != self.article.current_revision:
            raise forms.ValidationError(
                ugettext(
                gettext(
                    'While you tried to delete this article, it was modified. TAKE CARE!'))
        return cd



@@ 531,7 531,7 @@ class PermissionsForm(PluginSettingsFormMixin, forms.ModelForm):
                    user = User.objects.get(**kwargs)
                except User.DoesNotExist:
                    raise forms.ValidationError(
                        ugettext('No user with that username'))
                        gettext('No user with that username'))
            else:
                user = None
        else:

M src/wiki/models/article.py => src/wiki/models/article.py +1 -1
@@ 7,7 7,7 @@ from django.db.models.fields import GenericIPAddressField as IPAddressField
from django.db.models.signals import post_save, pre_delete, pre_save
from django.utils import translation
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from mptt.models import MPTTModel
from wiki import managers
from wiki.conf import settings

M src/wiki/models/pluginbase.py => src/wiki/models/pluginbase.py +1 -1
@@ 20,7 20,7 @@ There are three kinds of plugin base models:
"""
from django.db import models
from django.db.models import signals
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from wiki.decorators import disable_signal_for_loaddata

from .article import ArticleRevision, BaseRevisionMixin

M src/wiki/models/urlpath.py => src/wiki/models/urlpath.py +3 -3
@@ 9,8 9,8 @@ from django.core.urlresolvers import reverse
from django.db import models, transaction
from django.db.models.signals import post_save, pre_delete
# Django 1.6 transaction API, required for 1.8+
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext
from mptt.fields import TreeForeignKey
from mptt.models import MPTTModel
from wiki import managers


@@ 174,7 174,7 @@ class URLPath(MPTTModel):

    def __str__(self):
        path = self.path
        return path if path else ugettext("(root)")
        return path if path else gettext("(root)")

    def delete(self, *args, **kwargs):
        assert not (self.parent and self.get_children()

M src/wiki/plugins/attachments/apps.py => src/wiki/plugins/attachments/apps.py +1 -1
@@ 1,5 1,5 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class AttachmentsConfig(AppConfig):

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

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


@@ 101,7 101,7 @@ class AttachmentArchiveForm(AttachmentForm):
                    except IllegalFileExtension as e:
                        raise forms.ValidationError(e)
            except zipfile.BadZipfile:
                raise forms.ValidationError(ugettext("Not a zip file"))
                raise forms.ValidationError(gettext("Not a zip file"))
        else:
            return super().clean_file()
        return uploaded_file


@@ 110,7 110,7 @@ class AttachmentArchiveForm(AttachmentForm):
        super().clean()
        if not can_moderate(self.article, self.request.user):
            raise forms.ValidationError(
                ugettext("User not allowed to moderate this article"))
                gettext("User not allowed to moderate this article"))
        return self.cleaned_data

    def save(self, *args, **kwargs):


@@ 161,7 161,7 @@ class DeleteForm(forms.Form):

    def clean_confirm(self):
        if not self.cleaned_data['confirm']:
            raise forms.ValidationError(ugettext('You are not sure enough!'))
            raise forms.ValidationError(gettext('You are not sure enough!'))
        return True



M src/wiki/plugins/attachments/models.py => src/wiki/plugins/attachments/models.py +4 -4
@@ 3,8 3,8 @@ 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 ugettext_lazy as _
from django.utils.translation import ugettext
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext
from wiki import managers
from wiki.decorators import disable_signal_for_loaddata
from wiki.models.article import BaseRevisionMixin


@@ 65,12 65,12 @@ def extension_allowed(filename):
    except IndexError:
        # No extension
        raise IllegalFileExtension(
            ugettext("No file extension found in filename. That's not okay!"))
            gettext("No file extension found in filename. That's not okay!"))
    if not extension.lower() in map(
            lambda x: x.lower(),
            settings.FILE_EXTENSIONS):
        raise IllegalFileExtension(
            ugettext(
            gettext(
                "The following filename is illegal: {filename:s}. Extension "
                "has to be one of {extensions:s}"
            ).format(

M src/wiki/plugins/attachments/views.py => src/wiki/plugins/attachments/views.py +1 -1
@@ 4,7 4,7 @@ from django.db.models import Q
from django.http import Http404, HttpResponseRedirect
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.utils.translation import gettext as _
from django.views.generic.base import TemplateView, View
from django.views.generic.edit import FormView
from django.views.generic.list import ListView

M src/wiki/plugins/attachments/wiki_plugin.py => src/wiki/plugins/attachments/wiki_plugin.py +1 -1
@@ 1,5 1,5 @@
from django.conf.urls import include, url
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
from wiki.plugins.attachments import models, settings, views

M src/wiki/plugins/globalhistory/apps.py => src/wiki/plugins/globalhistory/apps.py +1 -1
@@ 1,5 1,5 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class GlobalHistoryConfig(AppConfig):

M src/wiki/plugins/help/apps.py => src/wiki/plugins/help/apps.py +1 -1
@@ 1,5 1,5 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class HelpConfig(AppConfig):

M src/wiki/plugins/help/wiki_plugin.py => src/wiki/plugins/help/wiki_plugin.py +1 -1
@@ 1,4 1,4 @@
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin


M src/wiki/plugins/images/apps.py => src/wiki/plugins/images/apps.py +1 -1
@@ 1,5 1,5 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class ImagesConfig(AppConfig):

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



@@ 14,7 14,7 @@ class SidebarForm(PluginSidebarFormMixin):
        self.fields['image'].required = True

    def get_usermessage(self):
        return ugettext(
        return gettext(
            "New image %s was successfully uploaded. You can use it by selecting it from the list of available images.") % self.instance.get_filename()

    def save(self, *args, **kwargs):


@@ 64,5 64,5 @@ class PurgeForm(forms.Form):
    def clean_confirm(self):
        confirm = self.cleaned_data['confirm']
        if not confirm:
            raise forms.ValidationError(ugettext('You are not sure enough!'))
            raise forms.ValidationError(gettext('You are not sure enough!'))
        return confirm

M src/wiki/plugins/images/models.py => src/wiki/plugins/images/models.py +5 -5
@@ 5,8 5,8 @@ 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 ugettext_lazy as _
from django.utils.translation import ugettext
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext
from wiki.models.pluginbase import RevisionPlugin, RevisionPluginRevision

from . import settings


@@ 48,9 48,9 @@ class Image(RevisionPlugin):

    def __str__(self):
        if self.current_revision:
            return ugettext('Image: %s') % self.current_revision.imagerevision.get_filename()
            return gettext('Image: %s') % self.current_revision.imagerevision.get_filename()
        else:
            return ugettext('Current revision not set!!')
            return gettext('Current revision not set!!')


class ImageRevision(RevisionPluginRevision):


@@ 108,7 108,7 @@ class ImageRevision(RevisionPluginRevision):
        ordering = ('-created',)

    def __str__(self):
        return ugettext('Image Revision: %d') % self.revision_number
        return gettext('Image Revision: %d') % self.revision_number


def on_image_revision_delete(instance, *args, **kwargs):

M src/wiki/plugins/images/views.py => src/wiki/plugins/images/views.py +1 -1
@@ 4,7 4,7 @@ from django.contrib import messages
from django.core.urlresolvers import reverse
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.utils.translation import gettext as _
from django.views.generic.base import RedirectView
from django.views.generic.edit import FormView
from django.views.generic.list import ListView

M src/wiki/plugins/images/wiki_plugin.py => src/wiki/plugins/images/wiki_plugin.py +1 -1
@@ 1,5 1,5 @@
from django.conf.urls import url
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
from wiki.plugins.images import forms, models, settings, views

M src/wiki/plugins/links/apps.py => src/wiki/plugins/links/apps.py +1 -1
@@ 1,5 1,5 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class LinksConfig(AppConfig):

M src/wiki/plugins/links/wiki_plugin.py => src/wiki/plugins/links/wiki_plugin.py +1 -1
@@ 1,6 1,6 @@
from django.conf.urls import url
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
from wiki.plugins.links import settings, views

M src/wiki/plugins/macros/apps.py => src/wiki/plugins/macros/apps.py +1 -1
@@ 1,5 1,5 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class MacrosConfig(AppConfig):

M src/wiki/plugins/macros/mdx/macro.py => src/wiki/plugins/macros/mdx/macro.py +1 -1
@@ 2,7 2,7 @@ import re

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


M src/wiki/plugins/macros/wiki_plugin.py => src/wiki/plugins/macros/wiki_plugin.py +1 -1
@@ 1,4 1,4 @@
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from wiki.core.plugins import registry
from wiki.core.plugins.base import BasePlugin
from wiki.plugins.macros import settings

M src/wiki/plugins/notifications/apps.py => src/wiki/plugins/notifications/apps.py +1 -1
@@ 1,5 1,5 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class NotificationsConfig(AppConfig):

M src/wiki/plugins/notifications/forms.py => src/wiki/plugins/notifications/forms.py +9 -9
@@ 2,8 2,8 @@ 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 ugettext_lazy as _
from django.utils.translation import ugettext
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext
from django_nyt.models import NotificationType, Settings, Subscription
from wiki.core.plugins.base import PluginSettingsFormMixin
from wiki.plugins.notifications import models


@@ 13,7 13,7 @@ from wiki.plugins.notifications.settings import ARTICLE_EDIT
class SettingsModelChoiceField(forms.ModelChoiceField):

    def label_from_instance(self, obj):
        return ugettext(
        return gettext(
            "Receive notifications %(interval)s"
        ) % {
            'interval': obj.get_interval_display()


@@ 24,7 24,7 @@ class ArticleSubscriptionModelMultipleChoiceField(
        forms.ModelMultipleChoiceField):

    def label_from_instance(self, obj):
        return ugettext("%(title)s - %(url)s") % {
        return gettext("%(title)s - %(url)s") % {
            'title': obj.article.current_revision.title,
            'url': obj.article.get_absolute_url()
        }


@@ 41,17 41,17 @@ class SettingsModelForm(forms.ModelForm):
            self.fields['delete_subscriptions'] = ArticleSubscriptionModelMultipleChoiceField(
                models.ArticleSubscription.objects.filter(
                    subscription__settings=instance),
                label=ugettext("Remove subscriptions"),
                label=gettext("Remove subscriptions"),
                required=False,
                help_text=ugettext("Select article subscriptions to remove from notifications"),
                help_text=gettext("Select article subscriptions to remove from notifications"),
                initial=models.ArticleSubscription.objects.none(),
            )
            self.fields['email'] = forms.TypedChoiceField(
                label=_("Email digests"),
                choices=(
                    (0, ugettext('Unchanged (selected on each article)')),
                    (1, ugettext('No emails')),
                    (2, ugettext('Email on any change')),
                    (0, gettext('Unchanged (selected on each article)')),
                    (1, gettext('No emails')),
                    (2, gettext('Email on any change')),
                ),
                coerce=lambda x: int(x) if x is not None else None,
                widget=forms.RadioSelect(),

M src/wiki/plugins/notifications/models.py => src/wiki/plugins/notifications/models.py +1 -1
@@ 1,7 1,7 @@
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models import signals
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django_nyt.models import Subscription
from django_nyt.utils import notify
from wiki import models as wiki_models

M src/wiki/plugins/notifications/util.py => src/wiki/plugins/notifications/util.py +1 -1
@@ 1,4 1,4 @@
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _


def get_title(article):

M src/wiki/plugins/notifications/views.py => src/wiki/plugins/notifications/views.py +1 -1
@@ 2,7 2,7 @@ from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.shortcuts import redirect
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.generic.edit import FormView

from . import forms, models

M src/wiki/views/accounts.py => src/wiki/views/accounts.py +1 -1
@@ 16,7 16,7 @@ from django.contrib.auth import logout as auth_logout
from django.contrib.auth.forms import AuthenticationForm
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.generic.base import View
from django.views.generic.edit import CreateView, FormView, UpdateView
from wiki import forms

M src/wiki/views/article.py => src/wiki/views/article.py +3 -3
@@ 9,8 9,8 @@ from django.db.models import Q
from django.http import Http404
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
from django.utils.translation import gettext as _
from django.utils.translation import ngettext
from django.views.generic.base import RedirectView, TemplateView, View
from django.views.generic.edit import FormView
from django.views.generic.list import ListView


@@ 488,7 488,7 @@ class Move(ArticleMixin, FormView):

            messages.success(
                self.request,
                ungettext(
                ngettext(
                    "Article successfully moved! Created {n} redirect.",
                    "Article successfully moved! Created {n} redirects.",
                    len(descendants)