Ejemplo n.º 1
0
def ajax_form(request):
    if not request.is_ajax():
        raise Http404

    json = {'success': False}

    if request.method == 'POST':
        form = SupportForm(request.POST)
        if form.is_valid():
            try:
                send_support_mail(request, form)
                json['success'] = True
            except smtplib.SMTPException:
                pass

    return HttpResponse(simplejson.dumps(json), mimetype='application/json')
Ejemplo n.º 2
0
def ajax_form(request):
    if not request.is_ajax():
        raise Http404

    json = {'success': False}

    if request.method == 'POST':
        form = SupportForm(request.POST)
        if form.is_valid():
            try:
                send_support_mail(request, form)
                json['success'] = True
            except smtplib.SMTPException:
                pass

    return HttpResponse(simplejson.dumps(json), mimetype='application/json')
Ejemplo n.º 3
0
def form(request):
    error = False

    if request.method == 'POST':
        form = SupportForm(request.user, request.POST)
        if form.is_valid():
            try:
                send_support_mail(request, form)
                return HttpResponseRedirect(reverse('support-success'))
            except smtplib.SMTPException:
                error = True
    else:
        form = SupportForm(request.user)

    return render_to_response('support/form.html', {
        'form': form,
        'error': error,
    }, context_instance=RequestContext(request))
Ejemplo n.º 4
0
def form(request):
    error = False

    if request.method == 'POST':
        form = SupportForm(request.user, request.POST)
        if form.is_valid():
            try:
                send_support_mail(request, form)
                return HttpResponseRedirect(reverse('support-success'))
            except smtplib.SMTPException:
                error = True
    else:
        form = SupportForm(request.user)

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