Exemple #1
0
def contact(request):
    category = Category.objects.all()
    if request.method == 'POST':  # check post
        form = ContactForm(request.POST)
        if form.is_valid():
            data = ContactMessage()  # create relation with model
            data.name = form.cleaned_data['name']  # get form input data
            data.email = form.cleaned_data['email']
            data.subject = form.cleaned_data['subject']
            data.message = form.cleaned_data['message']
            data.ip = request.META.get('REMOTE_ADDR')
            data.save()  # save data to table
            messages.success(
                request,
                "Your message has ben sent. Thank you for your message.")
            return HttpResponseRedirect('/contact')

    form = ContactForm
    setting = Setting.objects.get(pk=1)
    sform1 = SearchForm1()
    context = {
        'setting': setting,
        'category': category,
        'form': form,
        'sform1': sform1
    }
    return render(request, 'contact.html', context)
Exemple #2
0
def ContactView(request):

	#The c is for csrf stuff 
	# c = {}
	# c.update(csrf(request))
	errors = []
	if request.method == 'POST':
		form = ContactForm(request.POST)
		if form.is_valid():
			cd = form.cleaned_data

			#CONFIGURE MAIL SERVER LATER
			# send_mail(
   #              cd['subject'],
   #              cd['message'],
   #              cd.get('email', '*****@*****.**'),
   #              ['*****@*****.**'],
   #          )
			return HttpResponseRedirect('/')
	else:
		form = ContactForm(
			initial={'subject':'Ask me your questions three'}) #init message
		t = get_template('home/contact.html')
	return render_to_response('home/contact.html',{'form':form},
								context_instance=RequestContext(request))
def home(request):
    '''Homepage'''

    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():

            form.save()


            # send a notification email to the administrator
            sender = '*****@*****.**'
            receivers = [mail for (_,mail) in settings.ADMINS]

            message = "[00001] New mail: " + form.cleaned_data['email'] + " " + str(datetime.datetime.now())

            try:
               smtpObj = smtplib.SMTP('localhost')
               smtpObj.sendmail(sender, receivers, message)
               print("Successfully sent email")
            except (smtplib.SMTPException, smtplib.ConnectionRefusedError):
               print("Error: unable to send email")

    else:
        form = ContactForm()

    # Topic list to display in the navgation bar
    topics = Topic.objects.all()

    return render(request, 'home/home.html', locals())
Exemple #4
0
def contacto(request):

	info_enviado = False
	nombre = ""
	email = ""
	asunto = ""
	mensaje = ""
	if request.method == "POST":
		formulario = ContactForm(request.POST)
		if formulario.is_valid():
			info_enviado = True
			nombre = formulario.cleaned_data['Nombre']
			email = formulario.cleaned_data['Email']
			asunto = formulario.cleaned_data['Asunto']
			mensaje = formulario.cleaned_data['Mensaje']

			to_admin = '*****@*****.**'
			html_content = "<h1>Informacion recibida</h1> <br><br>Nombre: %s <br><br>Email: %s <br><br>Asunto: %s<br><br>***Mensaje***<br><br>%s"%(nombre, email, asunto, mensaje)
			msg = EmailMultiAlternatives('Consulta Webssites.com.ar',html_content,'*****@*****.**',[to_admin])
			msg.attach_alternative(html_content,'text/html')
			msg.send()



	else:
		formulario = ContactForm()
	ctx = {'form':formulario, 'nombre':nombre, 'email':email, 'asunto':asunto, 'mensaje':mensaje, 'info_enviado':info_enviado}
	return render_to_response('contacto.html',ctx,context_instance=RequestContext(request))
Exemple #5
0
def contact(request):
    form_class = ContactForm
    if request.method == "POST":
        form = ContactForm(request.POST)
        if form.is_valid():
            contact_name = request.POST.get('contact_name', '')
            contact_email = request.POST.get('contact_email', '')
            form_content = request.POST.get('content', '')

            template = get_template('home/contact_template.txt')
            context = {
                'contact_name': contact_name,
                'contact_email': contact_email,
                'form_content': form_content,
            }
            content = template.render(context)

            email = EmailMessage(
                "New contact form submission",
                content,
                "CCANA" + '',
                ['*****@*****.**'],
                headers={'Reply-To': contact_email},
            )
            email.send()
            return HttpResponseRedirect('contact_us')

    return render(request, 'home/contact_us.html', {
        'form': form_class,
    })
def contact_view(request):
    valido = False
    email = ""
    asunto = ""
    texto = ""
    if request.method == "POST":
        formulario = ContactForm(request.POST)
        if formulario.is_valid():
           valido = True
           email = formulario.cleaned_data['email']
           asunto = formulario.cleaned_data['asunto']
           texto = formulario.cleaned_data['texto']
           #configuracion enviando mensaje via GMAIL
           to_admin = '*****@*****.**' #el password de esta cuenta esta en el google drive 
           html_content = "Informacion recibida <br><br><br>***MENSAJE***<br><br>%s" % (texto)
           msg= EmailMultiAlternatives('Correo de Contacto',html_content,'*****@*****.**', [to_admin])
          # SUBJECT,CONTENT,DESTINATARIO
           msg.attach_alternative(html_content,'text/html') #definimos el contenido como html
           msg.send() #enviamos
           #fin configuracion del servidor GMAIL
           ctx = {'formulario':formulario,'email':email,'asunto':asunto,'texto':texto,'valido':valido}
           return render_to_response ('home/contacto.html',ctx,context_instance=RequestContext(request))
    else:
        formulario = ContactForm()
    ctx = {'formulario':formulario,'email':email,'asunto':asunto,'texto':texto,'valido':valido}
    return render_to_response ('home/contacto.html',ctx,context_instance=RequestContext(request))
Exemple #7
0
def contact(request):
    msg_er = ''
    msg_ok = ''
    if request.method == 'GET':
        form = ContactForm()
    else:
        form = ContactForm(request.POST)
        if form.is_valid():
            if auth(request) == 1 or auth(request) == 2 or auth(
                    request) == 3 or auth(request) == 5 or auth(request) == 6:
                name = request.user.username
                email = request.user.email
                message = form.cleaned_data['message']
            else:
                name = form.cleaned_data['name']
                email = form.cleaned_data['email']
                message = form.cleaned_data['message']
        try:
            send_mail(name, message, email,
                      ['*****@*****.**'
                       ])  #يتم وضع ايميل الخاص بالاتصال بادارة الموقع
        except BadHeaderError:
            msg_er = 'Invalid header found.'  # رسالة في حالة وجود خطأ في الايميل
            return render(request, "contact.html", {'msg_er': msg_er})
        msg_ok = 'تم ارسال رسالتك بنجاح... شكرا لك'
        # رسالة في حالة تمت عملية الارسال بنجاح
        return render(request, "contact.html", {'msg_ok': msg_ok})

    return render(request, "contact.html", {'form': form})
Exemple #8
0
def email_to_all(request):
    """ 管理员群发邮件 """

    if request.method == "POST":
        form = ContactForm(request.POST)
        if form.is_valid():
            subject = form.cleaned_data["subject"]
            message = form.cleaned_data["message"]
            sender = form.cleaned_data["sender"]

            recipients = []
            # recipients = ['*****@*****.**','*****@*****.**',]
            # recipients.append(sender)
            from django.core.mail import send_mail

            users = User.objects.all()
            for u in users:
                recipients.append(u.email)
                # for id in range(29,35):
                #    u = User.objects.get(pk=id)
                recipient = [u.email]
                send_mail(subject, message, sender, recipient)

            return render_to_response(
                "home/thanks.html", {"title": "感谢", "recipients": recipients}, context_instance=RequestContext(request)
            )
        return HttpResponse("%s" % form.errors)
    else:
        form = ContactForm()

        return render_to_response(
            "home/contact.html", {"title": "联系", "form": form}, context_instance=RequestContext(request)
        )
Exemple #9
0
def contact(request, template="home/contact.html"):
    if request.method == "POST":
        if request.LANGUAGE_CODE == 'en':
            form = ContactForm(request.POST, request.FILES)
        else:
            form = ChineseContactForm(request.POST, request.FILES)
        if form.is_valid():
            name = form.cleaned_data['name']
            email = form.cleaned_data['email']
            grade = form.cleaned_data['grade']
            school = form.cleaned_data['school']
            message = form.cleaned_data['message']

            contact_message = ContactMessage(name=name, email=email, grade=grade, school=school, message=message)
            contact_message.save()
            #send a confirmation message

            if request.LANGUAGE_CODE == 'en':
                messages.success(request, "Thank you for your message. We will get back to you shortly!")
            else:
                messages.success(request, "谢谢留言,我们会尽快回复。")
            return HttpResponseRedirect(reverse("home"))
    else:
        if request.LANGUAGE_CODE == 'en':
           form = ContactForm()
        else:
           form = ChineseContactForm()
    vals = dict(form=form, contact=True, layout='horizontal', translation=translation)
    return render_to_response(template, RequestContext(request, vals))
Exemple #10
0
def contactar(request):
    if request.method == 'POST':
        form = ContactForm(request.POST, error_class=DivErrorList)
        if form.is_valid():
            mensaje_envio = request.POST['contenido'] == '' and request.POST['web'] or request.POST['contenido'] + '- Pagina web: %s' % request.POST['web']
            recipients = ['*****@*****.**']

            from django.core.mail import send_mail
            send_mail('contactenos - %s' % request.POST['nombres'],
                      mensaje_envio + ' - Correo: ' + request.POST['correo'],
                      '*****@*****.**', recipients)

            form.cleaned_data['nombres']
            form.cleaned_data['correo']
            form.cleaned_data['web']
            form.cleaned_data['contenido']
            messages.add_message(request, messages.SUCCESS, "Su mensaje ha sido enviado")

    else:
        form = ContactForm(error_class=DivErrorList)
    data = get_menu_lateral()
    data['form'] = form
    return render_to_response(
            'home/contactenos.html', data,
            context_instance=RequestContext(request))
Exemple #11
0
    def post(self, request):
        form = ContactForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('/contact')

        args = {'form': form}
        return render(request, self.template_name, args)
Exemple #12
0
 def test_valid_form(self):
     data = dict(
         contact_name='test',
         contact_email='*****@*****.**',
         content='test message from user foo',
     )
     form = ContactForm(data=data)
     self.assertTrue(form.is_valid())
Exemple #13
0
def contact(request):
    template = 'home/base.html'

    job_profit_dict = {'0-$400':30 ,'$400-$1000':29 ,'$1000 - $3000':28 ,'$3,000-$5,000':27 ,'$5,000-$10,000':26 ,'$10,000 - $25,000':25 ,'$25,000 - $50,000':24 ,'$25,000 - $50,000':23 }
    job_prodbill_dict = {'0-$400':80 ,'$400-$1000':82 ,'$1000 - $3000':84 ,'$3,000-$5,000':86 ,'$5,000-$10,000':88 ,'$10,000 - $25,000':90 ,'$25,000 - $50,000':92 ,'$25,000 - $50,000':95 }
    job_ie_dict = {'0-$400':110 ,'$400-$1000':100 ,'$1000 - $3000':80 ,'$3,000-$5,000':60 ,'$5,000-$10,000':40 ,'$10,000 - $25,000':30 ,'$25,000 - $50,000':20 ,'$25,000 - $50,000':10 }
    priority_dict = {'1.1':15 , '1':10 , '2':5 , '3':0 }
    turnaround_dict = {'Very Quick':10 , 'Quick':5 , 'Average':0 }
    rs_dict = {'Hardly any definition':100 , 'Roughly Defined':40 , 'Clearly Defined':20 , 'Clearly defined with Disclaimer':10 , 'Mammoth':0 }
    credit_dict = {'Advance Payment':0.0 , '21 days Credit':1.0 , '30 days Credit':2.0 , '45 days Credit':2.5 , '60 days Credit':3.0 }
    mu_dict = {'110%':-10 , '90%':0 , '80%':10 , '70%':20 , '60%':25 }

    tot_prod_hrs = 171
    usd_rate = 72
    prod_cost = 38000  #monthly cost
    

    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            job_size = form.cleaned_data['job_size']
            company_size = form.cleaned_data['company_size']
            priority = form.cleaned_data['priority']
            ctc = float(form.cleaned_data['ctc'])
            hrs = float(form.cleaned_data['hrs'])
            turnaround_time = form.cleaned_data['turnaround_time']
            req_spec = form.cleaned_data['req_spec']
            credit_days = form.cleaned_data['credit_days']
            manpower_util = form.cleaned_data['manpower_util']
        
            profit_val = job_profit_dict[job_size]
            prodbill_val = job_prodbill_dict[job_size]
            indexp_val = job_ie_dict[job_size]
            priority_val = priority_dict[priority]
            avgctc_val = ctc
            esthrs_val = hrs
            ttime_val = turnaround_dict[turnaround_time]
            rs_val = rs_dict[req_spec]
            credit_val = credit_dict[credit_days]
            mu_val = mu_dict[manpower_util]

            gross_cost = (prod_cost/usd_rate)/tot_prod_hrs
            net_cost = (gross_cost+((indexp_val/100)*7000))/tot_prod_hrs
            net_cost_af_ttime = net_cost*(1+(ttime_val/100))
            net_cost_af_prodbill = net_cost_af_ttime/(prodbill_val/100)
            net_cost_af_profit = net_cost_af_prodbill/(1-(profit_val/100))
            net_cost_af_credit = net_cost_af_profit/(1-(credit_val/100))
            
            total_discount = priority_val + mu_val
            
            net_price = round(net_cost_af_credit*(1-(total_discount/100)), 2)
            net_price_per_month = round(net_price*tot_prod_hrs, 2)

        return render(request, template, {'form':form, 'text1':net_price, 'text2':net_price_per_month})

    else:
        form = ContactForm()
        return render(request, template, {'form':form})
 def test_blank_contact_form_data(self):
     form = ContactForm({})
     self.assertFalse(form.is_valid())
     self.assertEqual(
         form.errors, {
             'name': ['This field is required.'],
             'email': ['This field is required.'],
             'message': ['This field is required.'],
         })
Exemple #15
0
    def test_project_form_can_detect_invalid_data(self):
        data = self.create_feedback().__dict__
        del data['_state']

        # Name is required
        data['name'] = ''

        form = ContactForm(data=data)
        self.assertFalse(form.is_valid())
Exemple #16
0
    def post(self, request):
        form = ContactForm(request.POST)

        if form.is_valid():
            pass

        context = {
            'form': form
        }
        return render(request, self.template_name, context)
 def test_valid_contact_form_data(self):
     form = ContactForm({
         'name': "Test User",
         'email': "*****@*****.**",
         'message': "Here is my test message",
     })
     self.assertTrue(form.is_valid())
     message = form.save()
     self.assertEqual(message.name, "Test User")
     self.assertEqual(message.email, "*****@*****.**")
     self.assertEqual(message.message, "Here is my test message")
     self.assertTrue('contacted')
Exemple #18
0
def contact_team(request, lang=""):
    if request.method == "POST":
        form = ContactForm(request.POST)
        if form.is_valid():
            send_mail(
                'Nouveau message via le formulaire de contact',
                "Nouveau message via le formulaire de contact !\n\n\
De : {} ({} - {})\nMessage : {}\n\n\nJosianne secrétaire".format(
                    form.cleaned_data["name"], form.cleaned_data["email"],
                    form.cleaned_data["phone"], form.cleaned_data["text"]),
                "*****@*****.**", [
                    "*****@*****.**",
                ])

    return HttpResponseRedirect("/{}/".format(lang))
Exemple #19
0
    def test_can_post_message(self):
        """ test can post message successfully """
        form_data = {
            'contact_name': 'test user',
            'contact_email': '*****@*****.**',
            'query': 'Something else',
            'message': 'test message'}

        form = ContactForm(form_data)

        response = self.client.post(reverse('contact_us'),
                                    form_data, follow=True)

        self.assertTrue(form.is_valid())
        self.assertRedirects(response, '/')
Exemple #20
0
 def get_context(self, request):
     context = super(HomePage, self).get_context(request)
     portfolio_list = apps.get_model('portfolio', 'Portfolio')
     context['portfolio'] = portfolio_list.objects.all().order_by(
         '-date')[:4]
     context['feedback_form'] = ContactForm()
     return context
Exemple #21
0
def contact(request):
    if request.method == "POST":  
        form = ContactForm(request.POST)  
        if form.is_valid():  
            name        =   request.POST.get('name')
            subject     =   request.POST.get('subject')
            email       =   request.POST.get('email')
            message     =   request.POST.get('message')
            # create object
            contactObject   = Contact(name=name, subject=subject, email=email, message=message, created_at=datetime.now())
            # save the contact
            contactObject.save()
            messages.success(request, 'Thanks for contacting us.') 
    else:  
        form = ContactForm()  
    return render(request,'pages/contact.html',{'form':form, 'request':request}) 
Exemple #22
0
def contact_form(request):
   form = ContactForm()
   if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            message = "{name} / {email} said: ".format(
                  name=form.cleaned_data.get('name'),
                  email=form.cleaned_data.get('email'))
            message += "\n\n{0}".format(form.cleaned_data.get('message'))
            send_mail(
                 subject=form.cleaned_data.get('subject').strip(),
                 message=message,
                 from_email='*****@*****.**',
                 recipient_list=[settings.EMAIL_HOST_USER],)
            return render(request,"home/contact.html", {"form":form,"message": "message was sent",})
   return render(request,"home/contact.html", {"form": form,})
def contactenos(request):
    if request.method == 'POST':
        formulario = ContactForm(request.POST)
        if formulario.is_valid():
            nombre = formulario.cleaned_data['nombre']
            correo = formulario.cleaned_data['correo']
            mensaje = formulario.cleaned_data['mensaje']
            body_message = "Nombre: " + nombre.upper(
            ) + "\n" + "Correo: " + correo + "\n" + "Mensaje: " + mensaje
            send_mail('Mensaje de la aplicacion galerias', body_message,
                      '*****@*****.**', ['*****@*****.**'])
            return redirect('gracias')
    else:
        formulario = ContactForm()
    context = {'form': formulario}
    return render(request, 'contactenos.html', context)
def contactus(request):
    if request.method == 'GET':
        form = ContactForm()
    else:
        form = ContactForm(request.POST)
        if form.is_valid():
            subject = form.cleaned_data['title']
            from_email = form.cleaned_data['email']
            message = form.cleaned_data['text']
            try:
                send_mail(subject, message + " " + from_email, settings.EMAIL_HOST_USER,
                          recipient_list=['*****@*****.**', '*****@*****.**'])
            except BadHeaderError:
                return HttpResponse('Invalid header found.')
            return render(request, 'home/success.html')
    return render(request, "home/contactus.html", {'form': form,
                                                   'p': True})
Exemple #25
0
def home(request):
    if request.method == 'POST':
        form = ContactForm(data=request.POST)

        if form.is_valid():

            send_mail(subject='Website Contact Form',
                      message=get_details(request),
                      from_email="Personal Website",
                      recipient_list=["*****@*****.**"])

            return HttpResponseRedirect('/thanks/')

    else:
        form = ContactForm()

    return render(request, 'home/home.html', {'form': form})
Exemple #26
0
    def get(self, request):
        form = ContactForm()

        context = {
            'form': form
        }

        return render(request, self.template_name, context)
def contact_us(request):
    """A view that displays the contact us page and sends email

    Arguments:
    request = HttpRequest object
    """
    if request.method == 'POST':
        contact_form = ContactForm(request.POST)

        if contact_form.is_valid():
            sender_name = contact_form.cleaned_data['name']
            sender_email = contact_form.cleaned_data['email']
            message = ('{0} has sent you a new message:\n\n{1} \n\nTheir'
                       ' contact'
                       ' email '
                       'is: {2}').format(sender_name,
                                         contact_form.cleaned_data['message'],
                                         sender_email)
            send_mail('Contact Form', message, sender_email,
                      [settings.EMAIL_HOST_USER])
            request.session['contacted'] = True
            return redirect('thanks')
    else:
        if request.user.is_authenticated:
            contact_form = ContactForm(initial={
                                      'name': request.user.first_name +
                                      ' ' + request.user.last_name,
                                      'email': request.user.email})
        else:
            contact_form = ContactForm()
    return render(request, 'contact.html', {"contact_form": contact_form})
Exemple #28
0
def home(request):
    '''Homepage'''

    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():

            form.save()

            # send a notification email to the administrator
            sender = '*****@*****.**'
            receivers = [mail for (_, mail) in settings.ADMINS]

            message = "[00001] New mail: " + form.cleaned_data[
                'email'] + " " + str(datetime.datetime.now())

            try:
                smtpObj = smtplib.SMTP('localhost')
                smtpObj.sendmail(sender, receivers, message)
                print("Successfully sent email")
            except (smtplib.SMTPException, smtplib.ConnectionRefusedError):
                print("Error: unable to send email")

    else:
        form = ContactForm()

    # Topic list to display in the navgation bar
    topics = Topic.objects.all()

    return render(request, 'home/home.html', locals())
Exemple #29
0
 def post(self, request):
     form = ContactForm(request.POST)
     if form.is_valid():
         name = form.cleaned_data['name']
         comment = form.cleaned_data['comment']
         subject = 'Message from my site'
         message = '%s %s' % (comment, name)
         emaiFrom = form.cleaned_data['email']
         emailTo = [settings.EMAIL_HOST_USER]
         send_mail(subject, message, emaiFrom, emailTo, fail_silently=False)
         title = "Thanks!"
         confirm_message = "Thanks for the message we will get back to you"
         form = None
         args = {
             'form': form,
             'title': self.title,
             'confirm_message': confirm_message
         }
     return render(request, self.template_name, args)
Exemple #30
0
def send_email(request):
    form = ContactForm(request.POST)
    if form.is_valid():
        message = form.cleaned_data['message'] + "\n"
        message += form.cleaned_data['name'] + " at "
        message += form.cleaned_data['sender']
        send_mail(subject=form.cleaned_data['reason'],
                  message=message,
                  from_email="*****@*****.**",
                  recipient_list=['*****@*****.**'],
                  fail_silently=False)
        feedback = "Thanks for your message. "
        feedback += "I will get back to you shortly."
        messages.info(request, feedback)
    else:
        feedback = "Your email failed! "
        feedback += "Please try again."
        messages.error(request, feedback)
    return redirect('contact')
Exemple #31
0
def contact_View(request):
    if request.method =='POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            form.save(commit=True)
            return redirect('home')
    else:
        form =ContactForm()
    return render(request,'home/contact.html', {'form':form})
Exemple #32
0
def home(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            your_name = form.cleaned_data['your_name']
            subject = form.cleaned_data['subject']
            message = form.cleaned_data['message']
            sender = form.cleaned_data['email_id']
            cc_myself = form.cleaned_data['cc_myself']
            str_message = message + "\n" + "by" + "-" + your_name + "\n" + sender
            recipients = ['*****@*****.**']

            if cc_myself:
                recipients.append(sender)

            send_mail(subject, str_message, sender, recipients, fail_silently=False, )
            return HttpResponseRedirect('#contact')
    else:
        form = ContactForm()
        return render(request, 'home/home.html', {'form': form})
Exemple #33
0
def ContactUs(request):
    if request.method == "POST":
        form = ContactForm(request.POST)
        if form.is_valid():
            data = ContactMessage()
            data.name = form.cleaned_data['name']
            data.email = form.cleaned_data['email']
            data.subject = form.cleaned_data['subject']
            data.message = form.cleaned_data['message']
            data.ip = request.META.get('REMOTE_ADDR')
            data.save()
            messages.success(
                request,
                'Your message has been sent. Thank you for your message.')
            return HttpResponseRedirect('/contactus')
    contactform = ContactForm()
    setting = Setting.objects.get(pk=1)
    category = Category.objects.all()
    context = {'setting': setting, 'form': contactform, 'category': category}
    return render(request, 'contactus.html', context)
Exemple #34
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'] 
            full_message = """
                                Name = {}
                                Email = {}
                                Text = {}
            """.format(name, from_email, message)
            
            try:
                send_mail(subject, full_message, from_email, ['*****@*****.**'])
            except BadHeaderError:
                return HttpResponse('Invalid header found.')
            return redirect('home:success')
    return render(request, "home/email.html", {'form': form})
Exemple #35
0
def index(request):
    if request.method == "POST":
        form = ContactForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect("home")
    else:
        form = ContactForm()

    context = {"form": form}
    return render(request, "service/index.htm", context)
Exemple #36
0
def index(request):
    testimonial = Testimonial.objects.all()
    if request.method == "POST":
        form = ContactForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect("home")
    else:
        form = ContactForm()

    context = {"form": form, "tests": testimonial}
    return render(request, 'home/index.htm', context)
Exemple #37
0
def contact(request):
    title = contact
    form_class = ContactForm(request.POST or None)
    form = ContactForm(request.POST or None)
    confirm_message = None
    if form.is_valid():
        name = form.cleaned_data['Email']
        content = ( form.cleaned_data['Email'])
        subject = 'Message from MYSITE.com'
        message = '%s %s' %(content, name)
        emailFrom = ( form.cleaned_data['Email'])
        emailTo = [settings.EMAIL_HOST_USER]
        send_mail(subject, message, emailFrom, emailTo, fail_silently=True )
        title = 'Thanks!'
        confirm_message ="Thanks for the message we will get back to  you"
        form = None

        context = {'title': title, 'form': form, 'confirm_message': confirm_message }
    return render(request, 'home/contact.html', {
        'form': form_class,
    })

    
Exemple #38
0
def contact(request):
    if request.method == "GET":
        contactform = ContactForm()
        context = {'contactform': contactform}
        return render(request, 'home/contact.html', context)

    if request.method == "POST":
        contactform = ContactForm(request.POST)
        if contactform.is_valid():
            contactform.save()

        print(contactform)
        return render(request, 'home/contact.html')
Exemple #39
0
def email_to_all(request):
    ''' 管理员群发邮件 '''

    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            subject = form.cleaned_data['subject']
            message = form.cleaned_data['message']
            sender = form.cleaned_data['sender']

            recipients = []
            #recipients = ['*****@*****.**','*****@*****.**',]
            #recipients.append(sender)
            from django.core.mail import send_mail
            users = User.objects.all()
            for u in users:
                recipients.append(u.email)
                #for id in range(29,35):
                #    u = User.objects.get(pk=id)
                recipient = [u.email]
                send_mail(subject, message, sender, recipient)

            return render_to_response('home/thanks.html', {
                'title': "感谢",
                'recipients': recipients
            },
                                      context_instance=RequestContext(request))
        return HttpResponse("%s" % form.errors)
    else:
        form = ContactForm()

        return render_to_response('home/contact.html', {
            'title': "联系",
            'form': form,
        },
                                  context_instance=RequestContext(request))