Esempio n. 1
0
def contact_us():

    form = ContactUsForm()
    categories = Category.query.all()

    if form.validate_on_submit():

        name = form.name.data
        email = form.email.data
        subject = form.subject.data
        message = form.message.data

        contact = ContactUs(name, email, subject, message)

        try:

            db.session.add(contact)
            db.session.commit()

        except Exception as ex:

            db.session.rollback()

        return 'Thanks for contacting us!!'

    return render_template('contact_us.html', form=form, categories=categories)
Esempio n. 2
0
def contact_us(request):
    if request.method == "POST":
        form = ContactUsForm(request.POST)
        if form.is_valid():
            mail_admins(
                "Feedback: '{subject}' from {email}".format(
                    **form.cleaned_data), form.cleaned_data['content'])
            return redirect(reverse('home'))
    else:
        form = ContactUsForm()

    return render(request, 'contact-us.html', {'foo': form})
Esempio n. 3
0
def contact_us(request):
    if request.method == "POST":
        form = ContactUsForm(request.POST)
        if form.is_valid():
            mail_admins("Feedback: '{subject}' from {email}".format(**form.cleaned_data),
                        form.cleaned_data['content'])
            return redirect(reverse('home'))
    else:
        form = ContactUsForm()

    return render(request, 'contact-us.html', {
        'foo': form
    })
Esempio n. 4
0
def contact_form_view(request):
    #print(request.method)
    if request.method == "GET":
        form = ContactUsForm()
        return render(request, "blog/contact-us.html", context = {"form":form})
    else:
        print(request.POST)
        form = ContactUsForm(request.POST)
        if form.is_valid():
            print(form.cleaned_data)
            return render(request,"blog/thanks.html")
        else:
            print(form.errors)
            return render(request, "blog/contact-us.html", context = {"form":form})
Esempio n. 5
0
def contact_us_form_view(request):
    if request.method == 'GET':
        form = ContactUsForm()
        return render(request, 'blog/contact-us.html', context={'form': form})

    else:
        print(request.POST)
        form = ContactUsForm(request.POST)
        if form.is_valid():
            return render(request, 'blog/thankyou.html')
        else:
            print(form.errors)
            return render(request,
                          'blog/contact-us.html',
                          context={'form': form})
Esempio n. 6
0
def contact_us_form_view(request):
    # print(request.method)
    # print(request.GET)
    if request.method == "GET":
        form = ContactUsForm()
        return render(request, "blog/contact-us.html", context={"form": form})
    else:

        form = ContactUsForm(request.POST)
        if form.is_valid():
            print(form.cleaned_data)
            return HttpResponse("Thank you for submitting the response")
        else:
            print(form.errors)
            return render(request,
                          "blog/contact-us.html",
                          context={"form": form})
Esempio n. 7
0
def contactus(request):
    if request.session.get('username'):
        return HttpResponseRedirect(reverse('mainpageloggedin'))
    else:
        if request.method == "POST":
            contact = ContactUsForm(data=request.POST)
            if contact.is_valid():
                contact.save()
                return HttpResponseRedirect(reverse('lastContact'))
        else:
            contact = ContactUsForm()
        return render(request, 'contactus.html', context={'contacts': contact})