Skip to content

Commit f6a7275

Browse files
author
Michael Angeletti
committed
Added setting check to allow for non-registration
1 parent 13e9bde commit f6a7275

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

active_menu/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from active_menu.utils import isactive, menu_item
22

33

4-
VERSION = (0, 9, 3)
4+
VERSION = (0, 9, 4)

active_menu/menu.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from django.conf import settings
2+
from django.core.urlresolvers import resolve
3+
4+
15
class MenuItem(object):
26
"""
37
A menu item representing a named URL and an optional parent menu item.
@@ -73,13 +77,20 @@ def isactive(self, request, view_name):
7377
Returns whether the menu item represented by the provided view name or
7478
any of its parent menu items represent the provided request's view.
7579
"""
80+
# Resolve the request
81+
resolver_match = resolve(request.path_info)
82+
7683
# Get the provided request's view name
77-
request_view_name = request.resolver_match.view_name
84+
request_view_name = resolver_match.view_name
7885

7986
# Return True, if the view name matches the request's view name
8087
if view_name == request_view_name:
8188
return True
8289

90+
# Check whether to use registration (defaulting to True)
91+
if not getattr(settings, 'ACTIVE_MENU_USE_REGISTRATION', True):
92+
return False # Short circuit, registration not used
93+
8394
# Get the menu item for the provided view name
8495
menu_item = self.get_item(view_name)
8596

0 commit comments

Comments
 (0)