Example #1
0
    def contact_view(request):

        if request.method == 'POST':
            form = ContactForm(request.POST)

            print(request.POST)
            print(form.is_valid())

            if form.is_valid():

                cleaned_data = form.cleaned_data
                username = cleaned_data.get('nameContact')
                email = cleaned_data.get('emailContact')
                phone = cleaned_data.get('phoneContact')
                message = cleaned_data.get('messageContact') 
                        
                send_mail('Contacto Usuario', 
                    'Enviado por: ' + username + 
                    '\n\nCorreo: ' + email + 
                    '\n\nNúmero de teléfono: ' + phone +
                    '\n\nMensaje: ' + message, 
                    settings.EMAIL_HOST_USER, [settings.EMAIL_HOST_USER])

                message='Te contestaremos lo antes posible'    

                context = {'form': form, 'mensaje': message}
                return render(request, 'contact.html', context)
        else:
            form = ContactForm()
  
        context = {'form': form}

        return render(request, 'contact.html', context)
Example #2
0
def contact_us(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            send_mail('New #TinkerMessage from ' + request.POST['name'], request.POST['message'], request.POST['email'], ['*****@*****.**'], fail_silently=False)
            return HttpResponseRedirect("/")
        else:
            return HttpResponseRedirect("/")
    else:
        return render_to_response('contact.html', locals(), context_instance=RequestContext(request))
Example #3
0
def contact(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            send_mail(
                cd['subject'],
                cd['message'],
                cd.get('email', '*****@*****.**'),
                ['*****@*****.**'],
            )
            return HttpResponseRedirect('/contact/thanks/')
    else:
        form = ContactForm(initial={'subject': 'I love your site!'})
    return render_to_response('contact_form.html', {'form': form},
            context_instance=RequestContext(request))
Example #4
0
def contact(request):
    if request.method == 'GET':
        return JsonResponse({"message": _("Method not allowed")}, status=405)
    form = ContactForm(request.POST)
    if form.is_valid():
        send_mail("ITUGnu Contact Form",
                  str(form.cleaned_data['message']) + "\n\nFrom: " +
                  str(form.cleaned_data['email']) + "\nPhone: " +
                  str(form.cleaned_data['phone']),
                  settings.DEFAULT_FROM_EMAIL,
                  [settings.DEFAULT_CONTACT_EMAIL],
                  fail_silently=False)
        return JsonResponse({}, status=200)
    errors = form.errors
    message = ""
    for error in errors:
        message += errors[error][0]
    return JsonResponse({"message": message}, status=400)
Example #5
0
    def contact_view(request):

        if request.method == 'POST':
            form = ContactForm(request.POST)

            print(request.POST)
            print(form.is_valid())

            if form.is_valid():

                cleaned_data = form.cleaned_data
                username = cleaned_data.get('nameContact')
                email = cleaned_data.get('emailContact')
                phone = cleaned_data.get('phoneContact')
                message = cleaned_data.get('messageContact')

                send_mail(
                    'Contacto Usuario', 'Enviado por: ' + username +
                    '\n\nCorreo: ' + email + '\n\nNúmero de teléfono: ' +
                    phone + '\n\nMensaje: ' + message,
                    settings.EMAIL_HOST_USER, [settings.EMAIL_HOST_USER])

                message = gettext('Te contestaremos lo antes posible')

                context = {'form': form, 'mensaje': message}
                return render(request, 'contact.html', context)
        else:
            form = ContactForm()

        context = {'form': form}

        return render(request, 'contact.html', context)
Example #6
0
    def contact_view(request):

        if request.method == 'POST':
            form = ContactForm(request.POST)

            print(request.POST)
            print(form.is_valid())

            if form.is_valid():

                cleaned_data = form.cleaned_data
                username = cleaned_data.get('nameContact')
                email = cleaned_data.get('emailContact')
                phone = cleaned_data.get('phoneContact')
                message = cleaned_data.get('messageContact') 
                        
                send_mail('Contacto Usuario', 'Enviado por: '+username+ ', con el correo: '+ email+ ', el teléfono: '+ phone+ " y el mensaje: "+message, '*****@*****.**', ['*****@*****.**'])

                message='Te contestaremos lo antes posible'    

                context = {'form': form, 'mensaje': message}
                return render(request, 'contact.html', context)
        else:
            form = ContactForm()
  
        context = {'form': form}

        return render(request, 'contact.html', context)
Example #7
0
def contact_us(request):
    if request.method == "POST":
        form = ContactForm(request.POST)
        forms = SubscribeForm(request.POST)

        if form.is_valid():

            data = form.save(commit=False)
            data.save()

            name = form.cleaned_data['name']
            company = form.cleaned_data['company']
            telephone = form.cleaned_data['telephone']
            email = form.cleaned_data['email']
            message = form.cleaned_data['message']
            template = 'email/email.html'

            #email for admin

            content = "you have received a message"
            content += "<br />Name :%s" % name
            content += "<br />company :%s" % company
            content += "<br />telephone:%s" % telephone
            content += "<br />email:%s" % email
            content += "<br />message:%s" % message
            context = {
                'name': name,
                'company': company,
                'telephone': telephone,
                'email': email,
                'message': message,
                'content': content
            }

            html_content = render_to_string(template, context)
            send_mail('New message from %s through website' % name,
                      'you have received a message',
                      '*****@*****.**', ['*****@*****.**'],
                      fail_silently=False,
                      html_message=html_content)

            #email for sender

            content = "Thanks for contacting Neel's Cafe.  Our representaive will contact you soon"
            context = {
                'name': name,
                'company': company,
                'telephone': telephone,
                'email': email,
                'message': message,
                'content': content
            }
            html_content = render_to_string(template, context)
            send_mail(
                "Message received from Neels Cafe",
                "Thanks for contacting Neel's Cafe.  Our representaive will contact you soon.",
                '*****@*****.**', [email],
                fail_silently=False,
                html_message=html_content)

            context = {
                'status': 'true',
                'message': "Contact from sucussfully completed",
                'title': "sucussfully completed"
            }

            return HttpResponseRedirect(reverse('web:contact_us'))
        if forms.is_valid():

            data = forms.save(commit=False)
            data.save()

            return HttpResponseRedirect(reverse('web:contact_us'))

        else:
            context = {
                "form": form,
                "forms": forms,
                "title": "Error",
            }

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

    else:
        form = ContactForm()
        forms = SubscribeForm()

        context = {
            "form": form,
            "forms": forms,
            "title": "Contact us",
            "url": reverse('web:contact_us'),
            "redirect": True
        }
        return render(request, 'Neels cafe/contactus.html', context)
Example #8
0
def contact():
    form = ContactForm()
    return render_template('contact.html', form=form)