Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. class EmpresaAdmin(admin.ModelAdmin):
  2. list_display = ('nome', 'telefone', 'cnpj',)
  3. search_fields = ('nome', 'cnpj',)
  4. list_filter = ( 'nome', 'cnpj', 'telefone', )
  5.  
  6.  
  7. class AssociadoAdmin(admin.ModelAdmin):
  8. list_display = ('nome', 'endereco', 'telefone', 'cpf', 'data_filiacao', 'data_nascimento' )
  9. search_fields = ('nome', 'cpf',)
  10. list_filter = ( 'nome', 'cpf', 'telefone', )
  11.  
  12. class AgendamentoAdmin(admin.ModelAdmin):
  13. list_display = ('nome','inicio', 'fim','assunto', )
  14. search_fields = ('nome', 'cpf',)
  15. list_filter = ( 'nome', 'inicio', 'assunto', )
  16.  
  17.  
  18.  
  19.  
  20. #views
  21.  
  22.  
  23. class Render:
  24. @staticmethod
  25. def render(path: str, params: dict, filename: str):
  26. template = get_template(path)
  27. html = template.render(params)
  28. response = io.BytesIO()
  29. pdf = pisa.pisaDocument(
  30. io.BytesIO(html.encode("UTF-8")), response)
  31. if not pdf.err:
  32. response = HttpResponse(
  33. response.getvalue(), content_type='application/pdf')
  34. response['Content-Disposition'] = 'attachment;filename=%s.pdf' % filename
  35. return response
  36. else:
  37. return HttpResponse("Error Rendering PDF", status=400)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement