Module: check_mk
Branch: master
Commit: 748738b9687edc73b2fd825372499719104dbb72
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=748738b9687edc…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Feb 8 18:02:54 2018 +0100
adapted visual linking logic to pagetypes
Change-Id: Ia81264e76e28afce3542ecee191e88132fe25404
---
web/htdocs/pagetypes.py | 20 +++++++++++++++++++-
web/htdocs/visuals.py | 6 +-----
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/web/htdocs/pagetypes.py b/web/htdocs/pagetypes.py
index b706c53..32f77a9 100644
--- a/web/htdocs/pagetypes.py
+++ b/web/htdocs/pagetypes.py
@@ -390,12 +390,30 @@ class PageRenderer(Base):
def render_title(self):
- if not self.is_hidden():
+ if self._can_be_linked():
return html.render_a(self.title(), href=self.page_url())
else:
return self.title()
+ def _can_be_linked(self):
+ """Whether or not the thing can be linked to"""
+ if self.is_hidden():
+ return False # don't link to hidden things
+
+ if self.is_mine():
+ return True
+
+ # Is this the visual which would be shown to the user in case the user
+ # requests a visual with the current name?
+ page = self.find_page(self.name())
+ if page.owner() != self.owner():
+ return False
+
+ return self.is_public()
+
+
+
#.
# .--Overridable---------------------------------------------------------.
# | ___ _ _ _ _ |
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index 9d9730f..31a6485 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -25,11 +25,7 @@
# Boston, MA 02110-1301 USA.
import os, copy, sys
-
-try:
- import simplejson as json
-except ImportError:
- import json
+import json
from lib import *
from valuespec import *