From 40c071d9f5b5da6f8062a7963a580873f69a07ae Mon Sep 17 00:00:00 2001 From: Kenneth Love Date: Wed, 7 Aug 2013 10:00:34 -0700 Subject: [PATCH 1/2] should fix the unicode issues in python3 --- braces/views.py | 7 ++++--- setup.py | 2 +- tests/test_access_mixins.py | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/braces/views.py b/braces/views.py index 4af6dc3a..5d286c9c 100644 --- a/braces/views.py +++ b/braces/views.py @@ -1,3 +1,4 @@ +import six import warnings from django.conf import settings @@ -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 " @@ -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__) @@ -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__) diff --git a/setup.py b/setup.py index 5fc678ed..fe452615 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ license="BSD", packages=["braces"], zip_safe=False, - install_requires=[], + install_requires=['six'], include_package_data=True, classifiers=[ "Programming Language :: Python", diff --git a/tests/test_access_mixins.py b/tests/test_access_mixins.py index 1a6dbe1e..85116fcf 100644 --- a/tests/test_access_mixins.py +++ b/tests/test_access_mixins.py @@ -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 @@ -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)) + From b7095b7f222051e86d19fbfdbc9afd01b50dc8e9 Mon Sep 17 00:00:00 2001 From: Kenneth Love Date: Wed, 7 Aug 2013 10:04:02 -0700 Subject: [PATCH 2/2] version bump --- docs/conf.py | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 99ecc09a..b6cfcaa4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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. diff --git a/setup.py b/setup.py index fe452615..4267ee23 100644 --- a/setup.py +++ b/setup.py @@ -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",