Browse Source

Fix #2451 - adequação ao django 1.11

pull/2457/head
Leandro Roberto 6 years ago
parent
commit
15542b4387
  1. 2
      sapl/materia/views.py
  2. 18
      sapl/norma/views.py

2
sapl/materia/views.py

@ -2175,7 +2175,7 @@ class ImpressosView(PermissionRequiredMixin, TemplateView):
def gerar_pdf_impressos(request, context, template_name):
template = loader.get_template(template_name)
html = template.render(RequestContext(request, context))
html = template.render(context, request)
pdf = weasyprint.HTML(string=html, base_url=request.build_absolute_uri()
).write_pdf()

18
sapl/norma/views.py

@ -1,8 +1,6 @@
import logging
import re
import sapl
import weasyprint
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import ObjectDoesNotExist
@ -15,7 +13,10 @@ from django.views.generic import TemplateView, UpdateView
from django.views.generic.base import RedirectView
from django.views.generic.edit import FormView
from django_filters.views import FilterView
import weasyprint
from sapl import settings
import sapl
from sapl.base.models import AppConfig
from sapl.compilacao.views import IntegracaoTaView
from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux,
@ -108,7 +109,8 @@ class NormaPesquisaView(FilterView):
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr)
context['USE_SOLR'] = settings.USE_SOLR if hasattr(settings, 'USE_SOLR') else False
context['USE_SOLR'] = settings.USE_SOLR if hasattr(
settings, 'USE_SOLR') else False
return context
@ -199,7 +201,6 @@ class NormaCrud(Crud):
norma_id=kwargs['pk'])
return super().get(request, *args, **kwargs)
class DeleteView(Crud.DeleteView):
def get_success_url(self):
@ -218,12 +219,14 @@ class NormaCrud(Crud):
username = self.request.user.username
try:
self.logger.debug('user=' + username + '. Tentando obter objeto de modelo da esfera da federação.')
self.logger.debug(
'user=' + username + '. Tentando obter objeto de modelo da esfera da federação.')
esfera = sapl.base.models.AppConfig.objects.last(
).esfera_federacao
self.initial['esfera_federacao'] = esfera
except:
self.logger.error('user=' + username + '. Erro ao obter objeto de modelo da esfera da federação.')
self.logger.error(
'user=' + username + '. Erro ao obter objeto de modelo da esfera da federação.')
pass
self.initial['complemento'] = False
return self.initial
@ -332,6 +335,7 @@ class AutoriaNormaCrud(MasterDetailCrud):
})
return initial
class ImpressosView(PermissionRequiredMixin, TemplateView):
template_name = 'materia/impressos/impressos.html'
permission_required = ('materia.can_access_impressos', )
@ -339,7 +343,7 @@ class ImpressosView(PermissionRequiredMixin, TemplateView):
def gerar_pdf_impressos(request, context, template_name):
template = loader.get_template(template_name)
html = template.render(RequestContext(request, context))
html = template.render(context, request)
pdf = weasyprint.HTML(string=html, base_url=request.build_absolute_uri()
).write_pdf()

Loading…
Cancel
Save