コード例 #1
0
ファイル: views.py プロジェクト: janakiveluri/webportal
def contact(request):
    """Contact us page.

    Arguments: `request`: Request from the client.  This function
    takes the request of the client and direct it to the contact us
    page.
    """
    context = RequestContext(request)

    if request.POST:
        contactform = ContactForm(data=request.POST)
        if contactform.is_valid():
            contactform = contactform.save(commit=True)
            email_subject = "[aakashschooleducation.org] Contact Us"
            email_message = "Sender Name: " + contactform.name + "\n \\n" + contactform.message
            #send_mail(email_subject, email_message,
            #          contactform.email,
            #          [
            #              '*****@*****.**',
            #              '*****@*****.**',
            #              '*****@*****.**',
            #          ],
            #          fail_silently=False)
            messages.success(request, "Thank you for your reply. We will get back to you soon.")
        else:
            print contactform.errors
            messages.error(request, "One or more fields are required or not valid.")
    else:
        contactform = ContactForm()

    context_dict = {'contactform': contactform}
    return render_to_response('contact.html', context_dict, context)
コード例 #2
0
def contact(request):
    if request.method == 'GET':
        form = ContactForm()
    else:
        form = ContactForm(request.POST)
        if form.is_valid():
            # name = form.cleaned_data['name']
            subject = form.cleaned_data['subject']
            from_email = form.cleaned_data['from_email']
            message = form.cleaned_data['message']
            try:
                send_mail(subject, message, from_email,
                          ['*****@*****.**'])
            except BadHeaderError:
                return HttpResponse('Invalid header found.')
            return redirect('success')
    return render(request, "webapp/contact.html", {'form': form})
コード例 #3
0
ファイル: views.py プロジェクト: twiglet/twigletweb
def contact(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            contact=form.save(commit=False)
            contact.contact_version = get_active_version()
            contact.save()
            cd = form.cleaned_data
            email = EmailMessage("CS2J Online Contact from %s" % cd['name'],
                                 "Name: %(name)s\nEmail: %(email)s\nPhone: %(phone)s\nVersion: %(contact_version)s\nMessage: %(comment)s" % dict(contact_version = get_active_version(), **cd),
                                 '*****@*****.**',
                                 ['*****@*****.**'],
                                 headers = {'Reply-To':  cd.get('email')})
            email.send()
            return HttpResponseRedirect(reverse('webapp.views.contact_thanks'))
    else:
        form = ContactForm()
    return render_to_response('twiglet/contact_form.html', {'form': form}, context_instance=RequestContext(request))
コード例 #4
0
ファイル: views.py プロジェクト: code-aditya/Milan
    def post(self, request):
        form = ContactForm(request.POST)

        if form.is_valid():
            name = form.cleaned_data['name']
            email = form.cleaned_data['email']
            message = form.cleaned_data['message']

            subject = email
            from_email = settings.EMAIL_HOST_USER
            message = message
            to_list = [settings.EMAIL_HOST_USER, email]

            send_mail(subject,
                      message,
                      from_email,
                      to_list,
                      fail_silently=False)

            return redirect('about_us')
コード例 #5
0
ファイル: views.py プロジェクト: janakiveluri/webportal
def contact(request):
    """Contact us page.

    Arguments: `request`: Request from the client.  This function
    takes the request of the client and direct it to the contact us
    page.
    """
    context = RequestContext(request)

    if request.POST:
        contactform = ContactForm(data=request.POST)
        if contactform.is_valid():
            contactform = contactform.save(commit=True)
            email_subject = "[aakashschooleducation.org] Contact Us"
            email_message = "Sender Name: " + contactform.name + "\n \\n" + contactform.message
            #send_mail(email_subject, email_message,
            #          contactform.email,
            #          [
            #              '*****@*****.**',
            #              '*****@*****.**',
            #              '*****@*****.**',
            #          ],
            #          fail_silently=False)
            messages.success(
                request,
                "Thank you for your reply. We will get back to you soon.")
        else:
            print contactform.errors
            messages.error(request,
                           "One or more fields are required or not valid.")
    else:
        contactform = ContactForm()

    context_dict = {'contactform': contactform}
    return render_to_response('contact.html', context_dict, context)
コード例 #6
0
ファイル: views.py プロジェクト: simranjkk/teach
def contact( request ):
	''' 
	This view handles contact us form. It sends user query as email to all the users in ContactUs group.
	It also sends an automated response to the person submitting the contact us form.
	'''

	if request.method == "POST":
		form = ContactForm( request.POST )
		if form.is_valid():
			ContactUsEmailIds = User.objects.filter( groups__name='ContactUs' ).values_list( 'email', flat=True )
			enquiry = ( "teachoo.com: Enquiry from " + form.cleaned_data['sender_name'], form.cleaned_data['message'], form.cleaned_data['sender_email'], ContactUsEmailIds ) # email query to all the users in ContactUs group

			sender_response = ( "teachoo.com: Automated response", "Thank you for your interest. We will get back to you soon.", "*****@*****.**", [form.cleaned_data['sender_email']] ) # Automated response to sender

			status = send_mass_mail( ( enquiry, sender_response ), fail_silently=False )
			return render_to_response( 'webapp/contact.html', {'status': status}, RequestContext( request ) )
		
		else:
			return render_to_response( 'webapp/contact.html', {'form':form}, RequestContext( request ) )


	else:
		form = ContactForm()
		return render_to_response( 'webapp/contact.html', {'form':form}, RequestContext( request ) )
コード例 #7
0
ファイル: views.py プロジェクト: code-aditya/Milan
 def get(self, request):
     form = ContactForm()
     return render(request, self.template_name, {'form': form})