Exemplo n.º 1
0
def contact_us(request):
    contact_us_form = ContactUsForm(request.POST or None)
    success_message = ''

    if request.POST and contact_us_form.is_valid():
        subject = '[Politicos API]: Fale Conosco'

        message = (
            'Nome: {0}\nEmail: {1}\nIP: {2}\nMensagem:\n\n{3}').format(
                contact_us_form.cleaned_data['name'],
                contact_us_form.cleaned_data['email'],
                request.META['REMOTE_ADDR'],
                contact_us_form.cleaned_data['message']
            )

        from_field = '{0} <{1}>'.format(
            contact_us_form.cleaned_data['name'],
            contact_us_form.cleaned_data['email']
        )

        send_mail(subject, message, from_field, [settings.CONTACT_US_EMAIL])

        success_message = (
            """Sua mensagem foi enviada com sucesso. """
            """Em breve entraremos em contato!"""
        )

        contact_us_form = ContactUsForm(None)

    c = {
        'contact_us_form': contact_us_form,
        'success_message': success_message
    }

    return render(request, 'contact_us.html', c)
Exemplo n.º 2
0
def contact_us(request):
    contact_us_form = ContactUsForm(request.POST or None)
    success_message = ''

    if request.POST and contact_us_form.is_valid():
        subject = '[Politicos API]: Fale Conosco'

        message = ('Nome: {0}\nEmail: {1}\nIP: {2}\nMensagem:\n\n{3}').format(
            contact_us_form.cleaned_data['name'],
            contact_us_form.cleaned_data['email'], request.META['REMOTE_ADDR'],
            contact_us_form.cleaned_data['message'])

        from_field = '{0} <{1}>'.format(contact_us_form.cleaned_data['name'],
                                        contact_us_form.cleaned_data['email'])

        send_mail(subject, message, from_field, [settings.CONTACT_US_EMAIL])

        success_message = ("""Sua mensagem foi enviada com sucesso. """
                           """Em breve entraremos em contato!""")

        contact_us_form = ContactUsForm(None)

    c = {
        'contact_us_form': contact_us_form,
        'success_message': success_message
    }

    return render(request, 'contact_us.html', c)
Exemplo n.º 3
0
def form(request):
	form = ContactUsForm(auto_id='%s')
	
	if request.POST:
		form = ContactUsForm(auto_id='%s', data=request.POST)
		
		if form.is_valid():
			form.save()
			
			server = smtplib.SMTP('localhost')
			
			server.sendmail('From: [email protected]', 'To: [email protected]',
				'Subject: еще один хэндмейдер\r\n'+
				request.POST['name'].encode('utf8')+' из '+request.POST['city'].encode('utf8')+'\n\n'
				
				'Контакты: '+(', ').join([
					type+': '+request.POST[type] for type in ['icq', 'email', 'phone'] if request.POST[type]
				]).encode('utf8')+'\n\n'+
				
				'Интересен тем, что'+'\n'+request.POST['craft'].encode('utf8')+'\n\n'+
				'Может на заказ!'*int(request.POST.has_key('is_customable') and 1 or 0)
			)
			
			server.quit()
			
			return render_to_response('contactus/thankyou.html', context_instance=RequestContext(request))
	
	return render_to_response('contactus/index.html', { 'form': form }, context_instance=RequestContext(request))
Exemplo n.º 4
0
def contact(request):
    if request.method == "POST":
        form = ContactUsForm(request.POST)
        if form.is_valid():  # Pour le moment jusqu'à j'ajoute l'envoi d'email
            return render(request, 'client/contact-us.html', {'form': form})
    else:
        form = ContactUsForm()
    return render(request, 'client/contact-us.html', {'form': form})
Exemplo n.º 5
0
def contact(request):

    form = ContactUsForm(request.POST or None)
    if form.is_valid():
        this_form = form.save(commit=False)
        this_form.save()
        return HttpResponseRedirect('/')

    return render_to_response('contact.html', {'form': form},
                              RequestContext(request))
Exemplo n.º 6
0
def send_request_view(request):
    if request.method == 'POST':
        form = ContactUsForm(request.POST)
        if form.is_valid():
            ContactUs(**form.cleaned_data).save()
            messages.add_message(request,messages.SUCCESS,'Ваше сообщение успешно отправлено')
            return HttpResponseRedirect('/send_request/')
        messages.add_message(request,messages.ERROR,'Заполните все выделенные поля')
    else:
        form = ContactUsForm()
    return render(request,'main/send_request.html', locals())
Exemplo n.º 7
0
def contact(request):
    if request.method == 'POST':
        contact_form = ContactUsForm(request.POST)

        if contact_form.is_valid():
            send_email.delay(request.POST)
            return redirect(reverse('index'))

    elif request.method == 'GET':
        contact_form = ContactUsForm()

    return render(request,
                  'contact_form.html',
                  context={'contact_form': contact_form})
Exemplo n.º 8
0
def contact(request):
    subject = 'JBC - Admin AUTO REPLY'
    body = 'Thank you for contacting the administrator, you will be contacted shortly concerning:\n\n'
    if request.method == 'POST':
        form = ContactUsForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            email = form.cleaned_data['email']
            msg = form.cleaned_data['message']
            #sending the email is in development
            #send_mail(subject,body+msg,'*****@*****.**',[email]) 
            return render(request, 'thankyou.html', {'name':name, 'email':email })
    else:
        form = ContactUsForm()

    return render(request, 'contact.html', {'form':form})
Exemplo n.º 9
0
def contact(request):
    subject = 'JBC - Admin AUTO REPLY'
    body = 'Thank you for contacting the administrator, you will be contacted shortly concerning:\n\n'
    if request.method == 'POST':
        form = ContactUsForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            email = form.cleaned_data['email']
            msg = form.cleaned_data['message']
            #sending the email is in development
            #send_mail(subject,body+msg,'*****@*****.**',[email])
            return render(request, 'thankyou.html', {
                'name': name,
                'email': email
            })
    else:
        form = ContactUsForm()

    return render(request, 'contact.html', {'form': form})
Exemplo n.º 10
0
def home(request):
    site = Site.objects.get_current()
    siteDetail = SiteDetail.objects.get(site=site)
    context = {'site': site, 'siteDetail': siteDetail}
    if request.method == 'POST':
        form = ContactUsForm(request.POST, request.FILES)
        if form.is_valid():
            try:
                send_mail(
                    'New Contact Us Request',
                    'Name: %s, Email: %s, Comment: %s' % (
                        form.cleaned_data['name'],
                        form.cleaned_data['email'],
                        form.cleaned_data['comments']
                    ),
                    siteDetail.info_email,
                    [siteDetail.info_email],
                    fail_silently=True
                )
            except:
                return render(request, 'home.html', context)

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