Esempio n. 1
0
def add(request):

    if request.method == 'POST':
        form = GroupForm(request.POST)

        if form.is_valid():
            form.instance.techname = techify(form.cleaned_data['name'])
            group = form.save()
            return HttpResponseRedirect('/group/view/%s' % group.techname)

    else:
        form = GroupForm()

    return render_to_response('group/add.html', { 'form': form }, context_instance=RequestContext(request))
Esempio n. 2
0
def edit(request, techname):

    group = get_object_or_404(Group, techname=techname)

    if request.method == 'POST':
        form = GroupForm(request.POST, instance=group)

        if form.is_valid():
            form.instance.techname = techify(form.cleaned_data['name'])
            group = form.save()
            return HttpResponseRedirect('/group/view/%s/' % group.techname)

    else:
        form = GroupForm(instance=group)

    return render_to_response('group/edit.html', { 'form': form, 'group': group }, context_instance=RequestContext(request))