示例#1
0
 def show(self):
     group_type = self._group_type_ident()
     html.open_ul()
     for name, alias in sites.all_groups(group_type.replace("group", "")):
         url = "view.py?view_name=%s&%s=%s" % (group_type, group_type, urlencode(name))
         bulletlink(alias or name, url)
     html.close_ul()
示例#2
0
def hostgroup_autocompleter(value: str, params: Dict) -> Choices:
    """Return the matching list of dropdown choices
    Called by the webservice with the current input field value and the completions_params to get the list of choices"""

    return sorted(
        (v for v in sites.all_groups("host") if value.lower() in v[1].lower()),
        key=lambda a: a[1].lower(),
    )
示例#3
0
def hostgroup_autocompleter(value: str, params: Dict) -> Choices:
    """Return the matching list of dropdown choices
    Called by the webservice with the current input field value and the completions_params to get the list of choices"""
    group_type = params["group_type"]
    choices: Choices = sorted(
        (v for v in sites.all_groups(group_type)
         if value.lower() in v[1].lower()),
        key=lambda a: a[1].lower(),
    )
    # This part should not exists as the optional(not enforce) would better be not having the filter at all
    if not params.get("strict"):
        empty_choice: Choices = [("", "")]
        choices = empty_choice + choices
    return choices
示例#4
0
 def _load_groups(self):
     contact_group_choices = sites.all_groups("contact")
     return [(group_id, alias)
             for (group_id, alias) in contact_group_choices
             if self._with_foreign_groups or group_id in config.user.contact_groups]