fnp
/
prawokultury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
show publication date for publications
[prawokultury.git]
/
menu
/
helpers.py
diff --git
a/menu/helpers.py
b/menu/helpers.py
index
15d8646
..
3cf305b
100755
(executable)
--- a/
menu/helpers.py
+++ b/
menu/helpers.py
@@
-1,21
+1,30
@@
+from django.utils.translation import get_language
+
+
class MenuItem(object):
html_id = None
class InvalidMenuItem(BaseException):
pass
class MenuItem(object):
html_id = None
class InvalidMenuItem(BaseException):
pass
- def __init__(self, url, title, html_id=None, more_urls=None):
+ def __init__(self, url, title, html_id=None, more_urls=None
, langs=None
):
self.url = url
self.title = title
self.html_id = html_id
self.more_urls = more_urls or set()
self.url = url
self.title = title
self.html_id = html_id
self.more_urls = more_urls or set()
+ self.langs = langs
def is_valid(self):
def is_valid(self):
- return
True
+ return
not (self.langs and get_language() not in self.langs)
def is_active(self, request, value):
url = request.get_full_path()
def is_active(self, request, value):
url = request.get_full_path()
- return url == str(self.url) or url in set(str(url) for url in self.more_urls)
+ if url.startswith(str(self.url)):
+ return True
+ for other_url in self.more_urls:
+ if url.startswith(str(other_url)):
+ return True
+ return False
def check_active(self, request, value):
try:
def check_active(self, request, value):
try:
@@
-57,9
+66,11
@@
class ObjectMenuItem(MenuItem):
return self.url or self.get_object().get_absolute_url()
def is_valid(self):
return self.url or self.get_object().get_absolute_url()
def is_valid(self):
+ if not super(ObjectMenuItem, self).is_valid():
+ return False
try:
try:
-
obj =
self.get_object()
- except self.InvalidMenuItem
, e
:
+ self.get_object()
+ except self.InvalidMenuItem:
return False
return True
return False
return True