Browse Source

Merge branch '3.1.x' into Add-cont_mult-pdf-resumo

pull/2731/head
João Rodrigues 7 years ago
committed by GitHub
parent
commit
2d2f2a0eb5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      sapl/lexml/OAIServer.py

14
sapl/lexml/OAIServer.py

@ -11,6 +11,7 @@ from lxml.builder import ElementMaker
from sapl.base.models import AppConfig, CasaLegislativa from sapl.base.models import AppConfig, CasaLegislativa
from sapl.lexml.models import LexmlPublicador, LexmlProvedor from sapl.lexml.models import LexmlPublicador, LexmlProvedor
from sapl.norma.models import NormaJuridica from sapl.norma.models import NormaJuridica
from sapl.utils import LISTA_DE_UFS
class OAILEXML: class OAILEXML:
@ -127,17 +128,18 @@ class OAIServer:
urn = 'urn:lex:br;' urn = 'urn:lex:br;'
esferas = {'M': 'municipal', 'E': 'estadual'} esferas = {'M': 'municipal', 'E': 'estadual'}
municipio = casa.municipio.lower() municipio = casa.municipio.lower()
uf = casa.uf.lower() uf_map = dict(LISTA_DE_UFS)
uf_desc = uf_map.get(casa.uf.upper(), '').lower()
for x in [' ', '.de.', '.da.', '.das.', '.do.', '.dos.']: for x in [' ', '.de.', '.da.', '.das.', '.do.', '.dos.']:
municipio = municipio.replace(x, '.') municipio = municipio.replace(x, '.')
uf = uf.replace(x, '.') uf_desc = uf_desc.replace(x, '.')
if esfera == 'M': if esfera == 'M':
urn += '{};{}:'.format(uf, municipio) urn += '{};{}:'.format(uf_desc, municipio)
if norma.tipo.equivalente_lexml == 'regimento.interno' or norma.tipo.equivalente_lexml == 'resolucao': if norma.tipo.equivalente_lexml == 'regimento.interno' or norma.tipo.equivalente_lexml == 'resolucao':
urn += 'camara.' urn += 'camara.'
urn += esferas[esfera] + ':' urn += esferas[esfera] + ':'
elif esfera == 'E': elif esfera == 'E':
urn += '{}:{}:'.format(uf, esferas[esfera]) urn += '{}:{}:'.format(uf_desc, esferas[esfera])
else: else:
urn += ':' urn += ':'
if norma.tipo.equivalente_lexml: if norma.tipo.equivalente_lexml:
@ -189,13 +191,13 @@ class OAIServer:
else: else:
formato = 'text/html' formato = 'text/html'
url_conteudo = BASE_URL_SAPL + reverse('sapl.norma:normajuridica_detail', url_conteudo = BASE_URL_SAPL + reverse('sapl.norma:normajuridica_detail',
kwargs={'pk': norma.numero}) kwargs={'pk': norma.pk})
element_maker = ElementMaker() element_maker = ElementMaker()
id_publicador = str(publicador.id_publicador) id_publicador = str(publicador.id_publicador)
item_conteudo = element_maker.Item(url_conteudo, formato=formato, idPublicador=id_publicador, item_conteudo = element_maker.Item(url_conteudo, formato=formato, idPublicador=id_publicador,
tipo='conteudo') tipo='conteudo')
oai_lexml.append(item_conteudo) oai_lexml.append(item_conteudo)
url = BASE_URL_SAPL + reverse('sapl.norma:normajuridica_detail', kwargs={'pk': norma.numero}) url = BASE_URL_SAPL + reverse('sapl.norma:normajuridica_detail', kwargs={'pk': norma.pk})
item_metadado = element_maker.Item(url, formato='text/html', idPublicador=id_publicador, tipo='metadado') item_metadado = element_maker.Item(url, formato='text/html', idPublicador=id_publicador, tipo='metadado')
oai_lexml.append(item_metadado) oai_lexml.append(item_metadado)
documento_individual = element_maker.DocumentoIndividual(urn) documento_individual = element_maker.DocumentoIndividual(urn)

Loading…
Cancel
Save