Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed exception when menu config is Unicode #206

Merged
merged 2 commits into from
Mar 11, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions suit/templatetags/suit_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
from django.contrib.admin import AdminSite
from django.core.handlers.wsgi import WSGIRequest
from django.core.urlresolvers import reverse, resolve

try:
from django.utils.six import string_types
except ImportError:
# For Django < 1.4.2
string_types = basestring,

import warnings
from suit.config import get_config

Expand Down Expand Up @@ -107,7 +114,7 @@ def make_menu(self, config):
def make_app(self, app_def):
if isinstance(app_def, dict):
app = app_def.copy()
elif isinstance(app_def, str):
elif isinstance(app_def, string_types):
if app_def == '-':
app = self.make_separator()
else:
Expand Down Expand Up @@ -246,7 +253,7 @@ def process_models(self, app):
def make_model(self, model_def, app_name):
if isinstance(model_def, dict):
model = model_def.copy()
elif isinstance(model_def, str):
elif isinstance(model_def, string_types):
model = self.make_model_from_native(model_def, app_name)
else:
raise TypeError('MENU list item must be string or dict. Got %s'
Expand Down Expand Up @@ -447,7 +454,7 @@ def make_menu_from_old_format(self, conf_order):
if isinstance(order, (tuple, list)):
app_name = order[0]
models_order = order[1] if len(order) > 1 else None
if isinstance(app_name, str):
if isinstance(app_name, string_types):
new_app['app'] = app_name
elif isinstance(app_name, (tuple, list)):
mapping = ('label', 'url', 'icon', 'permissions')
Expand All @@ -456,7 +463,7 @@ def make_menu_from_old_format(self, conf_order):
if models_order and isinstance(models_order, (tuple, list)):
models = []
for model in models_order:
if isinstance(model, str):
if isinstance(model, string_types):
models.append({'model': model})
elif isinstance(model, (list, tuple)):
mapping = ('label', 'url', 'permissions')
Expand Down