Ejemplo n.º 1
0
def contact(request):
	if request.method == 'POST':
		form = ContactForm(request.POST)
		if form.is_valid():
			cd = form.cleaned_data
			return HttpResponseRedirect('/contact/thanks/')
	else:
		form = ContactForm()
	return render(request, 'contact_form.html', {'form': form})
Ejemplo n.º 2
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})
Ejemplo n.º 3
0
def contact(reqeust):
    if reqeust.method == 'POST':
        form = ContactForm(reqeust.POST)
        if form.is_valid():
            cd = form.cleaned_data
            send_mail(cd['subject'],cd['message'],cd.get('email','*****@*****.**'),'*****@*****.**')
            return HttpResponseRedirect('/book/contact/thanks')
    else:
        form = ContactForm(initial={'subject':'I love your site'})
    return render_to_response('books/contact_form.html',{'form':form},context_instance=RequestContext(reqeust))
Ejemplo n.º 4
0
def contact(request):
    if request.method == "POST":
        form = ContactForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            send_mail(cd["subjcet"], cd["message"], cd.get("email", "*****@*****.**"), ["*****@*****.**"])
            return HttpResponseRedirect("/contact/thanks/")
    else:
        form = ContactForm(initial={"subject": "I love you, Leon!", "f**k": "Please be polite."})
    return render(request, "contact_form.html", {"form": form})
Ejemplo n.º 5
0
def contact(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            return HttpResponse('thank you')
    else:
        form = ContactForm( 
                initial={'subject': 'I love your site!'}
                )
    return render_to_response('contact_form.html',{'form': form}, RequestContext(request) )
Ejemplo n.º 6
0
def contact(request):
    dic = {}
    dic.update(csrf(request))
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            print cd
            return HttpResponseRedirect('/books/contact/thanks/')
    else:
        form = ContactForm()
    dic['form'] = form
    return render_to_response('contact.html', dic)
Ejemplo n.º 7
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(reverse(thanks))
  else:
    form = ContactForm()
  return render_to_response(get_template('contact_form.html'),
                                {'form':form}, 
                                context_instance=RequestContext(request))
Ejemplo n.º 8
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(reverse(thanks))
    else:
        form = ContactForm()
    return render_to_response(get_template('contact_form.html'),
                              {'form': form},
                              context_instance=RequestContext(request))
Ejemplo n.º 9
0
def contact(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            #process form data
            topic = form.cleaned_data['topic']
            message = form.cleaned_data['message']
            sender = form.cleaned_data.get('sender', '*****@*****.**')
            #send_mail('Feedback from your site, topic: %s' % topic,
            #          message, sender, ['*****@*****.**'],'', 'bushuevzi','2CnpS1Lov4M','smtp.mail.ru')
            return HttpResponseRedirect('./thanks')
    else:
        form = ContactForm(initial={'sender':'*****@*****.**'})
    return render_to_response('contact.html', {'form':form})
Ejemplo n.º 10
0
def contact(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            #con=form.save()
            topic=form.cleaned_data['topic']
            message=form.cleaned_data['message']
            sender=form.cleaned_data['sender']
            send_mail('Feedback from your site: %s'%topic,message,sender,['*****@*****.**'],fail_silently=False)
            
            return HttpResponseRedirect('/contact/thanks/')
    else:
        form = ContactForm()
    return render(request,'contact.html', {'form': form})
Ejemplo n.º 11
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', '*****@*****.**'),
                ['*****@*****.**'],
            )
    else:
        form = ContactForm(initial={'subject': 'I love your site!'})
    return render_to_response('contact_form.html', {'form': form})
Ejemplo n.º 12
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 need your site.'})
	return render_to_response('contact_form.html',{'form':form})
Ejemplo n.º 13
0
def contact(request):
    errors = []
    if request.method == 'POST':  # If the form has been submitted...
        form = ContactForm(request.POST)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            return HttpResponse('Thanks!')
    else:
        form = ContactForm()  # An unbound form

    return render(
        request,
        'contact.html',
        {'form': form, 'errors': errors}
    )
Ejemplo n.º 14
0
def addContact(request):
    if not request.user.is_authenticated():
        return HttpResponseRedirect(getHost(request) + '/login/?next=%s' % request.path)  
    if request.method == 'POST' :
        form = ContactForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            g = Contact(name=cd['name'], description=cd['description'], user=cd['user'])
            g.create_by = request.user
            g.save()
            return HttpResponseRedirect(getHost(request) + "/contacts/")
    else:
        form = ContactForm()
    return  render_to_response('books/contact_form.html', {'form':form},context_instance=RequestContext(request))
Ejemplo n.º 15
0
def contact(request):
    if request.method == 'post':
        form = ContactForm(request.POST)
        if form.is_valid():
            topic = form.cleaned_data['topic']
            message = form.cleaned_data['message']
            sender = form.cleaned_data.get('sender',
                                           '*****@*****.**')
            send_mail('Feedback from your site,topic:%s' % topic, message,
                      sender, ['*****@*****.**'])
            return HttpResponseRedirect('/contact/thanks')
    else:
        form = ContactForm()
    return render(request, 'contact.html', {'form': form})
Ejemplo n.º 16
0
def contacts(request):
	if request.method =="POST":
		form=ContactForm(request.POST);
		if form.is_valid():
			cf = form.cleaned_data
			send_mail(
				cf['subject'],
				cf['message'],
				cf.get('email','*****@*****.**'),
				['*****@*****.**'],
				)
			return HttpResponseRedirect('/contact/thanks/')
	else:
		form = ContactForm()
	return render(request,'contact_form.html',{'form':form})
Ejemplo n.º 17
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()
    return render(request, 'contact_form.html', {'form': form})
Ejemplo n.º 18
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(request, 'contact_form.html', {'form': form})
Ejemplo n.º 19
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()
	return render(request,'contact_form.html',{'form':form})
Ejemplo n.º 20
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', '*****@*****.**'),
                      ['*****@*****.**'],
                      fail_silently=True)
            return HttpResponseRedirect('/contact/thanks/')
    else:
        form = ContactForm()
    return render_to_response('contact_form.html', {'form': form},
                              context_instance=RequestContext(request))
Ejemplo n.º 21
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': 'F**k you, You c**t'})
    return render(request, 'contact_form.html', {'form': form})
Ejemplo n.º 22
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()
    return render(request, 'contact_form.html', {'form': form})
Ejemplo n.º 23
0
def contact(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            topic = form.clean_data['topic']
            message = form.clean_data['message']
            sender = form.clean_data.get('sender', '*****@*****.**')
            send_mail(
                'Feedback from your site, topic: %s' % topic,
                message, sender,
                ['*****@*****.**']
            )
            return HttpResponseRedirect('/contact/thanks/')
    else:
        form = ContactForm()
    return render_to_response('contact.html', {'form': form})
Ejemplo n.º 24
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!'} #为字subject段添加初始值
        )
    return render(request, 'contact_form.html', {'form':form})
Ejemplo n.º 25
0
def contact(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            #con=form.save()
            topic = form.cleaned_data['topic']
            message = form.cleaned_data['message']
            sender = form.cleaned_data['sender']
            send_mail('Feedback from your site: %s' % topic,
                      message,
                      sender, ['*****@*****.**'],
                      fail_silently=False)

            return HttpResponseRedirect('/contact/thanks/')
    else:
        form = ContactForm()
    return render(request, 'contact.html', {'form': form})
Ejemplo n.º 26
0
def contact(request):
    if request.method == 'POST':  #判断请求方法是否为post
        form = ContactForm(request.POST)  #将想要发送的请求传到变量form中
        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!',
            'message': 'It is very beautiful'
        })  #如果不是post请求,就创建一个空表单,initial参数设置初始值
    return render(request, 'contact_form.html', {'form': form})
Ejemplo n.º 27
0
def contact(request):
    logger.info("request.method: %s", request.method)
    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))
Ejemplo n.º 28
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:
            return backToForm(request, form)
    else:
        form = ContactForm(
            initial={'subject':'FAQ', 'message':'Sample text'}
        )
        return backToForm(request, form)
Ejemplo n.º 29
0
def contact(request):
        if request.method == 'POST':  # If the form has been submitted...
                form = ContactForm(request.POST)  # A form bound to the POST data
                if form.is_valid():
                        subject = form.cleaned_data['subject']
                        message= form.cleaned_data['message']
                        sender = form.cleaned_data['sender']
                        cc_myself = form.cleaned_data['cc_myself']
                        recipients = ['*****@*****.**']
                        if cc_myself:
                            recipients.append(sender)
                        return HttpResponse('Thanks')
        else:
                form = ContactForm()  # An unbound form

        return render(
                request,
                'contact.html',
                {'form': form}
        )
Ejemplo n.º 30
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',
                       '*****@*****.**'), ['*****@*****.**']
                #    cd.get('email', <a class="reference external" href="mailto:'noreplay%40examble.com">'[email protected]</a>'),
                #   [<a class="reference external"href="mailto:'siteowner%40examble.com">'[email protected]</a>'],
            )
            return HttpResponseRedirect('/contact/thanks/')

    else:
        form = ContactForm(initial={'subject': 'I love you'})
    return render(request, 'books/contact_form.html', {
        'form': form,
        'ip_add': request.META['REMOTE_ADDR']
    })
Ejemplo n.º 31
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['email'],
                ['*****@*****.**']
            )
            return HttpResponseRedirect('/contatc/thanks')
    else:
        form = ContactForm(initial={'subject': 'I love your site!'})
    return render(request, 'contact_form.html', {'form': form})

        # CAP 7 - Exemplo 1
        # if not request.POST.get('subject'):
        #     errors.append('Enter a subject')
        # if not request.POST.get('message'):
        #     errors.append('Enter a message')
        # if request.POST.get('email') and '@' not in request.POST['email']:
        #     errors.append('Enter a valid e-mail address.')
        #
        # if not errors:
        #     send_mail(
        #         request.POST['subject'],
        #         request.POST['message'],
        #         request.POST.get('email') or '*****@*****.**',
        #         ['*****@*****.**']
        #     )
        #     return HttpResponseRedirect('/contact/thanks')
        # return render(request, 'contact_form.html', {
        #     'errors': errors,
        #     'subject': request.POST.get('subject') or '',
        #     'message': request.POST.get('message') or '',
        #     'email': request.POST.get('email') or ''
        # })
Ejemplo n.º 32
0
def contact(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            topic = form.cleaned_data['topic']
            message = form.cleaned_data['message']
            sender = form.cleaned_data.get('sender', '*****@*****.**')
            print(topic, message, sender)
            """
			t=send_mail(
			'Feedback from your site, topic: %s' % topic,
			message, sender,
			['*****@*****.**']
			)
			"""
            #url = reverse('thanks', kwargs={'name': sender})
            #return HttpResponseRedirect(url) #'/contact/thanks?name=aminul'

            return HttpResponseRedirect(
                reverse('ul_name', kwargs={'tst': sender}))
    else:
        form = ContactForm()
    return render_to_response('contact.html', {'form': form},
                              context_instance=RequestContext(request))
Ejemplo n.º 33
0
def contact(request):
    if request.method == 'POST':
        errors = []
        form = ContactForm(request.POST)
        # context_dict = {'errors': errors, 'subject': request.POST.get('subject', ''),
        #                 'message': request.POST.get('message', ''), 'email': request.POST.get('email', '')}
        # if not request.POST.get('subject', ''):
        #     errors.append('请输入邮件主题')
        #     return render(request, 'contact_form.html', context_dict)
        #     return render_to_response()
        # if '@' not in request.POST.get('email') or not request.POST.get('email'):
        #     errors.append('请输入有效的邮箱地址')
        #     return render(request, 'contact_form.html', context_dict)
        # if not request.POST.get('message', ''):
        #     errors.append('请输入邮件内容')
        #     return render(request, 'contact_form.html', context_dict)
        if form.is_valid():
            cd = form.cleaned_data
            try:
                send_mail(
                    cd['subject'],
                    cd['email'],
                    cd['message'],
                    ['*****@*****.**'],
                    # cd.get('email', '*****@*****.**'),
                    #['*****@*****.**'],
                )
                # Contact.objects.create(subject=cd['subject'], email=cd['email'], message=cd['message'])
                contact = Contact()
                contact.subject = cd['subject']
                contact.email = cd['email']
                contact.message = cd['message']
                contact.save()
            except smtplib.SMTPException as e:
                errors.append(u"邮件发送失败: %s" % e)
                return HttpResponse(errors)

            subject = cd['subject']
            email = cd['email']
            message = cd['message']
            # return HttpResponseRedirect("/book/contact/thanks/?subject=%s&email=%s&message=%s" % (subject, email, message))
            return thanks(request,
                          args={
                              'subject': subject,
                              'email': email,
                              'message': message
                          })
        # if not errors:
        #         #     try:
        #         #         send_mail(request.POST['subject'],
        #         #                   request.POST['message'],
        #         #                   request.POST.get('email', '*****@*****.**'),
        #         #                   ['*****@*****.**'],
        #         #                   )
        #         #         return HttpResponseRedirect('/book/contact/thanks/')
        #         #     except :
        #         #         errors.append('邮件发送失败')
    else:
        form = ContactForm(initial={'subject': 'I love your site!'})
    context_dict = {'form': form}
    return render(request, 'contact_form.html', context_dict)