Skip to content

Commit

Permalink
Exclude original model links with no admin_url
Browse files Browse the repository at this point in the history
This can happen, if user has no permissions for model at all,
in such case Django sometimes still provide model without an url
  • Loading branch information
darklow committed Feb 28, 2013
1 parent c2d881b commit 8027827
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion suit/templatetags/suit_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ def reorder_models(self, app, models_order):

# Append real model link
for model in self.all_models:
# Exclude models with no admin_url. This can happen, if user
# has no permissions, in such case Django sometimes provide
# model without an url
if 'admin_url' not in model:
continue

if model_name == self.get_model_name(model, '.' in model_name):
new_models.append(model)

Expand Down Expand Up @@ -195,7 +201,7 @@ def make_custom_link(self, link):
return

url = self.reverse_url(link[1])
return {'name': link[0], 'admin_url':url}
return {'name': link[0], 'admin_url': url}

def user_has_permission(self, perms):
perms = perms if isinstance(perms, (list, tuple)) else (perms,)
Expand Down

0 comments on commit 8027827

Please sign in to comment.