示例#1
0
 def get(self, request, *args, **kwargs):
     pdf = render_to_pdf('pages/pdf_template.html', data)
     response = HttpResponse(pdf, content_type='application/pdf')
     filename = "Invoice_%s.pdf" % ("12341231")
     content = "attachment; filename=%s" % (filename)
     response['Content-Disposition'] = content
     return response
示例#2
0
def print_enforcement_field(request, field_id):

    field_request = get_enforcement_field(field_id)

    context = {"field_request": field_request}
    pdf = render_to_pdf(
        'enforcement/reports/field_enforcment_detail_report.html', context)
    return HttpResponse(pdf, content_type='application/pdf')
示例#3
0
 def get(self, request, *args, **kwargs):
     acessos = Acesso.objects.all()
     data = {
         'acessos': acessos,
     }
     pdf = render_to_pdf('pdf/invoice.html', data)
     response = HttpResponse(pdf, content_type='application/pdf')
     response['Content-Disposition'] = 'attachment; filename="report.pdf"'
     return response
示例#4
0
def gen_ses_pdf(request, pk):
    session_data = sessiontList(generic.ListView)
    session = Session.objects.all().order_by('pk')
    part_list = session.objects.prefetch_related('participant')
    total_participant = part_list.count()
    context = {
        'session_data': session_data,
        'part_list': part_list,
        'total_participant': total_participant
    }
    participants = render_to_pdf('pages/pdf_ses_list.html', context)
    return participants
示例#5
0
def gen_pdf(request):
    # resp = HttpResponse(pdf, content_type='application/pdf')
    session = Session.objects.all().order_by("-pk")
    total_session = session.count()
    date = datetime.date.today()
    date = datetime.date.strftime(date, '%d-%b-%Y')
    context = {
        'session': session,
        'total_session': total_session,
        'date': date
    }
    result = render_to_pdf('pages/pdf_ses_temp.html', context)
    return result
示例#6
0
 def get(self, request, *args, **kwargs):
     participant = Participant.objects.all()
     participants = ParticipantFilter(request.GET, queryset=participant)
     date = datetime.date.today()
     date = datetime.date.strftime(date, '%d-%b-%Y')
     context = {'filter': participants, 'date': date}
     pdf = render_to_pdf('pages/pdf_part_list.html', context)
     response = HttpResponse(pdf, content_type='application/pdf')
     filename = 'Participants' + str(
         datetime.datetime.now()) + "_%s.pdf" % ("12341231")
     content = "attachment; filename=%s" % (filename)
     response['Content-Disposition'] = content
     return response
示例#7
0
def LoadEngineerDataInPdf(request, id):
	engineersign = Engineer.objects.get(id = id).engineersign
	CUSTOMER = Engineer.objects.get(id = id).CUSTOMER
	STORE = Engineer.objects.get(id = id).STORE
	STORE_NO = Engineer.objects.get(id = id).STORE_NO
	CALL_OUT_NO = Engineer.objects.get(id = id).CALL_OUT_NO
	managersign = Engineer.objects.get(id = id).managersign
	data = {
		"engineersign" : engineersign,
		"CUSTOMER" : CUSTOMER,
		"STORE":STORE,
		"STORE_NO":STORE_NO,
		"CALL_OUT_NO":CALL_OUT_NO,
		"managersign":managersign,
    }
	pdf = render_to_pdf('pdf/invoice.html', data)
	return HttpResponse(pdf, content_type='application/pdf')
示例#8
0
    def get(self, request, *args, **kwargs):
        template = ('pages/pdf_participant_list.html')
        session_data = Session.objects.get(id=kwargs['id'])
        date = datetime.date.today()
        date = datetime.date.strftime(date, '%d-%b-%Y')

        context = {
            'session_data': session_data,
            'date': date,
        }
        pdf = render_to_pdf(template, context)
        response = HttpResponse(pdf, content_type='application/pdf')
        filename = "Participants-List-" + str(
            session_data.name_of_activity) + ".pdf"
        content = "attachment; filename=%s" % (filename)
        response['Content-Disposition'] = content
        return (response)
示例#9
0
    def get(self, request, *args, **kwargs):
        session_old = Session.objects.all()
        sessions_q = sessionFilter(request.GET, queryset=session_old)
        total_session = session_old.count()
        date = datetime.date.today()
        date = datetime.date.strftime(date, '%d-%b-%Y')

        context = {
            'filter': sessions_q,
            'total_session': total_session,
            'date': date
        }
        pdf = render_to_pdf('pages/pdf_ses_print.html', context)
        response = HttpResponse(pdf, content_type='application/pdf')
        filename = "Session_%s.pdf" % ("12341231")
        content = "attachment; filename=%s" % (filename)
        response['Content-Disposition'] = content
        return response
示例#10
0
 def get(self, request, pk, **kwargs):
     bolsista = Bolsista.objects.get(pk=pk)
     acessos = Acesso.objects.filter(bolsista=bolsista).exclude(
         hora_saida=None)
     if acessos.exists():
         th = acessos.aggregate(total=Sum('total_horas'))
     else:
         th = '--'
     data = {
         'bolsista': bolsista,
         'acessos': acessos,
         'th': th,
     }
     pdf = render_to_pdf('pdf/invoice.html', data)
     response = HttpResponse(pdf, content_type='application/pdf')
     response[
         'Content-Disposition'] = 'attachment; filename=Relatório %s.pdf' % (
             bolsista.nome)
     return response
示例#11
0
    def get(self, request, data_ini, data_fim, pk):
        if not pk == '0':
            bolsista = Bolsista.objects.get(pk=pk)
            acessos = Acesso.objects.filter(
                data__range=(data_ini, data_fim),
                bolsista=bolsista).exclude(hora_saida=None)
            titulo = '%s' % (bolsista.nome)
            is_todos = '0'

        else:
            bolsista = Bolsista.objects.all()
            acessos = Acesso.objects.filter(
                data__range=(data_ini, data_fim)).exclude(hora_saida=None)
            titulo = 'TODOS BOLSISTAS'
            is_todos = '1'

#		bolsistas = Bolsista.objects.get(pk=pk)

#		acessos = Acesso.objects.filter(data__range=(data_ini,data_fim))

        if acessos.exists():
            th = acessos.aggregate(total=Sum('total_horas'))
        else:
            th = '--'


#		th = acessos.aggregate(total=Sum('total_horas'))
        d1 = datetime.datetime.strptime(data_ini, "%Y-%m-%d").date()
        d2 = datetime.datetime.strptime(data_fim, "%Y-%m-%d").date()
        data = {
            'acessos': acessos,
            'th': th,
            'bolsistas': bolsista,
            'data_inicio': d1.strftime("%d/%m/%Y"),
            'data_fim': d2.strftime("%d/%m/%Y"),
            'titulo': titulo,
            'is_todos': is_todos,
        }
        pdf = render_to_pdf('pdf/relatorio_periodo.html', data)
        response = HttpResponse(pdf, content_type='application/pdf')
        response[
            'Content-Disposition'] = 'attachment; filename=RelatorioPeriodoBolsista.pdf'
        return response
示例#12
0
    def form_valid(self, form):
        # print(form.cleaned_data)

        obj = form.save(commit=False)
        obj.managersign = form.cleaned_data['managersign_data']

        obj.save()

        engineersignb = Engineer.objects.get(id=obj.id).engineersign
        CUSTOMER = Engineer.objects.get(id=obj.id).CUSTOMER
        STORE = Engineer.objects.get(id=obj.id).STORE
        STORE_NO = Engineer.objects.get(id=obj.id).STORE_NO
        CALL_OUT_NO = Engineer.objects.get(id=obj.id).CALL_OUT_NO

        managersign = Engineer.objects.get(id=obj.id).managersign

        dataaa = {
            "engineersign": engineersignb,
            "CUSTOMER": CUSTOMER,
            'STORE': STORE,
            "STORE_NO": STORE_NO,
            "CALL_OUT_NO": CALL_OUT_NO,
            'managersign': managersign,
        }

        html = render_to_string('pdf/invoice.html', dataaa)
        pdf = weasyprint.HTML(string=html).write_pdf()

        to_emails = ['*****@*****.**']
        subject = "Certificate from " + STORE
        message = "Report Approved"
        email = EmailMessage(subject,
                             body=message,
                             from_email=settings.EMAIL_HOST_USER,
                             to=to_emails)
        email.attach("certificate.pdf", pdf, "application/pdf")
        email.content_subtype = "html"  # Main content is now text/html
        email.encoding = 'us-ascii'
        email.send()

        renderpdf = render_to_pdf('pdf/invoice.html', dataaa)
        return HttpResponse(renderpdf, content_type='application/pdf')
示例#13
0
    def get(self, request, data_ini, data_fim):
        acessos = Acesso.objects.filter(data__range=(data_ini, data_fim))

        #th = acessos.aggregate(total=Sum('total_horas'))
        if acessos.exists():
            th = acessos.aggregate(total=Sum('total_horas'))
        else:
            th = '--'
        d1 = datetime.datetime.strptime(data_ini, "%Y-%m-%d").date()
        d2 = datetime.datetime.strptime(data_fim, "%Y-%m-%d").date()
        data = {
            'acessos': acessos,
            'th': th,
            'data_inicio': d1.strftime("%d/%m/%Y"),
            'data_fim': d2.strftime("%d/%m/%Y"),
        }
        pdf = render_to_pdf('pdf/relatorio_periodo.html', data)
        response = HttpResponse(pdf, content_type='application/pdf')
        response[
            'Content-Disposition'] = 'attachment; filename=RelatorioPeriodo.pdf'
        return response
示例#14
0
    def get(self, request, *args, **kwargs):
        template = get_template('index.html')
        context = {
            "invoice_id": 123,
            "customer_name": "John Cooper",
            "amount": 1399.99,
            "today": "Today",
        }
        html = template.render(context)
        pdf = render_to_pdf('index.html', context)
        if pdf:
            response = HttpResponse(pdf, content_type='application/pdf')
            filename = "Invoice_%s.pdf" %("12341231")
            content = "inline; filename='%s'" %(filename)
            download = request.GET.get("download")
            if download:
                content = "attachment; filename='%s'" %(filename)
            response['Content-Disposition'] = content
            return response
        return HttpResponse("Not found")

# download the file by typing in url ../?download=true
示例#15
0
	def form_valid(self, form, *args, **kwargs):
		obj = form.save()
		# print(obj.id)

		engineersign = Engineer.objects.get(id = obj.id).engineersign
		CUSTOMER = Engineer.objects.get(id = obj.id).CUSTOMER
		STORE = Engineer.objects.get(id = obj.id).STORE
		STORE_NO = Engineer.objects.get(id = obj.id).STORE_NO
		CALL_OUT_NO = Engineer.objects.get(id = obj.id).CALL_OUT_NO
		newid = obj.id
		print(newid)
		data = {
			"engineersign" : engineersign,
			"CUSTOMER" : CUSTOMER,
			"STORE":STORE,
			"STORE_NO":STORE_NO,
			"CALL_OUT_NO":CALL_OUT_NO,
			"newid" :newid,

	 	}
	 
		# html = render_to_string('pdf/rendertostring.html',context)
		# pdf = weasyprint.HTML(string=html).write_pdf()


		# to_emails = ['*****@*****.**', '*****@*****.**']
		# subject = "Certificate from " + CUSTOMER
		# message = render_to_string('pdf/rendertostring.html', context)
		# email = EmailMessage(subject, body=message, from_email=settings.EMAIL_HOST_USER, to=to_emails)
		# # email.attach("certificate.pdf", pdf, "application/pdf")
		# email.content_subtype = "html"  # Main content is now text/html
		# email.encoding = 'us-ascii'
		# email.send()

		renderpdf = render_to_pdf('pdf/invoice.html', data)
		return HttpResponse(renderpdf, content_type='application/pdf')
示例#16
0
 def get(self, request, *args, **kwargs):
     pdf = render_to_pdf('pages/pdf_template.html', data)
     return HttpResponse(pdf, content_type='application/pdf')
示例#17
0
def export_search_pdf(request):
    sess_filter = sess_filter_search()
    context = {'filter': sess_filter}
    result = render_to_pdf('pages/pdf_ses_print.html', context)
    return result