示例#1
0
def contact_page():
    form = ContactForm()
    if form.validate_on_submit():
        try:
            form.send_mail()
            return render_template("contact_thankyou.html")
        except Exception as e:
            app.logger.exception("Failed to send contact email!")
            abort(500)
    else:
        return render_template("contact.html", form=form)
示例#2
0
def contact(request):
    context = {}
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            form.send_mail()
            context['success'] = True
    else:        
        form = ContactForm()
    context['form'] = form
    return render(request, 'contact.html', context)
示例#3
0
def contact(request):
	context = {}
	if request.method == 'POST':
		form = ContactForm(request.POST)
		if form.is_valid():
			form.send_mail()
			context['success'] = True
	else:
		form = ContactForm()
	context['form'] = form
	return render(request, "contact.html", context)
示例#4
0
def contact(request):
    context = {}
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            form.send_mail()
            context['sucess'] = True
            #context['data'] = form.cleaned_data
    else:
        form = ContactForm()
    context['form'] = form
    return render(request, 'contact.html', context)
示例#5
0
def contact(request):
    if request.method == "POST":
        form = ContactForm(request.POST)

        if form.is_valid():
            form.send_mail()

            return redirect("thanks")
    else:
        form = ContactForm()

    response_data = {"contact_form": form}

    return render_to_response("contact.html", response_data, context_instance=RequestContext(request))
示例#6
0
def contact(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)

        if form.is_valid():
            form.send_mail()

            return redirect('thanks')
    else:
        form = ContactForm()

    response_data = {
        'contact_form': form,
    }

    return render_to_response('contact.html',
                              response_data,
                              context_instance=RequestContext(request))
示例#7
0
文件: views.py 项目: klebercode/rhape
def home(request):
    context = {}
    context['enterprises'] = Enterprise.objects.all()
    context['contacts'] = Contact.objects.all()
    context['teans'] = Team.objects.all()
    context['costs'] = Cost.objects.all()
    context['partners'] = Partner.objects.all()
    context['galleries'] = Gallery.objects.all()
    context['courses'] = Course.objects.all()
    context['objectivies'] = Objective.objects.all()
    context['publics'] = Public.objects.all()
    context['steps'] = Step.objects.all()

    if request.method == 'POST':
        if request.POST['action'] == 'contact':
            contact_form = ContactForm(request.POST, prefix='Contact')
            subscribe_form = SubscribeForm(prefix='Subscribe')
            if contact_form.is_valid():
                contact_form.send_mail()
                context['contact_success'] = True
        elif request.POST['action'] == 'subscribe':
            subscribe_form = SubscribeForm(request.POST,
                                           prefix='Subscribe')
            contact_form = ContactForm(prefix='Contact')
            if subscribe_form.is_valid():
                # obj = subscribe_form.save()
                subscribe_form.save()
                subscribe_form.send_mail()
                context['subscribe_success'] = True
    else:
        contact_form = ContactForm(prefix='Contact')
        subscribe_form = SubscribeForm(prefix='Subscribe')

    context['contact_form'] = contact_form
    context['subscribe_form'] = subscribe_form

    return render(request, 'index.html', context)