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): def gerar_pdf_impressos(request, context, template_name):
template = loader.get_template(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() pdf = weasyprint.HTML(string=html, base_url=request.build_absolute_uri()
).write_pdf() ).write_pdf()

18
sapl/norma/views.py

@ -1,8 +1,6 @@
import logging import logging
import re import re
import sapl
import weasyprint
from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import ObjectDoesNotExist 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.base import RedirectView
from django.views.generic.edit import FormView from django.views.generic.edit import FormView
from django_filters.views import FilterView from django_filters.views import FilterView
import weasyprint
from sapl import settings from sapl import settings
import sapl
from sapl.base.models import AppConfig from sapl.base.models import AppConfig
from sapl.compilacao.views import IntegracaoTaView from sapl.compilacao.views import IntegracaoTaView
from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux, 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['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr) 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 return context
@ -199,7 +201,6 @@ class NormaCrud(Crud):
norma_id=kwargs['pk']) norma_id=kwargs['pk'])
return super().get(request, *args, **kwargs) return super().get(request, *args, **kwargs)
class DeleteView(Crud.DeleteView): class DeleteView(Crud.DeleteView):
def get_success_url(self): def get_success_url(self):
@ -218,12 +219,14 @@ class NormaCrud(Crud):
username = self.request.user.username username = self.request.user.username
try: 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 = sapl.base.models.AppConfig.objects.last(
).esfera_federacao ).esfera_federacao
self.initial['esfera_federacao'] = esfera self.initial['esfera_federacao'] = esfera
except: 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 pass
self.initial['complemento'] = False self.initial['complemento'] = False
return self.initial return self.initial
@ -332,6 +335,7 @@ class AutoriaNormaCrud(MasterDetailCrud):
}) })
return initial return initial
class ImpressosView(PermissionRequiredMixin, TemplateView): class ImpressosView(PermissionRequiredMixin, TemplateView):
template_name = 'materia/impressos/impressos.html' template_name = 'materia/impressos/impressos.html'
permission_required = ('materia.can_access_impressos', ) permission_required = ('materia.can_access_impressos', )
@ -339,7 +343,7 @@ class ImpressosView(PermissionRequiredMixin, TemplateView):
def gerar_pdf_impressos(request, context, template_name): def gerar_pdf_impressos(request, context, template_name):
template = loader.get_template(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() pdf = weasyprint.HTML(string=html, base_url=request.build_absolute_uri()
).write_pdf() ).write_pdf()

Loading…
Cancel
Save