Esempio n. 1
0
def addgroup(request):
    """ Add a new okconfig group

    """
    c = {}
    c['messages'] = []
    c['errors'] = []
    # If there is a problem with the okconfig setup, lets display an error
    if not okconfig.is_valid():
        return verify_okconfig(request)

    if request.method == 'GET':
        f = forms.AddGroupForm(initial=request.GET)
    elif request.method == 'POST':
        f = forms.AddGroupForm(request.POST)
        if f.is_valid():
            group_name = f.cleaned_data['group_name']
            alias = f.cleaned_data['alias']
            #description = f.cleaned_data['description']
            force = f.cleaned_data['force']
            try:
                c['filelist'] = okconfig.addgroup(group_name=group_name,
                                                  alias=alias,
                                                  force=force)
                c['group_name'] = group_name
                return addcomplete(request, c)
            except Exception, e:
                c['errors'].append("error adding group: %s" % e)
        else:
            c['errors'].append('Could not validate input')
Esempio n. 2
0
def addgroup(request):
    """ Add a new okconfig group

    """
    c = {}
    c['messages'] = []
    c['errors'] = []
    # If there is a problem with the okconfig setup, lets display an error
    if not okconfig.is_valid():
        return verify_okconfig(request)

    if request.method == 'GET':
        f = forms.AddGroupForm(initial=request.GET)
    elif request.method == 'POST':
        f = forms.AddGroupForm(request.POST)
        if f.is_valid():
            group_name = f.cleaned_data['group_name']
            alias = f.cleaned_data['alias']
            force = f.cleaned_data['force']
            try:
                c['filelist'] = okconfig.addgroup(group_name=group_name,
                                                  alias=alias,
                                                  force=force)
                c['group_name'] = group_name
                return addcomplete(request, c)
            except Exception as e:
                c['errors'].append(_("error adding group: %s") % e)
        else:
            c['errors'].append(_('Could not validate input'))
    else:
        raise Exception("Sorry i only support GET or POST")
    c['form'] = f
    return render_to_response('addgroup.html',
                              c,
                              context_instance=RequestContext(request))