예제 #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)
예제 #2
0
파일: views.py 프로젝트: gvidon/byhands
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))
예제 #3
0
def contact_us():
    form = ContactUsForm()

    if request.method == 'POST':
        if form.validate() == True:
            msg = Message('New Message SELF-16',
                          sender=('SELF-16 DoNotReply', MAIL_USERNAME),
                          recipients = RECIPIENTS)
            msg.body = """Name:
%s %s

Email:
%s <mailto:%s>

Message:
%s

________________________________

This message was submitted from your website contact form""" % (form.first_name.data, form.last_name.data, form.email.data, form.email.data, form.message.data)
            mail.send(msg)

            return render_template('contact-us.html', success=True)
        else:
            render_template('contact-us.html', form=form)

    elif request.method == 'GET':
        return render_template('contact-us.html', form=form)
예제 #4
0
파일: views.py 프로젝트: kgocks/politicos
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)
예제 #5
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})
예제 #6
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))
예제 #7
0
파일: views.py 프로젝트: fadles/fadles
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())
예제 #8
0
def contact():    
    forms = ContactUsForm()
    if forms.validate_on_submit():        
        contactus = ContactUs(name=forms.name.data,
                    email=forms.email.data, address=forms.address.data,phone=forms.phone.data,comments=forms.comments.data)
        db.session.add(contactus)
        db.session.commit()
        #flash('hurreey account created','success')
        #return redirect(url_for('home'))
        #return redirect('contact')

    return render_template('index.html', forms=forms)
예제 #9
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})
예제 #10
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})
예제 #11
0
def contactUs():
    contactUsForm = ContactUsForm(request.form)

    if request.method == 'POST' and contactUsForm.validate():
        contactDict = {}
        db = shelve.open('storage.db', 'c')
        try:
            contactDict = db['Contact']
        except:
            print("Error in retrieving Items from storage.db.")
        contact = ContactUs.Contact(contactUsForm.fname.data,
                                    contactUsForm.lname.data,
                                    contactUsForm.email.data,
                                    contactUsForm.text.data)
        contactDict[contact.get_email()] = contact
        db['Contact'] = contactDict
        db.close()
        return redirect(url_for('home'))
    return render_template('contactUs.html', form=contactUsForm)
예제 #12
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})
예제 #13
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)
예제 #14
0
파일: views.py 프로젝트: vtzk/dodo.md
def contact_us():
    form = ContactUsForm()
    if form.validate_on_submit():
        print form.email.data, form.message.data
        return redirect("/")
    return render_template('/contact_us.html')
예제 #15
0
파일: views.py 프로젝트: vladutzik/dodo.md
def contact_us():
	form = ContactUsForm()
	if form.validate_on_submit():
		print form.email.data, form.message.data
	 	return redirect("/")
	return render_template('/contact_us.html')