diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 0f856ede3..c3036d52e 100644 --- a/sapl/materia/views.py +++ b/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() diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 0e0ed23e4..c145705b5 100644 --- a/sapl/norma/views.py +++ b/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 @@ -196,9 +198,8 @@ class NormaCrud(Crud): estatisticas_acesso_normas = AppConfig.objects.first().estatisticas_acesso_normas if estatisticas_acesso_normas == 'S': NormaEstatisticas.objects.create(usuario=str(self.request.user), - norma_id=kwargs['pk']) + norma_id=kwargs['pk']) return super().get(request, *args, **kwargs) - class DeleteView(Crud.DeleteView): @@ -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 @@ -233,7 +236,7 @@ class NormaCrud(Crud): class ListView(Crud.ListView, RedirectView): def get_redirect_url(self, *args, **kwargs): - namespace = self.model._meta.app_config.name + namespace = self.model._meta.app_config.name return reverse('%s:%s' % (namespace, 'norma_pesquisa')) def get(self, request, *args, **kwargs): @@ -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()