Пример #1
0
    def get(self, request, *args, **kwargs):
        plugins_render = []

        plugins = PluginInfo.objects()
        for plugin in plugins:
            new_params = []
            params = ParamInfo.objects(plugin_name=plugin.plugin_name)
            for param in params:
                new_params.append({
                    'name': param.param_name,
                    'description': param.description,
                })
            plugins_render.append({
                'name': plugin.plugin_name,
                'description': plugin.description,
                'params_info': new_params
            })
        return render(request, self.template_name, {'plugins': plugins_render})
Пример #2
0
        return mark_safe('\n'.join(output))

    def __init__(self, attrs=None, **kwargs):
        self.kwargs = kwargs
        if attrs is not None:
            self.attrs = attrs.copy()
        else:
            self.attrs = {}


NODES_LIST = [(item.node_name, item.node_name) for item in NodeInfo.objects()]

ATTRS = {'class': 'form-control'}

PLUGINS_LIST = [(item.plugin_name, item.plugin_name) for item in
                PluginInfo.objects()]

GROUPS_LIST = [(item.name, item.name) for item in NodeGroups.objects()]


class CheckboxSelectMultiple(forms.CheckboxSelectMultiple):
    def render(self, name, value, attrs=None, choices=()):
        html = super(CheckboxSelectMultiple, self).render(name, value, attrs,
                                                          choices)

        return mark_safe(html.replace('<ul>', '<ul class="myClass">'))


class MonitoringSettingsForm(forms.Form):
    operation = forms.ChoiceField(choices=MONITORING_SETTINGS_OPERATIONS,
                                  widget=forms.Select(attrs=ATTRS),