Skip to content

Commit 4162dc3

Browse files
committed
Merge pull request #66 from brack3t/fix/unicode_strings_py3k
Resolves #64
2 parents c50dec5 + b7095b7 commit 4162dc3

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

braces/views.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import six
12
import warnings
23

34
from django.conf import settings
@@ -284,7 +285,7 @@ class GroupRequiredMixin(AccessMixin):
284285
def get_group_required(self):
285286
if self.group_required is None or (
286287
not isinstance(self.group_required,
287-
(str, unicode, list, tuple))):
288+
(list, tuple) + six.string_types)):
288289

289290
raise ImproperlyConfigured(
290291
"'GroupRequiredMixin' requires "
@@ -626,7 +627,7 @@ def get_form_valid_message(self):
626627
'{0}.get_form_valid_message().'.format(self.__class__.__name__)
627628
)
628629

629-
if not isinstance(self.form_valid_message, (unicode, str)):
630+
if not isinstance(self.form_valid_message, six.string_types):
630631
raise ImproperlyConfigured(
631632
'{0}.form_valid_message must be a str or unicode '
632633
'object.'.format(self.__class__.__name__)
@@ -666,7 +667,7 @@ def get_form_invalid_message(self):
666667
self.__class__.__name__)
667668
)
668669

669-
if not isinstance(self.form_invalid_message, (unicode, str)):
670+
if not isinstance(self.form_invalid_message, six.string_types):
670671
raise ImproperlyConfigured(
671672
'{0}.form_invalid_message must be a str or unicode '
672673
'object.'.format(self.__class__.__name__)

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
# built documents.
4949
#
5050
# The short X.Y version.
51-
version = '1.2.1'
51+
version = '1.2.2'
5252
# The full version, including alpha/beta/rc tags.
53-
release = '1.2.1'
53+
release = '1.2.2'
5454

5555
# The language for content autogenerated by Sphinx. Refer to documentation
5656
# for a list of supported languages.

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="django-braces",
5-
version="1.2.1",
5+
version="1.2.2",
66
description="Reusable, generic mixins for Django",
77
long_description="Mixins to add easy functionality to Django class-based views, forms, and models.",
88
keywords="django, views, forms, mixins",
@@ -12,7 +12,7 @@
1212
license="BSD",
1313
packages=["braces"],
1414
zip_safe=False,
15-
install_requires=[],
15+
install_requires=['six'],
1616
include_package_data=True,
1717
classifiers=[
1818
"Programming Language :: Python",

tests/test_access_mixins.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from django import test
23
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
34
from django.core.urlresolvers import reverse_lazy
@@ -310,3 +311,16 @@ def test_improperly_configured(self):
310311
with self.assertRaises(ImproperlyConfigured):
311312
view.get_group_required()
312313

314+
def test_with_unicode(self):
315+
view = self.view_class()
316+
view.group_required = u'niño'
317+
318+
user = self.build_authorized_user()
319+
user.groups.all()[0].name = u'niño'
320+
user.groups.all()[0].save()
321+
322+
self.client.login(username=user.username, password='asdf1234')
323+
resp = self.client.get(self.view_url)
324+
self.assertEqual(200, resp.status_code)
325+
self.assertEqual('OK', force_text(resp.content))
326+

0 commit comments

Comments
 (0)