commands and snapins alphabetically
Message-ID: <5328794c.mIG36oJfbTKWeaNe%mk(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: a330e69ca0328abc9373296c839b9dc957c2c2be
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a330e69ca0328a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Mar 18 17:50:11 2014 +0100
Sort permissions of views, dashboards, commands and snapins alphabetically
---
.werks/717 | 8 ++++++++
ChangeLog | 1 +
web/htdocs/config.py | 4 ++--
web/htdocs/dashboard.py | 2 +-
web/htdocs/sidebar.py | 2 +-
web/htdocs/views.py | 4 ++--
web/htdocs/wato.py | 16 ++++++++++++----
7 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/.werks/717 b/.werks/717
new file mode 100644
index 0000000..5700a31
--- /dev/null
+++ b/.werks/717
@@ -0,0 +1,8 @@
+Title: Sort permissions of views, dashboards, commands and snapins alphabetically
+Level: 1
+Component: wato
+Version: 1.2.5i1
+Date: 1395161390
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index fb51ebc..d8e0ed3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -277,6 +277,7 @@
* 0687 New summary pages with all settings of a host or service...
* 0275 WATO "Notify Users" feature: Improved confirmation info...
* 0134 New option to use expect string in response heads for check_http in wato...
+ * 0717 Sort permissions of views, dashboards, commands and snapins alphabetically
* 0057 FIX: Fix exception in WATO host editor on custom tag without topic...
* 0241 FIX: Improved sorting of WATO folders in dropdown menu...
* 0019 FIX: Fixed wording in WATO rule for MSSQL check
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index 713e132..8ff45dd 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -179,10 +179,10 @@ def declare_permission(name, title, description, defaults):
permissions_by_name[name] = perm
-def declare_permission_section(name, title, prio = 0):
+def declare_permission_section(name, title, prio = 0, do_sort = False):
# Prio can be a number which is used for sorting. Higher numbers will
# be listed first, e.g. in the edit dialogs
- permission_sections[name] = (prio, title)
+ permission_sections[name] = (prio, title, do_sort)
# Compute permissions for HTTP user and set in
# global variables. Also store user.
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index 34e1c77..e58aed6 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -77,7 +77,7 @@ def load_plugins():
dashboards = builtin_dashboards
# Declare permissions for all dashboards
- config.declare_permission_section("dashboard", _("Dashboards"))
+ config.declare_permission_section("dashboard", _("Dashboards"),
do_sort = True)
for name, dashboard in dashboards.items():
config.declare_permission("dashboard.%s" % name,
dashboard["title"],
diff --git a/web/htdocs/sidebar.py b/web/htdocs/sidebar.py
index 7915376..dcb3104 100644
--- a/web/htdocs/sidebar.py
+++ b/web/htdocs/sidebar.py
@@ -55,7 +55,7 @@ def load_plugins():
loaded_with_language = current_language
# Declare permissions: each snapin creates one permission
- config.declare_permission_section("sidesnap", _("Sidebar
snapins"))
+ config.declare_permission_section("sidesnap", _("Sidebar
snapins"), do_sort = True)
for name, snapin in sidebar_snapins.items():
config.declare_permission("sidesnap.%s" % name,
snapin["title"],
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 1440bd1..053798f 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -62,7 +62,7 @@ def load_plugins():
global view_hooks ; view_hooks = {}
global inventory_displayhints ; inventory_displayhints = {}
- config.declare_permission_section("action", _("Commands on host and
services"))
+ config.declare_permission_section("action", _("Commands on host and
services"), do_sort = True)
load_web_plugins("views", globals())
@@ -72,7 +72,7 @@ def load_plugins():
loaded_with_language = current_language
# Declare permissions for builtin views
- config.declare_permission_section("view", _("Builtin views"))
+ config.declare_permission_section("view", _("Builtin views"),
do_sort = True)
for name, view in multisite_builtin_views.items():
config.declare_permission("view.%s" % name,
view["title"],
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index bc9cf2f..4de2be2 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -11301,12 +11301,16 @@ def mode_edit_role(phase):
"permissions that are on default will reflect the new base role."))
# Loop all permission sections, but sorted plz
- for section, (prio, section_title) in sorted(config.permission_sections.iteritems(),
+ for section, (prio, section_title, do_sort) in
sorted(config.permission_sections.iteritems(),
key = lambda x: x[1][0], reverse =
True):
forms.header(section_title, False)
# Loop all permissions
- for perm in config.permissions_by_order:
+ permlist = config.permissions_by_order[:]
+ if do_sort:
+ permlist.sort(cmp = lambda a,b: cmp(a["title"],
b["title"]))
+
+ for perm in permlist:
pname = perm["name"]
this_section = pname.split(".")[0]
if section != this_section:
@@ -11390,7 +11394,7 @@ def mode_role_matrix(phase):
# Loop all permission sections, but sorted plz
odd = "even"
- for section, (prio, section_title) in sorted(config.permission_sections.iteritems(),
+ for section, (prio, section_title, do_sort) in
sorted(config.permission_sections.iteritems(),
key = lambda x: x[1][0], reverse =
True):
html.write('<tr>')
@@ -11398,7 +11402,11 @@ def mode_role_matrix(phase):
html.write('</tr>')
# Loop all permissions
- for perm in config.permissions_by_order:
+ permlist = config.permissions_by_order[:]
+ if do_sort:
+ permlist.sort(cmp = lambda a,b: cmp(a["title"],
b["title"]))
+
+ for perm in permlist:
pname = perm["name"]
this_section = pname.split(".")[0]
if section != this_section: