def test_pdf(request): context = {'username': '******', 'balance': 10.01} return render_to_response('sample.odt', dictionary=context, format='pdf', filename='test.pdf', context_instance=RequestContext(request))
def docs_recenziya(request): # для студента template = webodt.ODFTemplate('recenziya.odt') user = request.user student = get_object_or_404(Student, user=user) if not student.diplomnik: raise Http404 theme = student.theme if student.sex: last_name = (lastnames_ru.inflect(morph, user.last_name.upper(), u'рд,ед,мр')).capitalize() else: last_name = (lastnames_ru.inflect(morph, user.last_name.upper(), u'рд,ед,жр')).capitalize() first_name = (morph.inflect_ru(user.first_name.upper(), u'рд,ед,имя', u'С')).capitalize() middle_name = (morph.inflect_ru(student.middle_name.upper(), u'рд,ед,отч', u'С')).capitalize() of_student_full_name = u'%s %s %s' % (last_name,first_name,middle_name) on_work_type = '' for s in student.type_of_work.name.split(): on_work_type += (morph.inflect_ru(s.upper(), u'вн,ед')).lower() + ' ' context = dict( of_student_full_name = of_student_full_name, theme = theme, on_work_type = on_work_type, ) return shortcuts.render_to_response('recenziya.odt', context)
def docs_zadanie(request): # для студента template = webodt.ODFTemplate('zadanie_na_vipusknuyu_rabotu.odt') user = request.user student = get_object_or_404(Student, user=user) if not student.diplomnik: raise Http404 theme = student.theme teacher = theme.teacher context = dict( student_full_name = u'%s %s %s' % (user.last_name, user.first_name, student.middle_name), theme = theme, teacher = teacher, theme_contents = theme.contents.splitlines(), teacher_initials = u'%s %s.%s.' % (teacher.user.last_name.capitalize(), teacher.user.first_name[0].capitalize(), teacher.middle_name[0].capitalize()), student_initials = u'%s %s.%s.' % (user.last_name.capitalize(), user.first_name[0].capitalize(), student.middle_name[0].capitalize()), ) return shortcuts.render_to_response('zadanie_na_vipusknuyu_rabotu.odt', context)
def download(self, request, *args, **kwargs): # TODO: Сделать invoice_format = kwargs['format'] filename = 'test_filename' return render_to_response(self.document_name, { 'invoice': self.invoice, }, filename=filename, format=invoice_format)
def emitir_documento(nome_template, dados=dict()): template = webodt.ODFTemplate(nome_template) # context = dict(titulo='John Doe') document = template.render(Context(dados)) return shortcuts.render_to_response(template_name=nome_template, dictionary=dados)
def test_iterator(request): iterator = request.GET.get('iterator') == 'true' context = {'username': '******', 'balance': 10.01} return render_to_response('sample.odt', dictionary=context, format='html', filename='test.html', iterator=iterator, )
def test_render_to_response(self): context = { 'username': '******', 'balance': 10.01 } response = render_to_response('sample.odt', dictionary=context, format='html') self.assertTrue('John Doe' in response.content)
def bill_print(request, pk): docs = [get_object_or_404(Bill.objects.select_related(), pk=pk)] if docs[0].seller_id != 1: doc = get_object_or_404(Bill.objects.select_related(), pk=pk) doc.agent = doc.seller.agent doc.seller = doc.bkz docs.append(doc) return render_to_response('webodt/torg-12.odt',{'docs':docs},format='pdf',inline=True)
def test_iterator(request): iterator = request.GET.get('iterator') == 'true' context = {'username': '******', 'balance': 10.01} return render_to_response( 'sample.odt', dictionary=context, format='html', filename='test.html', iterator=iterator, )
def test_pdf_from_html(request): context = {'username': '******', 'balance': 10.01} return render_to_response( 'sample.html', dictionary=context, format='pdf', filename='test1.pdf', context_instance=RequestContext(request), cache=None, )
def batch_print_doc(request, pk): batch = get_object_or_404(Batch.objects.select_related(), pk=pk) parts = batch.parts.all() part, part2 = False, False if len(parts) and parts[0].defect == 'gost': part = parts[0] if len(parts) == 2 and parts[1].defect == 'gost': part2 = parts[1] return render_to_response('webodt/document-the-quality-of.odt', {'part': part, 'part2': part2}, format='pdf', inline=True)
def docs_zayavlenie(request): # для студента template = webodt.ODFTemplate('zayavlenie_na_vipusknuyu_rabotu.odt') user = request.user student = get_object_or_404(Student, user=user) if not student.diplomnik: raise Http404 theme = student.theme teacher = theme.teacher if student.sex: last_name = (lastnames_ru.inflect(morph, user.last_name.upper(), u'рд,ед,мр')).capitalize() else: last_name = (lastnames_ru.inflect(morph, user.last_name.upper(), u'рд,ед,жр')).capitalize() first_name = (morph.inflect_ru(user.first_name.upper(), u'рд,ед,имя', u'С')).capitalize() middle_name = (morph.inflect_ru(student.middle_name.upper(), u'рд,ед,отч', u'С')).capitalize() from_student_full_name = u'%s %s %s' % (last_name,first_name,middle_name) in_month=(morph.inflect_ru(student.month.upper(), u'пр')).lower() work_type = '' for s in student.type_of_work.name.split(): work_type += (morph.inflect_ru(s.upper(), u'рд,ед')).lower() + ' ' to_teacher_position = '' for s in teacher.position.split(): to_teacher_position += (morph.inflect_ru(s.upper(), u'вн,ед')).lower() + ' ' if teacher.sex: to_teacher_last_name = (lastnames_ru.inflect(morph, teacher.user.last_name.upper(), \ u'вн,ед,мр')).capitalize() else: to_teacher_last_name = (lastnames_ru.inflect(morph, teacher.user.last_name.upper(), \ u'вн,ед,жр')).capitalize() context = dict( from_student_full_name=from_student_full_name, work_type=work_type, in_month=in_month, theme = theme, teacher = teacher, student = student, theme_contents = theme.contents, to_teacher_position = to_teacher_position, to_teacher_initials = u'%s %s.%s.' % (to_teacher_last_name, teacher.user.first_name[0].capitalize(), teacher.middle_name[0].capitalize()), student_initials = u'%s %s.%s.' % (user.last_name.capitalize(), user.first_name[0].capitalize(), student.middle_name[0].capitalize()), ) return shortcuts.render_to_response('zayavlenie_na_vipusknuyu_rabotu.odt', context)
def test_pdf_from_html(request): context = {'username': '******', 'balance': 10.01} return render_to_response('sample.html', dictionary=context, format='pdf', filename='test1.pdf', context_instance=RequestContext(request), cache=None, )
def test_render_to_response(self): context = {"username": "******", "balance": 10.01} response = render_to_response("sample.odt", dictionary=context, format="html") self.assertTrue("John Doe" in response.content)
def batch_print_akt(request, pk): batch = get_object_or_404(Batch.objects.select_related(), pk=pk) return render_to_response('webodt/akt-out.odt', {'batch': batch}, format='pdf', inline=True)
def test_pdf(request): context = {'username': '******', 'balance': 10.01} return render_to_response('sample.odt', dictionary=context, format='pdf', filename='test.pdf', context_instance=RequestContext(request) )
def emitir_documento(nome_template, dados=dict()): template = webodt.ODFTemplate(nome_template) # context = dict(titulo='John Doe') document = template.render(Context(dados)) return shortcuts.render_to_response(template_name= nome_template, dictionary=dados)