Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

nav selection with apphooks works now

  • Loading branch information...
commit bc3158fe2664a915f515b566701d713a191bd290 1 parent 6967eea
@digi604 digi604 authored
Showing with 18 additions and 2 deletions.
  1. +7 −1 cms/models/__init__.py
  2. +8 −1 menus/base.py
  3. +3 −0  menus/menu_pool.py
View
8 cms/models/__init__.py
@@ -30,6 +30,12 @@ def validate_dependencies():
if not hasattr(VersionAdmin, 'get_urls'):
raise ImproperlyConfigured('django-cms requires never version of reversion (VersionAdmin must contain get_urls method)')
+def remove_current_root(url):
+ current_root = "/%s/" % get_language()
+ if url[:len(current_root)] == current_root:
+ url = url[len(current_root) - 1:]
+ return url
+
def monkeypatch_reverse():
django.core.urlresolvers.old_reverse = django.core.urlresolvers.reverse
@@ -50,11 +56,11 @@ def new_reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None, cur
lang = get_language()
ml_viewname = "%s:%s" % ( lang, viewname)
url = django.core.urlresolvers.old_reverse(ml_viewname, urlconf=urlconf, args=args, kwargs=kwargs, prefix=prefix, current_app=current_app)
- url = "/%s%s" % (lang, url)
return url
except NoReverseMatch:
pass
raise e
+ url = remove_current_root(url)
return url
django.core.urlresolvers.reverse = new_reverse
View
9 menus/base.py
@@ -1,4 +1,5 @@
from django.core.exceptions import ValidationError
+from django.utils.translation import get_language
class Menu(object):
@@ -32,7 +33,7 @@ class NavigationNode(object):
def __init__(self, title, url, id, parent_id=None, parent_namespace=None, attr=None):
self.children = [] # do not touch
self.title = title
- self.url = url
+ self.url = self._remove_current_root(url)
self.id = id
self.parent_id = parent_id
self.parent_namespace = parent_namespace
@@ -42,6 +43,12 @@ def __init__(self, title, url, id, parent_id=None, parent_namespace=None, attr=N
def __repr__(self):
return "<Navigation Node: %s>" % str(unicode(self.title))
+ def _remove_current_root(self, url):
+ current_root = "/%s/" % get_language()
+ if url[:len(current_root)] == current_root:
+ url = url[len(current_root) - 1:]
+ return url
+
def get_menu_title(self):
return self.title
View
3  menus/menu_pool.py
@@ -109,9 +109,12 @@ def _mark_selected(self, request, nodes):
node.ancestor = False
node.descendant = False
node.selected = False
+ print node.get_absolute_url()
+ print request.path[:len(node.get_absolute_url())]
if node.get_absolute_url() == request.path[:len(node.get_absolute_url())]:
if sel:
if len(node.get_absolute_url()) > len(sel.get_absolute_url()):
+ print "found"
sel = node
else:
sel = node
Please sign in to comment.
Something went wrong with that request. Please try again.