Example #1
0
def contact(request):
	if request.method == 'POST':
		form = ContactForm(request.POST)
		if form.is_valid():

			#send message using POST data
			cleaned_data = form.clean()
			subject = cleaned_data['subject']
			message = cleaned_data['message']
			emailAddress = cleaned_data['emailAddress']
			message = "Filtr Feedback from %s:\n%s"  %(emailAddress,message)
			email = EmailMessage(subject, message, '*****@*****.**', ['*****@*****.**', '*****@*****.**'])
			email.send(fail_silently=False)
			return HttpResponseRedirect('/')

	#initial page render
	form = ContactForm()
	return render(request, 'contact.html', {'form':form})
Example #2
0
def contact(request):
	if request.method == 'POST':
		form = ContactForm(request.POST)
		if form.is_valid():
			cleaned_data = form.clean()
			subject = cleaned_data['subject']
			message = cleaned_data['message']
			toAddress = cleaned_data['emailAddress']
			send_mail(subject, message, '*****@*****.**',
    ['*****@*****.**'], fail_silently=False)
			return HttpResponseRedirect('/')
	else:
		if request.user.is_active:
			data = {'emailAddress':request.user.email, 'subject':"Nice site!"}
			form = ContactForm(initial=data)
		else:
			form = ContactForm()
	
	return render(request, 'contact.html', {'form':form})