Ejemplo n.º 1
0
def showApplGroupMembers(name, url_back):
    """
    show application-site group content

    shows application group content when selecting a source in the dropdown
    menu while adding a new rule

    argument:
        group_id: the group that's been selected

    return: renders the show application group content page just below the
        select
    """
    form_select_app = ApplicationSelectForm(request.form)

    members = APIObject(name, 'application-site-group').show_members()
    choices = APIObject('APGR_APLICACIONS',
                        'application-site-group').show_members()

    options = [('', 'seleccionar')]
    for element in choices:
        already_in_group = False
        for appl in members:
            if element['name'] == appl['name']:
                already_in_group = True
        if not already_in_group:
            options.append((element['name'], element['name']))
    form_select_app.name.choices = options

    return render_template('show-appl-group-members.html',
                           form_select_app=form_select_app,
                           members=members,
                           name=name,
                           url_back=url_back)
Ejemplo n.º 2
0
def addExistingApplication(group_name, url_back):
    """
    add existing application

    adds an existing host to a group

    arguments:
        host_id: the id of the host to be added to the group
        group_id: the id of the group where the host has to be added

    return: when POST adds the host to the group, if NO renders the
        show groups page
    """
    form = ApplicationSelectForm(request.form)

    appl = APIObject(form.name.data, 'application-site')
    appl.add_to_group('set-application-site-group', group_name)

    api.api_call('publish')
    flash('URL added')
    return redirect(url_for(url_back))