def filter_matches(self, crit, value, hostname): value = convert_cgroups_from_tuple(value) # Just use the contact groups for searching for contact_group in crit["groups"]: if contact_group not in value["groups"]: return False return True
def paint(self, value, hostname): value = convert_cgroups_from_tuple(value) texts: List[HTML] = [] self.load_data() if self._contactgroups is None: # conditional caused by horrible API raise Exception("invalid contact groups") items = self._contactgroups.items() for name, cgroup in sorted(items, key=lambda x: x[1]["alias"]): if name in value["groups"]: display_name = cgroup.get("alias", name) texts.append( html.render_a( display_name, href=makeuri_contextless( request, [("mode", "edit_contact_group"), ("edit", name)], filename="wato.py", ), )) result: HTML = HTML(", ").join(texts) if texts and value["use"]: result += html.render_span( html.render_b("*"), title= _("These contact groups are also used in the monitoring configuration." ), ) return "", result
def render_input(self, varprefix, value): value = convert_cgroups_from_tuple(value) # If we're just editing a host, then some of the checkboxes will be missing. # This condition is not very clean, but there is no other way to savely determine # the context. is_host = bool( html.request.var("host")) or html.request.var("mode") == "newhost" is_search = varprefix == "host_search" # Only show contact groups I'm currently in and contact # groups already listed here. self.load_data() self._vs_contactgroups().render_input(varprefix + self.name(), value['groups']) html.hr() if is_host: html.checkbox(varprefix + self.name() + "_use", value["use"], label=_("Add these contact groups to the host")) elif not is_search: html.checkbox( varprefix + self.name() + "_recurse_perms", value["recurse_perms"], label=_( "Give these groups also <b>permission on all subfolders</b>" )) html.hr() html.checkbox( varprefix + self.name() + "_use", value["use"], label= _("Add these groups as <b>contacts</b> to all hosts <b>in this folder</b>" )) html.br() html.checkbox( varprefix + self.name() + "_recurse_use", value["recurse_use"], label= _("Add these groups as <b>contacts</b> to all hosts <b>in all subfolders of this folder</b>" )) html.hr() html.help( _("With this option contact groups that are added to hosts are always " "being added to services, as well. This only makes a difference if you have " "assigned other contact groups to services via rules in <i>Host & Service Parameters</i>. " "As long as you do not have any such rule a service always inherits all contact groups " "from its host.")) html.checkbox( varprefix + self.name() + "_use_for_services", value.get("use_for_services", False), label=_("Always add host contact groups also to its services") if is_host else _("Always add these groups as <b>contacts</b> to all services <b>in all subfolders of this folder</b>" ))
def paint(self, value, hostname): value = convert_cgroups_from_tuple(value) texts = [] self.load_data() items = self._contactgroups.items() for name, cgroup in sorted(items, key=lambda x: x[1]['alias']): if name in value["groups"]: display_name = cgroup.get("alias", name) texts.append('<a href="wato.py?mode=edit_contact_group&edit=%s">%s</a>' % (name, display_name)) result = ", ".join(texts) if texts and value["use"]: result += html.render_span( html.render_b("*"), title=_("These contact groups are also used in the monitoring configuration.")) return "", result