Skip to content

Commit

Permalink
Merge pull request #66 from brack3t/fix/unicode_strings_py3k
Browse files Browse the repository at this point in the history
Resolves #64
  • Loading branch information
kennethlove committed Aug 7, 2013
2 parents c50dec5 + b7095b7 commit 4162dc3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
7 changes: 4 additions & 3 deletions braces/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import six
import warnings

from django.conf import settings
Expand Down Expand Up @@ -284,7 +285,7 @@ class GroupRequiredMixin(AccessMixin):
def get_group_required(self):
if self.group_required is None or (
not isinstance(self.group_required,
(str, unicode, list, tuple))):
(list, tuple) + six.string_types)):

raise ImproperlyConfigured(
"'GroupRequiredMixin' requires "
Expand Down Expand Up @@ -626,7 +627,7 @@ def get_form_valid_message(self):
'{0}.get_form_valid_message().'.format(self.__class__.__name__)
)

if not isinstance(self.form_valid_message, (unicode, str)):
if not isinstance(self.form_valid_message, six.string_types):
raise ImproperlyConfigured(
'{0}.form_valid_message must be a str or unicode '
'object.'.format(self.__class__.__name__)
Expand Down Expand Up @@ -666,7 +667,7 @@ def get_form_invalid_message(self):
self.__class__.__name__)
)

if not isinstance(self.form_invalid_message, (unicode, str)):
if not isinstance(self.form_invalid_message, six.string_types):
raise ImproperlyConfigured(
'{0}.form_invalid_message must be a str or unicode '
'object.'.format(self.__class__.__name__)
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
# built documents.
#
# The short X.Y version.
version = '1.2.1'
version = '1.2.2'
# The full version, including alpha/beta/rc tags.
release = '1.2.1'
release = '1.2.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="django-braces",
version="1.2.1",
version="1.2.2",
description="Reusable, generic mixins for Django",
long_description="Mixins to add easy functionality to Django class-based views, forms, and models.",
keywords="django, views, forms, mixins",
Expand All @@ -12,7 +12,7 @@
license="BSD",
packages=["braces"],
zip_safe=False,
install_requires=[],
install_requires=['six'],
include_package_data=True,
classifiers=[
"Programming Language :: Python",
Expand Down
14 changes: 14 additions & 0 deletions tests/test_access_mixins.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from django import test
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
from django.core.urlresolvers import reverse_lazy
Expand Down Expand Up @@ -310,3 +311,16 @@ def test_improperly_configured(self):
with self.assertRaises(ImproperlyConfigured):
view.get_group_required()

def test_with_unicode(self):
view = self.view_class()
view.group_required = u'niño'

user = self.build_authorized_user()
user.groups.all()[0].name = u'niño'
user.groups.all()[0].save()

self.client.login(username=user.username, password='asdf1234')
resp = self.client.get(self.view_url)
self.assertEqual(200, resp.status_code)
self.assertEqual('OK', force_text(resp.content))

0 comments on commit 4162dc3

Please sign in to comment.