Browse Source

Fixes #2560

pull/2583/head
Edward Ribeiro 6 years ago
parent
commit
fa3071a6b6
  1. 6
      sapl/lexml/models.py
  2. 13
      sapl/lexml/views.py
  3. 6
      sapl/templates/lexml/layouts.yaml

6
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', '<br/>').replace(' ', '&nbsp;')
class Meta:
verbose_name = _('Provedor Lexml')
verbose_name_plural = _('Provedores Lexml')

13
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})

6
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

Loading…
Cancel
Save