From fa3071a6b6b406c4210535380482531bde55bff3 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Thu, 28 Feb 2019 19:37:38 -0300 Subject: [PATCH] Fixes #2560 --- sapl/lexml/models.py | 6 ++++++ sapl/lexml/views.py | 15 ++++++++++++--- sapl/templates/lexml/layouts.yaml | 6 ++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/sapl/lexml/models.py b/sapl/lexml/models.py index f6315d399..eeab71f73 100644 --- a/sapl/lexml/models.py +++ b/sapl/lexml/models.py @@ -23,6 +23,12 @@ class LexmlProvedor(models.Model): # LexmlRegistroProvedor blank=True, verbose_name=_('XML fornecido pela equipe do LexML:')) + @property + def pretty_xml(self): + import html + safe_xml = html.escape(self.xml) + return safe_xml.replace('\n', '
').replace(' ', ' ') + class Meta: verbose_name = _('Provedor Lexml') verbose_name_plural = _('Provedores Lexml') diff --git a/sapl/lexml/views.py b/sapl/lexml/views.py index bed7f29d4..200460bbc 100644 --- a/sapl/lexml/views.py +++ b/sapl/lexml/views.py @@ -1,15 +1,23 @@ from django.http import HttpResponse from django.shortcuts import render -from sapl.crud.base import CrudAux +from sapl.crud.base import CrudAux, Crud from sapl.lexml.OAIServer import OAIServerFactory, get_config +from sapl.rules import RP_DETAIL, RP_LIST from .models import LexmlProvedor, LexmlPublicador -LexmlProvedorCrud = CrudAux.build(LexmlProvedor, 'lexml_provedor') LexmlPublicadorCrud = CrudAux.build(LexmlPublicador, 'lexml_publicador') +class LexmlProvedorCrud(Crud): + model = LexmlProvedor + help_topic = 'lexml_provedor' + public = [RP_LIST, RP_DETAIL] + + class DetailView(Crud.DetailView): + layout_key = 'LexmlProvedorDetail' + def lexml_request(request): config = get_config(request.get_raw_uri(), int(request.GET.get('batch_size', '10'))) oai_server = OAIServerFactory(config) @@ -17,5 +25,6 @@ def lexml_request(request): response = r.decode('UTF-8') return HttpResponse(response, content_type='text/xml') + def request_search(request, keyword): - return render(request,"lexml/resultado-pesquisa.html",{"keyword":keyword}) \ No newline at end of file + return render(request, "lexml/resultado-pesquisa.html", {"keyword":keyword}) diff --git a/sapl/templates/lexml/layouts.yaml b/sapl/templates/lexml/layouts.yaml index 1dc354bd2..23df277c3 100644 --- a/sapl/templates/lexml/layouts.yaml +++ b/sapl/templates/lexml/layouts.yaml @@ -5,6 +5,12 @@ LexmlProvedor: - id_responsavel:2 nome_responsavel email_responsavel - xml +LexmlProvedorDetail: + {% trans 'Provedor Lexml' %}: + - id_provedor:2 nome + - id_responsavel:2 nome_responsavel email_responsavel + - pretty_xml + LexmlPublicador: {% trans 'Publicador Lexml' %}: - id_publicador:2 nome sigla