Exemplo n.º 1
0
def delete(params):
    """Delete a contact group"""
    user.need_permission("wato.edit")
    name = params["name"]
    check_modify_group_permissions("contact")
    with endpoint.do_not_track_permissions(), SuperUserContext():
        # HACK: We need to supress this, due to lots of irrelevant dashboard permissions
        delete_group(name, "contact")
    return Response(status=204)
Exemplo n.º 2
0
def bulk_delete(params):
    """Bulk delete service groups"""
    user.need_permission("wato.edit")
    body = params["body"]
    entries = body["entries"]
    for group_name in entries:
        _group = fetch_group(group_name,
                             "service",
                             status=400,
                             message="service group %s was not found" %
                             group_name)
    for group_name in entries:
        groups.delete_group(group_name, group_type="service")
    return Response(status=204)
Exemplo n.º 3
0
def bulk_delete(params):
    """Bulk delete contact groups"""
    body = params["body"]
    entries = body["entries"]
    for group_name in entries:
        _group = fetch_group(
            group_name,
            "contact",
            status=400,
            message=f"contact group {group_name} was not found",
        )
    with endpoint.do_not_track_permissions(), SuperUserContext():
        for group_name in entries:
            # We need to supress this, because a lot of dashboard permissions are checked for
            # various reasons.
            delete_group(group_name, "contact")
    return Response(status=204)
Exemplo n.º 4
0
    def action(self) -> ActionResult:
        if not transactions.check_transaction():
            return redirect(mode_url("%s_groups" % self.type_name))

        if request.var("_delete"):
            delname = request.get_ascii_input_mandatory("_delete")
            usages = groups.find_usages_of_group(delname, self.type_name)

            if usages:
                message = "<b>%s</b><br>%s:<ul>" % (
                    _("You cannot delete this %s group.") % self.type_name,
                    _("It is still in use by"),
                )
                for title, link in usages:
                    message += '<li><a href="%s">%s</a></li>\n' % (link, title)
                message += "</ul>"
                raise MKUserError(None, message)

            groups.delete_group(delname, self.type_name)
            self._groups = self._load_groups()

        return redirect(mode_url("%s_groups" % self.type_name))
Exemplo n.º 5
0
def with_groups(request_context, with_admin_login,
                suppress_remote_automation_calls):
    groups.add_group("windows", "host", {"alias": "windows"})
    groups.add_group("routers", "service", {"alias": "routers"})
    groups.add_group("admins", "contact", {"alias": "admins"})
    yield
    groups.delete_group("windows", "host")
    groups.delete_group("routers", "service")
    groups.delete_group("admins", "contact")
Exemplo n.º 6
0
def delete(params):
    """Delete a service group"""
    user.need_permission("wato.edit")
    name = params["name"]
    groups.delete_group(name, group_type="service")
    return Response(status=204)
Exemplo n.º 7
0
def delete(params):
    """Delete a host group"""
    user.need_permission("wato.edit")
    name = params["name"]
    groups.delete_group(name, "host")
    return Response(status=204)