Skip to content

Commit

Permalink
Fix null reference when user does not have perms
Browse files Browse the repository at this point in the history
  • Loading branch information
erik committed Nov 18, 2021
1 parent 2526f9b commit ce247b8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions suit/templatetags/suit_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_menu(context, request):
else:
try:
template_response = get_admin_site(context.current_app).index(request)
# Django 1.10 removed the current_app parameter for some classes and functions.
# Django 1.10 removed the current_app parameter for some classes and functions.
# Check the release notes.
except AttributeError:
template_response = get_admin_site(context.request.resolver_match.namespace).index(request)
Expand Down Expand Up @@ -340,7 +340,7 @@ def convert_native_model(self, model, app_name):
}

def get_native_model_url(self, model):
return model.get('admin_url') or model.get('add_url', '')
return model.get('admin_url') or model.get('add_url') or ''

def process_model(self, model, app_name):
if 'model' in model:
Expand Down

2 comments on commit ce247b8

@emilburzo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erik any idea why this fixed it? it seems like it should be the same thing?

@erik
Copy link
Author

@erik erik commented on ce247b8 Nov 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emilburzo because the model object in this case was {"add_url": None}, so None was returned, rather than ''

Please sign in to comment.