Module: check_mk
Branch: master
Commit: b2b4360fd4381e816c9c8f0212b1f88ae7c1f027
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b2b4360fd4381e…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Apr 7 17:23:32 2016 +0200
3375 FIX Fixed exception when adding a bookmark while having a list not named
my_bookmarks
---
.werks/3375 | 10 ++++++++++
ChangeLog | 1 +
web/plugins/sidebar/shipped.py | 34 +++++++++++++++++++++++-----------
3 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/.werks/3375 b/.werks/3375
new file mode 100644
index 0000000..658dcad
--- /dev/null
+++ b/.werks/3375
@@ -0,0 +1,10 @@
+Title: Fixed exception when adding a bookmark while having a list not named my_bookmarks
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1460042581
+
+
diff --git a/ChangeLog b/ChangeLog
index 555a0e2..04251ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -181,6 +181,7 @@
* 3327 FIX: Disallow scheduling downtimes with an end date that is before the start
date
* 3373 FIX: Fixed exception when handling syntax errors while loading pagetype files
* 3374 FIX: Fixed broken Logwatch page when a host has no log directory (yet)
+ * 3375 FIX: Fixed exception when adding a bookmark while having a list not named
my_bookmarks
WATO:
* 3244 WATO BI Module: swap order of aggregation function and child node
selection...
diff --git a/web/plugins/sidebar/shipped.py b/web/plugins/sidebar/shipped.py
index a29230a..9adaf88 100644
--- a/web/plugins/sidebar/shipped.py
+++ b/web/plugins/sidebar/shipped.py
@@ -1163,6 +1163,21 @@ class BookmarkList(pagetypes.Overridable):
@classmethod
+ def add_default_bookmark_list(cls):
+ attrs = {
+ "title" : u"My Bookmarks",
+ "public" : False,
+ "owner" : config.user_id,
+ "name" : "my_bookmarks",
+ "description" : u"Your personal bookmarks",
+ "default_topic" : u"My Bookmarks",
+ "bookmarks" : [],
+ }
+
+ cls.add_instance((config.user_id, "my_bookmarks"), cls(attrs))
+
+
+ @classmethod
def load_legacy_bookmarks(self):
# Don't load the legacy bookmarks when there is already a my_bookmarks list
if self.has_instance((config.user_id, "my_bookmarks")):
@@ -1173,20 +1188,12 @@ class BookmarkList(pagetypes.Overridable):
if user_id == config.user_id:
return
- bookmark_list = {
- "title" : u"My Bookmarks",
- "public" : False,
- "owner" : config.user_id,
- "name" : "my_bookmarks",
- "description" : u"Your personal bookmarks",
- "default_topic" : u"My Bookmarks",
- "bookmarks" : [],
- }
+ self.add_default_bookmark_list()
+ bookmark_list = self.instance((config.user_id, "my_bookmarks"))
for title, url in load_legacy_bookmarks():
- bookmark_list["bookmarks"].append(self.new_bookmark(title, url))
+ bookmark_list.add_bookmark(title, url)
- self.add_instance((config.user_id, "my_bookmarks"),
self(bookmark_list))
@classmethod
def new_bookmark(self, title, url):
@@ -1209,6 +1216,7 @@ class BookmarkList(pagetypes.Overridable):
topic.append(bookmark)
return sorted(topics.items())
+
def add_bookmark(self, title, url):
self._["bookmarks"].append(BookmarkList.new_bookmark(title, url))
@@ -1310,6 +1318,10 @@ def try_shorten_url(url):
def add_bookmark(title, url):
BookmarkList.load()
+
+ if not BookmarkList.has_instance((config.user_id, "my_bookmarks")):
+ BookmarkList.add_default_bookmark_list()
+
bookmarks = BookmarkList.instance((config.user_id, "my_bookmarks"))
bookmarks.add_bookmark(title, try_shorten_url(url))
bookmarks.save_user_instances()