Browse Source

replaced all gettext functions with their unicode counterparts

Rafał Pitoń 8 years ago
parent
commit
4108aa6233

+ 1 - 1
misago/core/templatetags/misago_pagetitle.py

@@ -1,5 +1,5 @@
 from django import template
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 
 register = template.Library()

+ 1 - 1
misago/legal/views.py

@@ -3,7 +3,7 @@ from hashlib import md5
 from django.http import Http404
 from django.shortcuts import redirect, render
 from django.utils.encoding import force_bytes
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 from misago.conf import settings
 from misago.core.cache import cache

+ 1 - 1
misago/markup/finalise.py

@@ -2,7 +2,7 @@ from __future__ import unicode_literals
 
 import re
 
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 
 HEADER_RE = re.compile(

+ 1 - 1
misago/threads/api/attachments.py

@@ -3,7 +3,7 @@ from rest_framework.response import Response
 
 from django.core.exceptions import PermissionDenied, ValidationError
 from django.template.defaultfilters import filesizeformat
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 from misago.acl import add_acl
 from misago.threads.models import Attachment, AttachmentType

+ 1 - 1
misago/threads/api/pollvotecreateendpoint.py

@@ -4,7 +4,7 @@ from rest_framework.response import Response
 
 from django.core.exceptions import ValidationError
 from django.utils import six
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 from django.utils.translation import ungettext
 
 from misago.acl import add_acl

+ 1 - 1
misago/threads/api/postendpoints/patch_event.py

@@ -1,5 +1,5 @@
 from django.core.exceptions import PermissionDenied
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 from misago.acl import add_acl
 from misago.core.apipatch import ApiPatch

+ 1 - 1
misago/threads/api/postendpoints/patch_post.py

@@ -1,5 +1,5 @@
 from django.core.exceptions import PermissionDenied
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 from misago.acl import add_acl
 from misago.core.apipatch import ApiPatch

+ 1 - 1
misago/threads/api/threadendpoints/editor.py

@@ -1,7 +1,7 @@
 from rest_framework.response import Response
 
 from django.core.exceptions import PermissionDenied
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 from misago.acl import add_acl
 from misago.categories import THREADS_ROOT_NAME

+ 1 - 1
misago/threads/api/threadendpoints/merge.py

@@ -2,7 +2,7 @@ from rest_framework.response import Response
 
 from django.core.exceptions import PermissionDenied
 from django.http import Http404
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 from django.utils.translation import ungettext
 
 from misago.acl import add_acl

+ 1 - 1
misago/threads/api/threadendpoints/patch.py

@@ -2,7 +2,7 @@ from django.contrib.auth import get_user_model
 from django.core.exceptions import PermissionDenied, ValidationError
 from django.shortcuts import get_object_or_404
 from django.utils import six
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 from misago.acl import add_acl
 from misago.categories.models import Category

+ 1 - 1
misago/threads/api/threadendpoints/pollmergehandler.py

@@ -1,4 +1,4 @@
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 from misago.threads.models import Poll
 

+ 1 - 1
misago/threads/api/threadpoll.py

@@ -5,7 +5,7 @@ from rest_framework.response import Response
 from django.core.exceptions import PermissionDenied
 from django.db import transaction
 from django.http import Http404
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 from misago.acl import add_acl
 from misago.core.shortcuts import get_int_or_404

+ 1 - 1
misago/threads/api/threads.py

@@ -4,7 +4,7 @@ from rest_framework.response import Response
 
 from django.core.exceptions import PermissionDenied
 from django.db import transaction
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 from misago.categories import PRIVATE_THREADS_ROOT_NAME, THREADS_ROOT_NAME
 from misago.core.shortcuts import get_int_or_404

+ 1 - 1
misago/threads/serializers/moderation.py

@@ -1,7 +1,7 @@
 from rest_framework import serializers
 
 from django.core.exceptions import ValidationError
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 from misago.acl import add_acl
 from misago.threads.models import Thread

+ 3 - 3
misago/threads/templatetags/misago_poststags.py

@@ -1,8 +1,8 @@
 from __future__ import unicode_literals
 
 from django import template
-from django.utils.translation import gettext as _
-from django.utils.translation import ngettext
+from django.utils.translation import ugettext as _
+from django.utils.translation import ungettext
 
 
 register = template.Library()
@@ -30,7 +30,7 @@ def likes_label(post):
 
     formats = {'users': usernames_string, 'likes': hidden_likes}
 
-    return ngettext(
+    return ungettext(
         "%(users)s and %(likes)s other user like this.",
         "%(users)s and %(likes)s other users like this.",
         hidden_likes,

+ 56 - 0
misago/threads/tests/test_threadview.py

@@ -1,7 +1,9 @@
+# -*- coding: utf-8 -*-
 from misago.acl.testutils import override_acl
 from misago.categories.models import Category
 from misago.conf import settings
 from misago.threads import testutils
+from misago.threads.checksums import update_post_checksum
 from misago.threads.events import record_event
 from misago.threads.moderation import threads as threads_moderation
 from misago.threads.moderation import hide_post
@@ -521,3 +523,57 @@ class ThreadAnonViewTests(ThreadViewTestCase):
         self.assertContains(response, post.get_absolute_url())
         self.assertNotContains(response, hidden_event.get_absolute_url())
         self.assertNotContains(response, unapproved_post.get_absolute_url())
+
+
+class ThreadUnicodeSupportTests(ThreadViewTestCase):
+    def test_category_name(self):
+        """unicode in category name causes no showstopper"""
+        self.category.name = u'Łódź'
+        self.category.slug = 'Lodz'
+
+        self.category.save()
+
+        self.override_acl()
+
+        response = self.client.get(self.thread.get_absolute_url())
+        self.assertEqual(response.status_code, 200)
+
+    def test_thread_title(self):
+        """unicode in thread title causes no showstopper"""
+        self.thread.title = u'Łódź'
+        self.thread.slug = 'Lodz'
+
+        self.thread.save()
+
+        self.override_acl()
+
+        response = self.client.get(self.thread.get_absolute_url())
+        self.assertEqual(response.status_code, 200)
+
+    def test_post_content(self):
+        """unicode in thread title causes no showstopper"""
+        self.thread.first_post.original = u'Łódź'
+        self.thread.first_post.parsed = u'<p>Łódź</p>'
+
+        update_post_checksum(self.thread.first_post)
+
+        self.thread.first_post.save()
+
+        self.override_acl()
+
+        response = self.client.get(self.thread.get_absolute_url())
+        self.assertEqual(response.status_code, 200)
+
+    def test_user_rank(self):
+        """unicode in user rank causes no showstopper"""
+        self.user.title = u'Łódź'
+        self.user.rank.name = u'Łódź'
+        self.user.rank.title = u'Łódź'
+
+        self.user.rank.save()
+        self.user.save()
+
+        self.override_acl()
+
+        response = self.client.get(self.thread.get_absolute_url())
+        self.assertEqual(response.status_code, 200)

+ 1 - 1
misago/threads/viewmodels/thread.py

@@ -1,5 +1,5 @@
 from django.shortcuts import get_object_or_404
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 from misago.acl import add_acl
 from misago.categories import PRIVATE_THREADS_ROOT_NAME, THREADS_ROOT_NAME

+ 1 - 1
misago/users/decorators.py

@@ -1,5 +1,5 @@
 from django.core.exceptions import PermissionDenied
-from django.utils.translation import gettext as _
+from django.utils.translation import ugettext as _
 
 from misago.core.exceptions import Banned