Skip to content
Open
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
17 changes: 9 additions & 8 deletions admin_shortcuts/templatetags/admin_shortcuts_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ def eval_func(func_path, request):
result = getattr(module, func_str)
if callable(result):
args, varargs, keywords, defaults = inspect.getargspec(result)
if 'request' in args:
result = result(request)
else:
result = result()
result = result(request) if 'request' in args else result()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function eval_func refactored with the following changes:

return result
except:
return func_path
Expand All @@ -97,10 +94,14 @@ def admin_static_url():
def get_shortcut_class(url):
if url == '/':
return 'home'
for key, value in CLASS_MAPPINGS:
if key is not None and key in url:
return value
return 'config' # default icon
return next(
(
value
for key, value in CLASS_MAPPINGS
if key is not None and key in url
),
'config',
)
Comment on lines -100 to +104

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function get_shortcut_class refactored with the following changes:

  • Use the built-in function next instead of a for-loop (use-next)

This removes the following comments ( why? ):

# default icon



CLASS_MAPPINGS = getattr(settings, 'ADMIN_SHORTCUTS_CLASS_MAPPINGS', [
Expand Down