def class_wise_report(request): if not request.session['employee_id']: return redirect('/login/') class_list = models.ClassInfo.objects.filter(status = True) shift_list = models.Shift.objects.filter(status = True) school_info = models.SchoolProfile.objects.filter(status = True).first() if request.method == "POST": class_name = int(request.POST['class_name']) shift_name = int(request.POST['shift_name']) class_wise_report = models.Result.objects.filter( class_name_id = class_name, shift_name_id = shift_name) context = { 'class_list':class_list, 'shift_list':shift_list, 'class_name':class_name, 'shift_name':shift_name, 'school_info':school_info, 'class_wise_report':class_wise_report, } if class_wise_report: pdf = render_to_pdf('school/admin/report/class_wise_report_pdf.html',context) return HttpResponse(pdf, content_type='application/pdf') else: context = { 'class_list':class_list, 'shift_list':shift_list, 'class_name':class_name, 'shift_name':shift_name, } messages.error(request, "No Data Found!") return render(request, 'school/admin/report/class_wise_report.html', context) return render(request, 'school/admin/report/class_wise_report.html',{"class_list" : class_list, 'shift_list':shift_list})
def get(self, request, *args, **kwargs): template = get_template('pdf.html') context = { 'today': 'Mayur', 'amount': 39.99, 'customer_name': 'Cooper Mann', 'order_id': 1233434, } html = template.render(context) pdf = render_to_pdf('pdf.html', context) return HttpResponse(pdf, content_type='application/pdf')
def get(self, request, pk, *args, **kwargs): template = get_template('pdf/invoice.html') contexts = Staffinfo.objects.get(id=pk) bill = Staff_Payment_Bill.objects.filter( staffinfo=contexts).order_by('-id')[0] #bill=s.objects.order_by('paid_date').first() context = {"context": bill, "student": contexts} html = template.render(context) pdf = render_to_pdf('pdf/invoice.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")
def get_your_copy(request): image = SchoolLogo.objects.all() reg = request.POST.get('reg') pin = request.POST.get('pin') gen = GeneratePin.objects.get(Registration_Number=reg, pin=pin) result = GeneralResult.objects.get( Registration_Number=gen.Registration_Number, current_session=gen.current_session, current_class=gen.current_class) s = Session.objects.get(date=gen.current_session) total_student = Student.objects.filter( current_class=gen.current_class).count() record = Student_subject.objects.filter( Registration_Number=gen.Registration_Number, session=s.id, term=1, current_class=gen.current_class).exclude(average=0) template = get_template('administrator/check_result.html') context = { 'gen': gen, 'result': result, 'record': record, 'total_student': total_student, 'image': image, 'reg': reg, 'pin': pin } html = template.render(context) pdf = render_to_pdf('administrator/check_result.html', context) if pdf: response = HttpResponse(pdf, content_type='application/pdf') filename = "%s_article.pdf" % ('post_title') 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")