[checkmk-commits] Check_MK Git: check_mk: Moveing and deleting graphs in a collection

Mathias Kettner mk at mathias-kettner.de
Wed Apr 29 14:15:53 CEST 2015


Module: check_mk
Branch: master
Commit: a6901cf1ce7b37f04bb8b9ae72c6bf8e130a2a35
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a6901cf1ce7b37f04bb8b9ae72c6bf8e130a2a35

Author: Mathias Kettner <mk at mathias-kettner.de>
Date:   Tue Apr 28 14:04:04 2015 +0200

Moveing and deleting graphs in a collection

---

 web/htdocs/pagetypes.py |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/web/htdocs/pagetypes.py b/web/htdocs/pagetypes.py
index fe06056..3a30c68 100644
--- a/web/htdocs/pagetypes.py
+++ b/web/htdocs/pagetypes.py
@@ -204,6 +204,12 @@ class PageRenderer:
 #   |  Examples: views, dashboards, graphs collections                     |
 #   '----------------------------------------------------------------------'
 class Overridable:
+    def page_header(self):
+        header = self.type_title() + " - " + self.title()
+        if not self.is_mine():
+            header += " (%s)" % self.owner()
+        return header
+
     # Checks wether a page is publicly visible. This does not only need a flag
     # in the page itself, but also the permission from its owner to publish it.
     def is_public(self):
@@ -351,6 +357,8 @@ class Overridable:
         foreign = None
 
         for page in self.instances():
+            if page.name() != name:
+                continue
 
             if page.is_mine() and config.may("general.edit_" + self.type_name()):
                 mine = page
@@ -613,6 +621,11 @@ class Container(Overridable):
     def add_element(self, element):
         self._.setdefault("elements", []).append(element)
 
+    def move_element(self, nr, whither):
+        el = self._["elements"][nr]
+        del self._["elements"][nr]
+        self._["elements"][whither:whither] = [ el ]
+
     def is_empty(self):
         return not self.elements()
 
@@ -659,11 +672,13 @@ class Container(Overridable):
         if not page.is_mine():
             page = page.clone()
             if isinstance(page, PageRenderer) and not page.is_hidden():
-                need_sidebar_reload
+                need_sidebar_reload = True
 
         page.add_element(create_info) # can be overridden
         self.save_user_instances()
-        return page, need_sidebar_reload
+        return None, need_sidebar_reload
+        # With a redirect directly to the page afterwards do it like this:
+        # return page, need_sidebar_reload
 
 
 #.



More information about the checkmk-commits mailing list