Пример #1
0
    def test_send_email(self):
        form = FeedbackForm(data={"email": "*****@*****.**", "body": "test email"})

        if form.is_valid():
            form.send_email()
        else:
            self.assertFail()

        self.assertEqual(len(mail.outbox), 1)
Пример #2
0
    def test_send_email(self):
        form = FeedbackForm(data={
            'email': '*****@*****.**',
            'body': 'test email'
        })

        if form.is_valid():
            form.send_email()
        else:
            self.assertFail()

        self.assertEqual(len(mail.outbox), 1)
Пример #3
0
def contact(request):
    if request.method == 'POST':
        form = FeedbackForm(request.POST)

        if(form.is_valid()):
            print(request.POST['name'])
            print(request.POST['message'])
            message = 'Thank you for you feedback.'
        else:
            message = 'Sorry, something went wrong.'
        return render_to_response('contact/contact.html', {'success': message}, context_instance=RequestContext(request))
    else:
        return render_to_response('contact/contact.html', {'form': FeedbackForm()}, context_instance=RequestContext(request))
Пример #4
0
def feedback(request):
    if(request.method == "POST"):
        form = FeedbackForm(request.POST)

        if(form.is_valid()):
            send_mail('[GoDjango Feedback Form]', request.POST['body'], request.POST['email'], ['*****@*****.**'], fail_silently=False)
            message = "Thank you for the email"
        else:
            message = "Please be sure to use an email address and have a message in the body."
    else:
        message = ""

    return render_to_response('contact/feedback.html',
            { 'form':FeedbackForm(), 'message':message },
            context_instance=RequestContext(request))
Пример #5
0
def feedback(request):
    if (request.method == "POST"):
        form = FeedbackForm(request.POST)

        if (form.is_valid()):
            send_mail('[GoDjango Feedback Form]',
                      request.POST['body'],
                      request.POST['email'], ['*****@*****.**'],
                      fail_silently=False)
            message = "Thank you for the email"
        else:
            message = "Please be sure to use an email address and have a message in the body."
    else:
        message = ""

    return render_to_response('contact/feedback.html', {
        'form': FeedbackForm(),
        'message': message
    },
                              context_instance=RequestContext(request))
Пример #6
0
def feedback(request):
    if request.method == "POST":
        form = FeedbackForm(request.POST)

        if form.is_valid():
            send_mail(
                "[GoDjango Feedback Form]",
                request.POST["body"],
                request.POST["email"],
                ["*****@*****.**"],
                fail_silently=False,
            )
            message = "Thank you for the email"
        else:
            message = "Please be sure to use an email address and have a message in the body."
    else:
        message = ""

    return render_to_response(
        "contact/feedback.html", {"form": FeedbackForm(), "message": message}, context_instance=RequestContext(request)
    )