def send_confirmation_email(self): ##Para el alumno subject = "Te has matriculado para un examen Cambridge en EIDE" message_body = """""" ### Para los admins subject = "Hay una nueva matricula (sin pagar) para cambridge " message_body = """""" mail_admins(subject, message_body)
def send_paiment_confirmation_email(self): subject = "Se ha confirmado el pago de la matricula para el examen" html_content="""""" message_body = html_content ##send_mail(subject, message_body, settings.DEFAULT_FROM_EMAIL, [self.email]) msg = EmailMultiAlternatives(subject, message_body, settings.DEFAULT_FROM_EMAIL, [self.email]) msg.attach_alternative(html_content, "text/html") ##msg.content_subtype = "html" msg.send() subject = "Se ha confirmado el pago" message_body = """""" mail_admins(subject, message_body)
def new_report(request, pk): template = "facilities/report.html" if request.method == "POST": form = FacilityReportForm(pk, request.POST) if form.is_valid(): saved = form.save(request) return HttpResponseRedirect('/reports/ajax/reported/%d' % saved.pk) else: form = FacilityReportForm(Facility.objects.get(pk=pk).pk) if not form.has_reportables: from mailer import mail_admins mail_admins("Facility not reportable: %s" % reverse('admin:facilities_facility_change', args=[pk]), "Please add some reportable items to rectify the situation.") return render(request, "facilities/not_reportable.html") return render(request, template, {'form':form})
def new_report(request, pk): template = "facilities/report.html" if request.method == "POST": form = FacilityReportForm(pk, request.POST) if form.is_valid(): saved = form.save(request) return HttpResponseRedirect('/reports/ajax/reported/%d' % saved.pk) else: form = FacilityReportForm(Facility.objects.get(pk=pk).pk) if not form.has_reportables: from mailer import mail_admins mail_admins( "Facility not reportable: %s" % reverse('admin:facilities_facility_change', args=[pk]), "Please add some reportable items to rectify the situation.") return render(request, "facilities/not_reportable.html") return render(request, template, {'form': form})
def test_mail_admins(self): with self.settings(MAILER_EMAIL_BACKEND="django.core.mail.backends.locmem.EmailBackend", ADMINS=(("Test", "*****@*****.**"),)): # noqa mailer.mail_admins("Subject", "Admin Body") self.assertEqual(Message.objects.count(), 1) self.assertEqual(Message.objects.deferred().count(), 0) engine.send_all() self.assertEqual(Message.objects.count(), 0) self.assertEqual(Message.objects.deferred().count(), 0) self.assertEqual(len(mail.outbox), 1) sent = mail.outbox[0] # Default "plain text" self.assertEqual(sent.body, "Admin Body") self.assertEqual(sent.to, ["*****@*****.**"])
def private_beta_email(request): email = request.POST.get("email") PrivateBetaEmail.objects.create(email=email) mail_admins("new private beta request", "%s total: %s"%(email, PrivateBetaEmail.objects.count()), fail_silently=False) return render_to_response('maptales_app/private_beta_thanks.html', { }, context_instance=RequestContext(request))
def upload_video(request, template_name='video/upload.html'): if request.method == 'POST': form = VideoForm(request.POST, request.FILES) if form.is_valid(): vimeoClient = VimeoClient(settings.VIMEO_API_KEY, settings.VIMEO_API_SECRET) tempVideo = open(tempfile.mktemp(".AVI"), 'wb+') for chunk in form.files['video'].chunks(): tempVideo.write(chunk) try: ticked_id = vimeoClient.upload(tempVideo.name) except Exception, inst: mail_admins("Error Uploading Video", "Vimeo Video konnte nicht hochgeladen werden: "\ +str(inst.args)) return render_to_response("video/upload_error.html", { }, context_instance=RequestContext(request)) tempVideo.close() if ticked_id: video_id = vimeoClient.check_upload_status(ticked_id) if video_id: #get thumbnail url rsp = vimeoClient.call("vimeo.videos.getThumbnailUrl", {"video_id": video_id, "size":"160x120"} ) thumbnail_url = rsp.getElementsByTagName("thumbnail")[0]\ .childNodes[0].nodeValue #set the values video = Video(creator=request.user, import_url="http://vimeo.com/"+video_id, was_uploaded=True, is_viewable=False, external_id=video_id, ticket_id=ticked_id, comment=form.cleaned_data['comment'], title=form.cleaned_data['title'], tags=form.cleaned_data['tags'], thumbnail_url=thumbnail_url ) video.save(); rsp = vimeoClient.call("vimeo.videos.setTitle", { "title": form.cleaned_data['title'], "video_id": video_id } ) if(rsp.attributes['stat'].value!="ok"): mail_admins("Error", "Vimeo Titel konnte nicht gesetzt werden:\ Video_id: "+str(video.pk)) rsp = vimeoClient.call("vimeo.videos.setCaption", { "caption": form.cleaned_data['comment'], "video_id": video_id } ) if(rsp.attributes['stat'].value!="ok"): mail_admins("Error", "Vimeo Caption konnte nicht gesetzt werden:\ Video_id: "+str(video.pk)) rsp = vimeoClient.call("vimeo.videos.setPrivacy", {"privacy": "anybody", "video_id": video_id} ) if(rsp.attributes['stat'].value!="ok"): mail_admins("Error", "Vimeo Privacy konnte nicht gesetzt werden:\ Video_id: "+str(video.id)) if form.cleaned_data['tags']: tags = parse_tag_input(video.tags) tags = ",".join(tags) rsp = vimeoClient.call("vimeo.videos.addTags", {"tags": tags, "video_id": video_id} ) if(rsp.attributes['stat'].value!="ok"): mail_admins("Error", "Vimeo Tags konnten nicht gesetzt \ werden: Video_id: "+str(video.id)) return render_to_response("video/upload_success.html", { "video": video, }, context_instance=RequestContext(request)) # an error has occurred return render_to_response("video/upload_error.html", { }, context_instance=RequestContext(request)) else: request.user.message_set.create(message=_("Video '%s' was \ successfully uploaded!") % video.title) return HttpResponseRedirect(reverse('show_video', args=(video.id,)))
def send_confirmation_email(self): ##Para el alumno subject = "Has solicitado un curso de HOBETUZ en EIDE" html_content = u""" <html> <body> <div class="well"> Acaba de realizar una solicitud de curso para: <br /> %s <br> %s <br> %s <br> %s <br> %s <br> </div> <div class="well"> <p>En caso de que convoquemos un curso de los que solicita y cumpla los requisitos, no pondremos en contacto con usted para realizar un proceso de selección.</p> </div> </body> </html> """%(self.curso,self.curso2,self.curso3,self.curso4,self.curso5) message_body = html_content ##send_mail(subject, message_body, settings.DEFAULT_FROM_EMAIL, [self.email]) msg = EmailMultiAlternatives(subject, message_body, settings.DEFAULT_FROM_EMAIL, [self.email]) msg.attach_alternative(html_content, "text/html") ##msg.content_subtype = "html" msg.send() ##Para el secretaria subject = "[HOBETUZ] nueva solicitud desde la Web" payload = {'registration': self} html_content = render_to_string('hobetuz/detalle.html', payload) message_body = html_content ##send_mail(subject, message_body, settings.DEFAULT_FROM_EMAIL, [self.email]) msg = EmailMultiAlternatives(subject, message_body, settings.DEFAULT_FROM_EMAIL, ["*****@*****.**","*****@*****.**"]) msg.attach_alternative(html_content, "text/html") ##msg.content_subtype = "html" msg.send() ### Para los admins subject = "[Hobetuz]Hay una nueva solicitud para Hobetuz" message_body = u""" Se ha dado de alta una nueva solictud de hobetuz. Los datos son del solicitante son: Nombre: %s Apellidos: %s Telefono Fijo: %s Telefono Móvil: %s e-mail: %s Curso1: %s Curso2: %s Curso3: %s Curso4: %s Curso5: %s Desempleado: %s Para mas detalle visitar: https://matricula-eide.es/hobetuz/list/ """%(self.name,self.surname,self.telephone,self.telephone2,self.email,self.curso,self.curso2,self.curso3,self.curso4,self.curso5,self.desempleado) message_html = u""" <html> <body> Se ha dado de alta una nueva solictud de hobetuz. Los datos son del solicitante son: <table> <tr> <td>Nombre:</td><td> %s</td> </tr> <tr> </d>Apellidos:</td><td> %s</td> </tr> <tr> <td>Telefono Fijo:</td><td> %s</td> </tr> <tr> <td>Telefono Móvil:</td><td> %s</td> </tr> <tr> <td>e-mail:</td><td> %s</td> </tr> </table> Para mas detalle visitar: <a href="https://matricula-eide.es/hobetuz/list/">Lista</a> </body> """%(self.name,self.surname,self.telephone,self.telephone2,self.email) mail_admins(subject, message_body,False,None,message_html)
def send_confirmation_email(self): ##Para el alumno subject = "Has solicitado un curso Intensivo en EIDE" html_content = u""" <html> <head> <link rel="stylesheet" href="https://matricula-eide.es/site_media/static/css/bootstrap.min.css"> <link rel="stylesheet" href="https://matricula-eide.es/site_media/static/css/extra.css"> </head> <body> <div class="well"> Muchas gracias por la solicitud del curso: %s <br> <p>Pronto nos pondremos en contacto desde EIDE para darle más información.</p> <p>Gracias.</p> </div> <div class="well"> <p></p> </div> </body> </html> """%(self.get_curso_display()) message_body = html_content ##send_mail(subject, message_body, settings.DEFAULT_FROM_EMAIL, [self.email]) msg = EmailMultiAlternatives(subject, message_body, settings.DEFAULT_FROM_EMAIL, [self.email]) msg.attach_alternative(html_content, "text/html") ##msg.content_subtype = "html" msg.send() ##Para el secretaria subject = "[EIDE] Matricula curso intensivo" payload = {'registration': self} html_content = render_to_string('intensivos/detalle.html', payload) message_body = html_content ##send_mail(subject, message_body, settings.DEFAULT_FROM_EMAIL, [self.email]) msg = EmailMultiAlternatives(subject, message_body, settings.DEFAULT_FROM_EMAIL, ["*****@*****.**","*****@*****.**"]) msg.attach_alternative(html_content, "text/html") ##msg.content_subtype = "html" msg.send() ### Para los admins subject = u"[INTENSIVOS]Hay una nueva matrícula" message_body = u""" Se ha dado de alta una nueva solictud de intensivo. Los datos son del solicitante son: Nombre: %s Apellidos: %s Telefono : %s e-mail: %s Curso: %s Para mas detalle visitar: https://matricula-eide.es/intensivos/list/ """%(self.name,self.surname,self.telephone,self.email,self.get_curso_display) message_html = u""" <html> <body> Se ha dado de alta una nueva solictud de intensivo: Los datos son del solicitante son: <table> <tr> <td>Nombre:</td><td> %s</td> </tr> <tr> </d>Apellidos:</td><td> %s</td> </tr> <tr> <td>Teléfono:</td><td> %s</td> </tr> <tr> <td>e-mail:</td><td> %s</td> </tr> <tr> <td>Curso</td><td>%s</td> </tr> </table> Para mas detalle visitar: <a href="https://matricula-eide.es/intesivos/list/">Lista</a> </body> """%(self.name,self.surname,self.telephone,self.email,self.get_curso_display) mail_admins(subject, message_body,False,None,message_html)