Exemple #1
0
def create_response(request):
    if request.method == "POST":
        form = ResponseForm(request.POST)
        if form.is_valid():
            response = form.save()
            return HttpResponseRedirect(reverse('twilioproj.twilioapp.views.edit_response', 
                args=[str(response.name)]))
    else:
        form = ResponseForm()
    
    return render_to_response('twilioapp/create_response.html', {
                'form': form,
            })
Exemple #2
0
def edit_response(request, response_name):
    response = get_object_or_404(Response, name=response_name)
    verbs = TwilioVerb.objects.filter(response=response).select_related().order_by('order')    
    verb_forms = []
    
    for verb in verbs:
        verb_forms.append(FormUtilities.get_form(verb))

    if request.method == "POST":
        form = ResponseForm(request.POST)
        if form.is_valid():
            form.save()
    else:
        form = ResponseForm(instance=response)
    
    return render_to_response('twilioapp/edit_response.html', {
                'form': form,
                'response': response,
                'verb_forms': verb_forms,
            })