Module: check_mk
Branch: master
Commit: 113a67a15d40c5058c6a0fcf90a6a7aed12868fc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=113a67a15d40c5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Apr 10 11:34:02 2019 +0200
Improve readability: Handle non disk folder as early exit
Change-Id: I99b6ff4475e04af302139aa8685280ca652fe3c7
---
cmk/gui/wato/pages/folders.py | 91 +++++++++++++++++++++----------------------
1 file changed, 45 insertions(+), 46 deletions(-)
diff --git a/cmk/gui/wato/pages/folders.py b/cmk/gui/wato/pages/folders.py
index d095e39..03e1e8a 100644
--- a/cmk/gui/wato/pages/folders.py
+++ b/cmk/gui/wato/pages/folders.py
@@ -76,55 +76,54 @@ class ModeFolder(WatoMode):
def buttons(self):
global_buttons()
- if self._folder.is_disk_folder():
- if config.user.may("wato.rulesets") or
config.user.may("wato.seeall"):
- html.context_button(
- _("Rulesets"),
watolib.folder_preserving_link([("mode", "ruleeditor")]),
- "rulesets")
- html.context_button(
- _("Manual Checks"),
watolib.folder_preserving_link([("mode", "static_checks")]),
- "static_checks")
- if self._folder.may("read"):
- html.context_button(
- _("Folder Properties"),
self._folder.edit_url(backfolder=self._folder), "edit")
- if not self._folder.locked_subfolders() and config.user.may(
- "wato.manage_folders") and
self._folder.may("write"):
- html.context_button(
- _("New folder"), self._folder.url([("mode",
"newfolder")]), "newfolder")
- if not self._folder.locked_hosts() and config.user.may(
- "wato.manage_hosts") and
self._folder.may("write"):
- html.context_button(_("New host"),
self._folder.url([("mode", "newhost")]), "new")
- html.context_button(
- _("New cluster"), self._folder.url([("mode",
"newcluster")]), "new_cluster")
- html.context_button(
- _("Bulk import"), self._folder.url([("mode",
"bulk_import")]), "bulk_import")
- if config.user.may("wato.services"):
- html.context_button(
- _("Bulk discovery"), self._folder.url([("mode",
"bulkinventory"),
- ("all",
"1")]), "inventory")
- if config.user.may("wato.rename_hosts"):
- html.context_button(
- _("Bulk renaming"), self._folder.url([("mode",
"bulk_rename_host")]),
- "rename_host")
- if config.user.may("wato.custom_attributes"):
- html.context_button(
- _("Custom attributes"),
- watolib.folder_preserving_link([("mode",
"host_attrs")]), "custom_attr")
- if not self._folder.locked_hosts() and config.user.may(
- "wato.parentscan") and
self._folder.may("write"):
- html.context_button(
- _("Parent scan"), self._folder.url([("mode",
"parentscan"), ("all", "1")]),
- "parentscan")
- folder_status_button()
- if config.user.may("wato.random_hosts"):
- html.context_button(
- _("Random Hosts"), self._folder.url([("mode",
"random_hosts")]), "random")
- html.context_button(
- _("Search"), watolib.folder_preserving_link([("mode",
"search")]), "search")
- else:
+ if not self._folder.is_disk_folder():
html.context_button(_("Back"), self._folder.parent().url(),
"back")
html.context_button(
_("Refine Search"), self._folder.url([("mode",
"search")]), "search")
+ return
+
+ if config.user.may("wato.rulesets") or
config.user.may("wato.seeall"):
+ html.context_button(
+ _("Rulesets"),
watolib.folder_preserving_link([("mode", "ruleeditor")]),
"rulesets")
+ html.context_button(
+ _("Manual Checks"),
watolib.folder_preserving_link([("mode", "static_checks")]),
+ "static_checks")
+ if self._folder.may("read"):
+ html.context_button(
+ _("Folder Properties"),
self._folder.edit_url(backfolder=self._folder), "edit")
+ if not self._folder.locked_subfolders() and config.user.may(
+ "wato.manage_folders") and
self._folder.may("write"):
+ html.context_button(
+ _("New folder"), self._folder.url([("mode",
"newfolder")]), "newfolder")
+ if not self._folder.locked_hosts() and config.user.may(
+ "wato.manage_hosts") and self._folder.may("write"):
+ html.context_button(_("New host"),
self._folder.url([("mode", "newhost")]), "new")
+ html.context_button(
+ _("New cluster"), self._folder.url([("mode",
"newcluster")]), "new_cluster")
+ html.context_button(
+ _("Bulk import"), self._folder.url([("mode",
"bulk_import")]), "bulk_import")
+ if config.user.may("wato.services"):
+ html.context_button(
+ _("Bulk discovery"), self._folder.url([("mode",
"bulkinventory"), ("all", "1")]),
+ "inventory")
+ if config.user.may("wato.rename_hosts"):
+ html.context_button(
+ _("Bulk renaming"), self._folder.url([("mode",
"bulk_rename_host")]), "rename_host")
+ if config.user.may("wato.custom_attributes"):
+ html.context_button(
+ _("Custom attributes"),
watolib.folder_preserving_link([("mode", "host_attrs")]),
+ "custom_attr")
+ if not self._folder.locked_hosts() and config.user.may(
+ "wato.parentscan") and self._folder.may("write"):
+ html.context_button(
+ _("Parent scan"), self._folder.url([("mode",
"parentscan"), ("all", "1")]),
+ "parentscan")
+ folder_status_button()
+ if config.user.may("wato.random_hosts"):
+ html.context_button(
+ _("Random Hosts"), self._folder.url([("mode",
"random_hosts")]), "random")
+ html.context_button(
+ _("Search"), watolib.folder_preserving_link([("mode",
"search")]), "search")
def action(self):
if html.request.var("_search"): # just commit to search form