actualización cero

This commit is contained in:
Juan Burgos
2026-08-03 14:57:44 +00:00
parent d073a071ad
commit 3ae490f25f
9 changed files with 1786 additions and 2 deletions

View File

@@ -1,3 +1,69 @@
# sprpcb-exportpdf-func
# exportPDF
Funcionalidad para exportar datos de un recurso a un archivo PDF
Funcionalidad para implementar la capacidad de exportar los datos de un recurso a formato PDF.
Los modelos de recursos habilitados para la función son los siguientes:
* Patrimonio material - Bienes inmuebles
* Patrimonio material - Bienes muebles
* Patrimonio inmaterial
* Organización o persona
# Para agregar la funcionalidad ExportPDF a un proyecto de Arches puede seguir el siguiente procedimiento.
Procedimiento válido para un proyecto en modo desarrollo implementado con un enfoque tradicional sin contenedores.
Para el caso de un enfoque utilizando contenedores o en moo Producción, el procesos varía levemente.
### 1. Clonar este repositorio en alguna carpeta de su servidor).
```shell
pip install git+https://gitea.patrimonio.org.bo/sysadmin/sprpcb-resumen-app.git
```
### 2. Agregar la vista personalizada creando (copiando) la carpeta indicada y moviendo la vista adentro:
```properties
INSTALLED_APPS = (
# otras aplicaciones ya enumeradas
"resumen",
"arches_proy", # Ensure the project is listed before any other arches applications
)
```
### 3. Agregar la entrada de ruta en el archivo urls.py del proyecto:
```shell
from django.urls import include, re_path, path # re_path añadido
urlpatterns = [
re_path(r"^", include("resumen.urls")), # Línea añadida
# project-level urls
]
```
### 4. Copiar las plantillas de la funcionalidad correspondientes a los modelos de recursos:
```python
python manage.py migrate
```
### 5. Copiar los arachivos necesarios para una nueva plantilla de reporte:
```python
python manage.py migrate
```
### 6. Registrar la plantilla personalizada de proyecto que agrega los botones necesarios:
```python
python manage.py migrate
```
### 7. A continuación, asegúrese de reconstruir la interfaz de su proyecto para incluir el complemento:
```
npm run build_development
```
### 8. Cuando haya terminado, debería ver los botones de exportar en la ventana de vista de reporte de su modelo de recursos:
![image.png](https://gitea.patrimonio.org.bo/sysadmin/sprpcb-resumen-app/attachments/a9b5011e-ce70-482e-8953-da45ff04ca1c)
### 9. Forma de uso:
```
```

Binary file not shown.

166
pdf/views.py Normal file
View File

@@ -0,0 +1,166 @@
# mi_proyecto/pdf/views.py
# dpsk - 2026
import io
from pathlib import Path
from django.http import HttpResponse
from django.template.loader import render_to_string
from weasyprint import HTML
from arches.app.models.resource import Resource
from django.contrib.auth.models import Group
from datetime import datetime
from zoneinfo import ZoneInfo
from functools import reduce
from operator import getitem
from pypdf import PdfReader, PdfWriter
import json
import ast
def ajustar_medios(resource_media_rel, medios_list):
medios = []
img=["image/bmp", "image/gif", "image/jpg", "image/jpeg", "image/png", "image/tif", "image/tiff"]
no_imagen_principal = True
try:
if isinstance(medios_list, list) :
for rel in resource_media_rel['related_resources']:
if isinstance(medios_list[0], dict) :
medio=next((item for item in medios_list if item['@value'] == rel['displayname']), None)
else:
medio = None
for til in rel['tiles']:
for dato in til['data']:
if isinstance(til['data'][dato], list):
for dat in til['data'][dato]:
idx = " - " + str(dat['index'] +1) if len(til['data'][dato])>1 else ""
if medio is not None and isinstance(medio, dict):
medio_nuevo = {'tipo': val for key, val in medio.items() if "Tipo" in key}
else:
if dat['type'] in img and no_imagen_principal:
medio_nuevo = {'tipo':'Imagen principal'}
no_imagen_principal = False
else:
medio_nuevo = {'tipo':'Medio'}
medio_nuevo.update({'@value':rel['displayname']+idx, 'file':dat['name'], 'url': dat['url'], 'formato':dat['type']})
medios.append(medio_nuevo)
# Reordenamos para que el primer medio de la lista sea de tipo Imagen principal o al menos del tipo imagen
medios.sort(key=lambda item: item.get('formato') not in img)
medios.sort(key=lambda item: item.get('tipo') != 'Imagen principal')
except:
pass
return medios
def find_key_path(data, target_key, current_path=None):
if current_path is None:
current_path = []
# Verifica si es diccionario válido
if isinstance(data, dict):
for key, value in data.items():
# si la clave buscada está en el nivel actual del diccionario.
if key == target_key:
return current_path + [key]
# Profundiza en el rastreo mientras agrega la clave actual a la ruta.
path = find_key_path(value, target_key, current_path + [key])
if path:
return path
# En caso de que la clave esté dentro de una lista
elif isinstance(data, list):
for index, item in enumerate(data):
path = find_key_path(item, target_key, current_path + [index])
if path:
return path
return None
def strdict_to_dict(strdict):
""" Representación de texto de un diccionario a formato json """
value = {}
try:
if isinstance(strdict, str):
value = json.dumps(ast.literal_eval(strdict))
except:
pass
return value
def export_resource_pdf(request, resourceid, printubic, printimgs, printpdfs):
resource = Resource.objects.get(pk=resourceid)
resource_data = resource.to_json()
# Corrección de medios relacionados, se normalizan claves y se adicionan propiedades
ruta_medios = find_key_path( resource_data, "Medio de información")
if ruta_medios is not None:
valor_medios=reduce(lambda dict_layer, key: dict_layer[key], ruta_medios, resource_data)
resource_rel=resource.get_related_resources(user=request.user,resourceinstance_graphid='6afc4e9e-727e-4152-8084-309267752650')
#resource_data["Información gráfica"]["Medio de información"] = ajustar_medios(resource_rel)
reduce(getitem, ruta_medios[:-1], resource_data)[ruta_medios[-1]] = ajustar_medios(resource_rel,valor_medios)
# Cambio de datos gis en texto a formato json
ruta_gis = find_key_path( resource_data, "Coordenadas / Geometría")
if ruta_gis is not None:
valor_gis=reduce(lambda dict_layer, key: dict_layer[key], ruta_gis, resource_data)["@value"]
reduce(getitem, ruta_gis[:-1], resource_data)[ruta_gis[-1]]["@value"] = strdict_to_dict(valor_gis)
# Extracción del identificador de grupo ETA
eta_group=""
ruta_meta_iden = find_key_path( resource_data, "Meta identificación")
if ruta_meta_iden is not None:
meta_iden=json.loads(strdict_to_dict(reduce(lambda dict_layer, key: dict_layer[key], ruta_meta_iden, resource_data)))
eta_group=str(Group.objects.get(pk=meta_iden["grp_eta"])).upper()
# Fecha del informe
sprpcb_url=request.build_absolute_uri('/')[:-1]
fecha=datetime.now(ZoneInfo("America/La_Paz"))
resources = [{
'resourceinstanceid': str(resource.resourceinstanceid),
'graph_id': str(resource.graph_id),
'displayname': resource.displayname,
'resource': resource_data,
'sprpcb_url': sprpcb_url,
'fecha': fecha,
'eta_group': eta_group,
'print_imgs': bool(int(printimgs)),
'print_pdfs': bool(int(printpdfs))
}]
context = {'resources': resources}
match str(resource.graph_id):
case "72420da0-db59-4048-aea2-03b0bc5cdcdf": # Actores
context["resources"][0]["grafo"]="Organizaciones y personas"
nombre_pdf = f'Actor_{resourceid}'
html_string = render_to_string('reports/actor_pdf_report.html', context)
case '8ea3bf67-89ce-474c-b3cb-6dd5ee3d6198': # Bienes inmuebles
context["resources"][0]["grafo"]="Patrimonio material - Bienes inmuebles"
html_string = render_to_string('reports/bim_pdf_report.html', context)
nombre_pdf = f'bienes_inmuebles_{resourceid}'
case '10b03fec-4d85-11ee-a708-ffcd06c08a5d': # Bienes muebles
context["resources"][0]["grafo"]="Patrimonio material - Bienes muebles"
html_string = render_to_string('reports/bm_pdf_report.html', context)
nombre_pdf = f'bienes_muebles_{resourceid}'
case "9b0e22c7-5c56-4be6-aa89-ae2632ba28e8": # Inmaterial
context["resources"][0]["grafo"]="Patrimonio Inmaterial"
html_string = render_to_string('reports/pi_pdf_report.html', context)
nombre_pdf = f'Inmaterial_{resourceid}'
gen_pdf_file = HTML(string=html_string, base_url=request.build_absolute_uri("/")).write_pdf()
merger = PdfWriter()
merger.append(PdfReader(io.BytesIO(gen_pdf_file)))
root_path = Path(__file__).resolve().parent.parent
for medio in reduce(getitem, ruta_medios[:-1], resource_data)[ruta_medios[-1]] :
if medio['formato'] == 'application/pdf' and bool(int(printpdfs)) :
merger.append(PdfReader(f'{root_path}/uploadedfiles/{medio["file"]}'))
output_buffer = io.BytesIO()
merger.write(output_buffer)
merger.close()
else:
output_buffer = io.BytesIO()
merger.write(output_buffer)
merger.close()
response = HttpResponse(output_buffer.getvalue(), content_type='application/pdf')
response['Content-Disposition'] = f'attachment; filename="{nombre_pdf}.pdf"'
return response

View File

@@ -0,0 +1,183 @@
{% load i18n %}
<!-- ko if: !$data.configForm -->
<!-- ko if: !$data.summary -->
{% block report %}
{% block report_title_bar %}
<!-- Report Title Bar -->
<div class="relative report-title-bar">
<!-- Title Block -->
<div class="report-toolbar-preview ep-form-toolbar">
<div class="h4 report-toolbar-title"><span data-bind="text: report.get('name')"></span> - <span data-bind="text: report.get('displayname') "></span></div>
<!-- Tools -->
<div class="ep-form-toolbar-tools mar-no flex">
<p class="report-print-date">
<span data-bind="text: $root.translations.reportDate"></span>
<span data-bind="text: reportDate"></span>
</p>
<div
class="report-print-date"
data-bind="component: {
name: 'views/components/simple-switch',
params: {
value: hideEmptyNodes,
config:{ label: $root.translations.hideNullValues, subtitle: ''}
}
}"
></div>
</div>
</div>
</div>
{% endblock report_title_bar %}
<!-- Report Content -->
<div class="rp-report-container-preview">
{% block header %}
{% endblock header %}
{% block body %}
<!--ko if: hasProvisionalData() && (editorContext === false) -->
<div class="report-provisional-flag"><span data-bind="text: $root.translations.pendingProvisionalEditsNotDisplayed"></span></div>
<!--/ko-->
<!--ko if: hasProvisionalData() && (editorContext === true && report.userisreviewer === true) -->
<div class="report-provisional-flag"><span data-bind="text: $root.translations.pendingProvisionalEditsNotDisplayed"></span></div>
<!--/ko-->
<!--ko if: hasProvisionalData() && (editorContext === true && report.userisreviewer === false) -->
<div class="report-provisional-flag"><span data-bind="text: $root.translations.pendingProvisionalEdits"></div>
<!--/ko-->
<div class="rp-report-section relative rp-report-section-root">
<div class="rp-report-section-title">
<!-- ko foreach: { data: report.cards, as: 'card' } -->
<!-- ko if: ($parent.hideEmptyNodes() === false || card.tiles().length > 0) && ko.unwrap(card.model.visible) -->
<!-- ko if: $index() !== 0 --><hr class="rp-tile-separator"><!-- /ko -->
<div class="rp-card-section">
<!-- ko component: {
name: card.model.cardComponentLookup[card.model.component_id()].componentname,
params: {
state: 'report',
preview: $parent.report.preview,
card: card,
pageVm: {...$root, report: $parent.report},
hideEmptyNodes: $parent.hideEmptyNodes
}
} --> <!-- /ko -->
</div>
<!-- /ko -->
<!-- /ko -->
</div>
</div>
{% endblock body %}
{% block related_resources %}
<div class="rp-report-section relative report-related-resources">
<div class="rp-report-section-title">
<div class="h4 rp-section-title"><span data-bind="text: $root.translations.relatedResources"></span></div>
</div>
<!-- ko foreach: { data: Object.values(report.relatedResourcesLookup()), as: 'resourceData' } -->
<!-- ko if: resourceData.totalRelatedResources > 0 || !$parent.hideEmptyNodes() -->
<div class="h5 rp-tile-title">
<span class="rp-tile-title-float" data-bind="text: resourceData.name"></span>
</div>
<div class="rp-card-section">
<!-- ko foreach: { data: resourceData.loadedRelatedResources(), as: 'relatedResource' } -->
<div class="rp-report-container-tile">
<div class="row rp-report-tile">
<dl class="dl-horizontal">
<dt><a data-bind="text: relatedResource.displayName, attr: {href: relatedResource.link}"></a></dt>
<!-- ko if: relatedResource.relationship -->
<dd data-bind="text: '( ' + relatedResource.relationship + ' )'"></dd>
<!-- /ko -->
</dl>
</div>
</div>
<!-- /ko -->
<!-- ko if: resourceData.paginator() && resourceData.paginator().has_next -->
<button class="btn btn-primary" data-bind="click: $parent.report.getRelatedResources.bind($parent.report, false)">
<span data-bind="text: $root.translations.loadMore" ></span>
<span data-bind="text: '(' + resourceData.remainingResources() + ')'"></span>
</button>
<button class="btn btn-primary" data-bind="click: $parent.report.getRelatedResources.bind($parent.report, true)">
<span data-bind="text: $root.translations.loadAll" ></span>
<span data-bind="text: '(' + (resourceData.totalRelatedResources - resourceData.loadedRelatedResources().length) + ')'"></span>
</button>
<!-- /ko -->
<!--ko if: resourceData.totalRelatedResources === 0 -->
<div class="rp-report-container-tile">
<div class="row rp-report-tile rp-no-data"><span data-bind="text: $root.translations.noRelationshipsAdded"></span></div>
</div>
<!--/ko-->
</div>
<!-- /ko -->
<!-- /ko -->
</div>
{% endblock related_resources %}
{% block footer %}
{% endblock footer %}
</div>
{% endblock report %}
<!-- /ko -->
<!-- ko if: $data.summary -->
{% block summary %}
<div class="relative report-title-bar">
<!-- Title Block -->
<div class="report-toolbar-preview ep-form-toolbar">
<h4 class="report-toolbar-title"><span data-bind="text: report.get('name')"></span> - <span data-bind="text: report.get('displayname') "></span></h4>
<!-- Tools -->
<div class="ep-form-toolbar-tools mar-no flex">
<p class="report-print-date">
<span data-bind="text: $root.translations.reportDate"></span>
<span data-bind="text: reportDate"></span>
</p>
</div>
</div>
</div>
<div class="rp-report-container-preview">
<div class="rp-report-section relative rp-report-section-root">
<div class="rp-report-section-title">
<!-- ko if: report.cards.length > 0 -->
<!--ko let: { card: report.cards[0] }-->
<div class="rp-card-section">
<!-- ko component: {
name: card.model.cardComponentLookup[card.model.component_id()].componentname,
params: {
state: 'report',
preview: report.preview,
card: card,
pageVm: $root
}
} --> <!-- /ko -->
</div>
<!--/ko-->
<!-- /ko -->
</div>
</div>
</div>
{% endblock summary %}
<!-- /ko -->
<!-- end of not configForm -->
<!-- /ko -->
<!-- ko if: $data.configForm && ($data.configType === 'header') -->
{% block header_form %}
{% endblock header_form %}
<!-- /ko -->

View File

@@ -0,0 +1,60 @@
<!-- mi_proyecto/templates/views/report-templates/export-pdf-report.htm -->
{% extends "views/report-templates/default.htm" %}
{% load i18n %}
{% block header %}
{{ block.super }}
<div class="relative report-title-bar">
<div class="report-toolbar-preview ep-form-toolbar" style="height: 30px; min-height: 30px;">
<button class="btn btn-sm btn-primary" data-bind="click: exportPDF">
<i class="fa fa-file-pdf-o"></i> Exportar a PDF
</button>
<div class="report-print-date" data-bind="component: {
name: 'views/components/simple-switch',
params: { value: anexarUbic, config:{ label: 'Incluir ubicación detallada'}}}">
</div>
<div class="report-print-date" data-bind="component: {
name: 'views/components/simple-switch',
params: { value: anexarImagenes, config:{ label: 'Incluir imágenes adjuntas'}}}">
</div>
<div class="report-print-date" data-bind="component: {
name: 'views/components/simple-switch',
params: { value: anexarPdfs, config:{ label: 'Incluir documentos (pdf) adjuntos'}}}">
</div>
</div>
</div>
{% endblock header %}
{% block body %}
<!--ko if: hasProvisionalData() && (editorContext === false) -->
<div class="report-provisional-flag">{% trans 'This resource has provisional edits (not displayed in this report) that are pending review' %}</div>
<!--/ko-->
<!--ko if: hasProvisionalData() && (editorContext === true && report.userisreviewer === true) -->
<div class="report-provisional-flag">{% trans 'This resource has provisional edits (not displayed in this report) that are pending review' %}</div>
<!--/ko-->
<!--ko if: hasProvisionalData() && (editorContext === true && report.userisreviewer === false) -->
<div class="report-provisional-flag">{% trans 'This resource has provisional edits that are pending review' %}</div>
<!--/ko-->
<div class="rp-report-section relative rp-report-section-root">
<div class="rp-report-section-title">
<!-- ko foreach: { data: report.cards, as: 'card' } -->
<!-- ko if: !!(ko.unwrap(card.tiles).length > 0) -->
<!-- ko if: $index() !== 0 --><hr class="rp-tile-separator"><!-- /ko -->
<div class="rp-card-section">
<!-- ko component: {
name: card.model.cardComponentLookup[card.model.component_id()].componentname,
params: {
state: 'report',
preview: $parent.report.preview,
card: card,
pageVm: $root,
hideEmptyNodes: $parent.hideEmptyNodes
}
} --> <!-- /ko -->
</div>
<!-- /ko -->
<!-- /ko -->
</div>
</div>
{% endblock body %}

View File

@@ -0,0 +1,156 @@
<!-- mi_proyecto/templates/reports/actor_pdf_report.html -->
{% load template_tags %}
{% for resource in resources %}
{% with resource_data=resource.resource %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
:root {--oscuro: #242424; --carbon: #4c4c4c; --ceniza: #999; --claro: #fafafa; --resaltado: #d1a21c;}
html { color: var(carbon); font-family: 'Helvetica', sans-serif; font-size: 9pt; font-weight: 300; line-height: 1.2;}
body { margin: 0;}
h1 { color: var(--resaltado); font-size: 13pt; text-align: center; width: 100%;}
h2, h3, h4 { color: black; font-weight: 400;}
h2 { break-before: always; font-size: 12pt;}
h3 { font-size: 12pt;}
h4 { font-size: 11pt;}
.tiles-grid-grp { display: grid; grid-template-columns: 3fr 2fr; grid-template-rows: auto auto; gap: 2px;}
.tiles-grid-grp-col { grid-column: 2; grid-row: 1 / span 2; }
.tile-block { border: 1px solid var(--ceniza); border-radius: 4px; padding: 2px; margin: 2px 0; background-color: var(--claro);}
.tile-title { font-size: 11pt; font-weight: bold; color: var(--oscuro); border-bottom: 1px solid var(--ceniza); padding-bottom: 2px; margin-bottom: 5px;}
.data-row { display: flex; padding: 2px 0; border-bottom: 1px solid var(--claro);}
.data-label { font-weight: 600; letter-spacing: -0.05em; width: 40%; color: var(--oscuro);}
.data-value { width: 40%; letter-spacing: -0.05em; word-wrap: break-word;}
.no-data { color: var(--ceniza); font-style: italic;}
@page {
@top-left { background: var(--resaltado); content: counter(page); height: 1cm; text-align: center; width: 1cm;}
@top-center { background: var(--resaltado); content: ''; display: block; height: .05cm; opacity: .5; width: 100%;}
@top-right { content: '{{ resource.grafo }} \A UUID: {{ resource.resourceinstanceid }}'; white-space: pre-line; color: var(--ceniza); font-size: 8pt; height: 1cm; vertical-align: middle; width: 100%;}
@bottom-center { background: var(--resaltado); content: ''; display: block; height: .05cm; opacity: .5; width: 100%;}
@bottom-left { content: 'Sistema Plurinacional de Registro de Patrimonio Cultural Boliviano\ASPRPCB - {{ resource.eta_group }}'; white-space: pre-line; color: var(--ceniza); font-size: 8pt; height: 1cm; vertical-align: middle; width: 100%;}
@bottom-right { content: '{{ resource.fecha }} \A BOLIVIA'; white-space: pre-line; color: var(--ceniza); font-size: 8pt; height: 1cm; vertical-align: middle; width: 100%;}
size: Letter;
margin-top: 1.5cm; margin-bottom: 1.8cm; margin-left: 2cm; margin-right: 1.5cm;
}
</style>
<title>{{ resource.grafo }} ID de sistema: {{ resource.resourceinstanceid }}</title>
<meta name="description" content="Ficha PDF">
</head>
<body>
{% if resource_data %}
<h1>{{ resource.displayname|truncatewords:10 }}</h1>
<div class="tiles-grid-grp">
<div class="tile-block">
<div class="tile-title">Identificación</div>
{% if resource_data|has_key:"Identificación" %}
{% for iden in resource_data|val_from_key:"Identificación" %}
<div class="data-row">
<span class="data-label">Nombre / Título :</span>
<span class="data-value">{{ iden|val_from_key:"@value" }}</span>
</div>
<div class="data-row">
<span class="data-label">Tipo de actor :</span>
<span class="data-value">{{ iden|val_from_key:"Tipo de actor" }}</span>
</div>
<div class="data-row">
<span class="data-label">Cargo :</span>
<span class="data-value">{{ iden|val_from_key:"Cargo" }}</span>
</div>
{% endfor %}
{% endif %}
</div>
<div class="tile-block">
<div class="tile-title">Características</div>
{% if resource_data|has_key:"Detalles del actor" %}
<div class="data-row">
<span class="data-label">Grupo etario: </span>
<span class="data-value">{{ resource_data|val_from_key:"Detalles del actor"|val_from_key:"Grupo etario" }}</span>
</div>
<div class="data-row">
<span class="data-label">Rasgo Cultural Principal: </span>
<span class="data-value">{{ resource_data|val_from_key:"Detalles del actor"|val_from_key:"Rasgo Cultural Principal" }}</span>
</div>
<div class="data-row">
<span class="data-label">Otro rasgo cultural: </span>
<span class="data-value">{{ resource_data|val_from_key:"Detalles del actor"|val_from_key:"Otro rasgo cultural" }}</span>
</div>
<div class="data-row">
<span class="data-label">Sexo: </span>
<span class="data-value">{{ resource_data|val_from_key:"Detalles del actor"|val_from_key:"Sexo" }}</span>
</div>
<div class="data-row">
<span class="data-label">Nº de personas (aprox.): </span>
<span class="data-value">{{ resource_data|val_from_key:"Detalles del actor"|val_from_key:'Cantidad de personas del grupo(aprox.)' }}</span>
</div>
{% endif %}
</div>
<div class="tiles-grid-grp-col">
<div class="tile-block">
<div class="tile-title">Imagen de referencia</div>
{% if resource_data|has_key:"Imagen de referencia" %}
<div class="data-row">
<img src="{{resource.sprpcb_url}}{{ resource_data|val_from_key:'Imagen de referencia' }}" alt="foto">
</div>
{% endif %}
</div>
</div>
</div>
<div class="tile-title">Ubicación</div>
<div class="tiles-grid-grp">
<div class="tile-block">
{% if resource_data|has_key:"Ubicación simple" %}
<div class="data-row">
<span class="data-label">Localidad: </span>
<span class="data-value">{{ resource_data|val_from_key:"Ubicación simple"|val_from_key:"Departamento" }}</span>
</div>
<div class="data-row">
<span class="data-label">Otra localidad: </span>
<span class="data-value">{{ resource_data|val_from_key:"Ubicación simple"|val_from_key:"Otra localidad" }}</span>
</div>
<div class="data-row">
<span class="data-label">Coordenadas / Geometría: </span>
</div>
{% if resource_data|val_from_key:"Ubicación simple"|has_key:"Coordenadas / Geometría" %}
{% with gis_vector=resource_data|val_from_key:"Ubicación simple"|val_from_key:"Coordenadas / Geometría"|val_from_key:"@value"|json_to_obj %}
{% for gis in gis_vector.features %}
<div class="data-row">
<span class="data-value" style="width: 100%;">{{ gis.geometry }}</span>
</div>
{% endfor %}
{% endwith %}
<div class="data-row">
<span class="data-label">Geometría principal: </span>
<span class="data-value">{{ resource_data|val_from_key:"Ubicación simple"|val_from_key:"Coordenadas / Geometría"|val_from_key:"Tipo de geometría" }}</span>
</div>
{% endif %}
{% endif %}
</div>
<div class="tiles-grid-grp-col">
<div class="tile-block">
<div class="data-label">Mapa de referencia</div>
</div>
</div>
</div>
<div class="tile-block">
<div class="tile-title">Notas</div>
{% if resource_data|has_key:"Descripción / Notas" %}
{% for desc in resource_data|val_from_key:"Descripción / Notas" %}
<div class="data-row">
<span class="data-label" style="width: 100%;">{{ desc|val_from_key:"Tipo de descripción" }}</span>
</div>
<div class="data-row">
<span class="data-value" style="width: 100%;">{{ desc|val_from_key:"Descripción"|safe|cut:"<p>&nbsp;</p>" }}</span>
</div>
{% endfor %}
{% endif %}
</div>
{% else %}
<p class="no-data">El recurso no tiene información.</p>
{% endif %}
</body>
{% endwith %}
{% endfor %}
</html>

476
reports/bim_pdf_report.html Normal file
View File

@@ -0,0 +1,476 @@
<!-- mi_proyecto/templates/reports/bim_pdf_report.html -->
{% load template_tags %}
{% for resource in resources %}
{% with resource_data=resource.resource %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
:root {--oscuro: #242424; --carbon: #4c4c4c; --ceniza: #999; --claro: #fafafa; --resaltado: #d1a21c;}
html { color: var(carbon); font-family: 'Helvetica', sans-serif; font-size: 9pt; font-weight: 300; line-height: 1.2;}
body { margin: 0;}
h1 { color: var(--resaltado); font-size: 13pt; text-align: center; width: 100%;}
h2, h3, h4 { color: black; font-weight: 400;}
h2 { break-before: always; font-size: 12pt;}
h3 { font-size: 12pt;}
h4 { font-size: 11pt;}
a { font-size:.85em;}
.flex-container { display: flex; flex-wrap: wrap; gap: 0 4px; margin-top: 5px;}
.flex-item {flex: 0 0 calc(50% - 5px); box-sizing: border-box;;}
.tiles-grid-grp { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 2px;}
.tiles-grid-grp-col { grid-column: 2; contain: size; }
.tile-block { border: 1px solid var(--ceniza); border-radius: 4px; padding: 2px; margin: 2px 0; background-color: var(--claro);}
.tile-title { font-size: 11pt; font-weight: bold; color: var(--oscuro); border-bottom: 1px solid var(--ceniza); padding-bottom: 2px; margin-bottom: 5px;}
.data-row { display: flex; padding: 2px 0; border-bottom: 1px solid var(--claro);}
.data-label { font-weight: 600; letter-spacing: -0.05em; width: 40%; color: var(--oscuro);}
.data-value { width: 60%; font-size:.9em; word-wrap: break-word;}
.no-data { color: var(--ceniza); font-style: italic;}
.tiles-grid-grp-col .tile-block img { object-fit: cover; width: 330px; max-height: 300px;}
.rtable{margin:0 0 0 30px;table-layout: fixed;width:95%;display:table; border:1px solid var(--ceniza)}
.rrow{display:table-row; flex-direction:row }
.rcol-larga{width: auto;}.rcol-media{width: 25%;}.rcol-corta{width: 10%;}
.rcell{padding:3px 6px;display:table-cell;border:1px solid var(--ceniza)}
.rrow.rheader{ background-color: solid var(--ceniza); border:1px solid var(--ceniza)}
.rrow.rheader .rcell{font-weight:600; border-bottom: 1px solid var(--ceniza);}
.rrow .rcell{margin-bottom:6px;border:none;font-size:.85em;}
.gallery { display: grid; grid-template-columns: repeat(2, 340px); grid-auto-rows: 272px; gap: 5px; justify-content: center; }
.gallery-item { overflow: hidden; border-radius: 5px; background-color: var(--ceniza); position: relative;}
.gallery-item img { width: 100%; height: 100%; object-fit: cover;}
.gallery-item a {position: absolute; bottom: 6px; left: 6px; color: var(--carbon); text-decoration: none; background-color: rgb(255 255 255 / 50%); font-size: .75em;}
@page {
@top-left { background: var(--resaltado); content: counter(page); height: 1cm; text-align: center; width: 1cm;}
@top-center { background: var(--resaltado); content: ''; display: block; height: .05cm; opacity: .5; width: 100%;}
@top-right { content: '{{ resource.grafo }} \A UUID: {{ resource.resourceinstanceid }}'; white-space: pre-line; color: var(--ceniza); font-size: 8pt; height: 1cm; vertical-align: middle; width: 100%;}
@bottom-center { background: var(--resaltado); content: ''; display: block; height: .05cm; opacity: .5; width: 100%;}
@bottom-left { content: 'Sistema Plurinacional de Registro de Patrimonio Cultural Boliviano\ASPRPCB - {{ resource.eta_group }}'; white-space: pre-line; color: var(--ceniza); font-size: 8pt; height: 1cm; vertical-align: middle; width: 100%;}
@bottom-right { content: '{{ resource.fecha }} \A BOLIVIA'; white-space: pre-line; color: var(--ceniza); font-size: 8pt; height: 1cm; vertical-align: middle; width: 100%;}
size: Letter;
margin-top: 1.5cm; margin-bottom: 1.8cm; margin-left: 2cm; margin-right: 1.5cm;
}
</style>
<title>{{ resource.grafo }} ID de sistema: {{ resource.resourceinstanceid }}</title>
<meta name="description" content="Ficha PDF">
</head>
<body>
{% if resource_data %}
<h1>{{ resource.displayname|truncatewords:10 }}</h1>
<div class="tiles-grid-grp">
<div class="tile-block" >
<div class="tile-title">Identificación</div>
{% if resource_data|has_key:"Identificación" %}
<div class="data-row">
<span class="data-label">Ámbito / subámbito: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:'Ámbito / subámbito' }}</span>
</div>
<div class="data-row">
<span class="data-label">Código principal: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:"Código principal" }}</span>
</div>
{% if resource_data|val_from_key:"Identificación"|has_key:"Código institucional" %}
<span class="data-label">Código alternativo: </span>
{% for cod in resource_data|val_from_key:"Identificación"|val_from_key:"Código institucional" %}
<div class="data-row" style="margin-left: 20px;">
<span class="data-label" style="width: 36%;">{{ cod|val_from_key:"Tipo de código" }}: </span>
<span class="data-value" style="width: 64%;">{{ cod|val_from_key:"@value" }}</span>
</div>
{% endfor %}
{% endif %}
<span class="data-label">Denominación</span>
{% for nom in resource_data|val_from_key:"Identificación"|val_from_key:"Denominación" %}
<div class="data-row" style="margin-left: 20px;">
<span class="data-label" style="width: 36%;">{{ nom|val_from_key:"Tipo de nombre" }} : </span>
<span class="data-value" style="width: 64%;">{{ nom|val_from_key:"@value" }}</span>
</div>
{% endfor %}
<div class="data-row">
<span class="data-label">Época : </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:'Época'|val_from_key:"@value" }}</span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-label" style="width: 36%;">Otra época : </span>
<span class="data-value" style="width: 64%;">{{ resource_data|val_from_key:"Identificación"|val_from_key:'Época'|val_from_key:"Otro" }}</span>
</div>
<div class="data-row">
<span class="data-label">Autor / constructor : </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:"Autor / constructor" }}</span>
</div>
<div class="data-row">
<span class="data-label">Uso original : </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:"Uso original" }}</span>
</div>
<div class="data-row">
<span class="data-label">Año : </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:"Año" }}</span>
</div>
<div class="data-row">
<span class="data-label">Uso actual : </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:"Uso actual" }}</span>
</div>
<div class="data-row">
<span class="data-label">Estilo / filiación cultural: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:"Estilo / filiación cultural" }}</span>
</div>
<div class="data-row">
<span class="data-label">Tipología : </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:"Tipología" }}</span>
</div>
{% endif %}
</div>
<div class="tiles-grid-grp-col">
<div class="tile-block">
<div class="tile-title">Imagen de referencia</div>
{% if resource_data|has_key:"Recursos" %}
{% with medios=resource_data|val_from_key:'Recursos'|val_from_key:'Medio de información' %}
<img src="{{resource.sprpcb_url}}{{ medios.0.url }}" alt="{{medios.0.file}}">
{% endwith %}
{% endif %}
</div>
</div>
</div>
<div class="tiles-grid-grp">
<div class="tile-block">
<div class="tile-title">Ubicación</div>
{% if resource_data|has_key:"Ubicación BIM" %}
<div class="data-row">
<span class="data-label">Localidad : </span>
<span class="data-value">{{ resource_data|val_from_key:"Ubicación BIM"|val_from_key:"Departamento" }}</span>
</div>
<div class="data-row">
<span class="data-label">Departamento : </span>
<span class="data-value">{{ resource_data|val_from_key:"Ubicación BIM"|val_from_key:"Ubicación extendida" }}</span>
</div>
<div class="data-row">
<span class="data-label">Calle/Avenida/Pasaje : </span>
<span class="data-value">{{ resource_data|val_from_key:"Ubicación BIM"|val_from_key:"Calle/Avenida/Pasaje" }}</span>
</div>
<div class="data-row">
<span class="data-label">Número : </span>
<span class="data-value">{{ resource_data|val_from_key:"Ubicación BIM"|val_from_key:"Número" }}</span>
</div>
<div class="data-row">
<span class="data-label">Zona : </span>
<span class="data-value">{{ resource_data|val_from_key:"Ubicación BIM"|val_from_key:"Zona" }}</span>
</div>
<div class="data-row">
<span class="data-label" style="width: 100%;">Coordenadas / Geometría: </span>
</div>
{% if resource_data|val_from_key:"Ubicación BIM"|has_key:"Coordenadas / Geometría" %}
{% with gis_vector=resource_data|val_from_key:"Ubicación BIM"|val_from_key:"Coordenadas / Geometría"|val_from_key:"@value"|json_to_obj %}
{% for gis in gis_vector.features %}
<div class="data-row">
<span class="data-value" style="width: 100%;">{{ gis.geometry }}</span>
</div>
{% endfor %}
{% endwith %}
<div class="data-row">
<span class="data-value" style="width: 100%;"><b>Geometría principal : </b>{{ resource_data|val_from_key:"Ubicación BIM"|val_from_key:"Coordenadas / Geometría"|val_from_key:"Tipo de geometría" }}</span>
</div>
{% endif %}
{% endif %}
</div>
<div class="tiles-grid-grp-col">
<div class="tile-block">
<div class="tile-title">Mapa de referencia</div>
</div>
</div>
</div>
<div class="tile-block">
<div class="tile-title">Marco legal</div>
{% if resource_data|has_key:"Marco Legal BM" %}
<div class="tiles-grid-grp">
<div class="tile-block">
<div class="data-row">
<span class="data-label" style="width: 45%;">Es de interés patrimonial : </span>
<span class="data-value" style="width: 55%;">{{ resource_data|val_from_key:"Marco Legal BM"|val_from_key:"Es de interés patrimonial"|yesno:"Si,No" }}</span>
</div>
<div class="data-row">
<span class="data-label" style="width: 45%;">Protección : </span>
<span class="data-value" style="width: 55%;">{{ resource_data|val_from_key:"Marco Legal BM"|val_from_key:"Protección" }}</span>
</div>
</div>
<div class="tiles-grid-grp-col">
<div class="tile-block">
<div class="data-row">
<span class="data-label">Propietario(s) : </span>
<span class="data-value">{{ resource_data|val_from_key:"Marco Legal BM"|val_from_key:'Propietario/s'|val_from_key:"@value" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-label" style="width: 37%;">Tipo : </span>
<span class="data-value" style="width: 63%;">{{ resource_data|val_from_key:"Marco Legal BM"|val_from_key:'Propietario/s'|val_from_key:"Tipo de propietario" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-label" style="width: 37%;">Propiedad con: </span>
<span class="data-value" style="width: 63%;">{{ resource_data|val_from_key:"Marco Legal BM"|val_from_key:'Propietario/s'|val_from_key:"Propiedad con" }}</span>
</div>
</div>
</div>
</div>
{% endif %}
</div>
<div class="tile-block">
<div class="tile-title">Características</div>
{% if resource_data|has_key:"Características BiM" %}
{% with caracteristica=resource_data|val_from_key:"Características BiM" %}
<div class="tile-block">
<div class="data-row">
<span class="data-label">Número de niveles : {{ caracteristica|val_from_key:'Niveles'|val_from_key:"@value" }}</span>
<span class="data-value"><b>Cambios : </b>{{ caracteristica|val_from_key:"Niveles"|val_from_key:'Cambios'|val_from_key:"@value" }}</span>
</div>
</div>
{% if caracteristica|has_key:"Mediciones" %}
<div class="tile-block">
<span class="data-label">Mediciones : </span>
<div class="flex-container">
{% for item in caracteristica|val_from_key:"Mediciones" %}
<div class="flex-item">
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 95%; line-height: 0.6;"><b>{{item|val_from_key:"Tipo de medida"}} : </b>{{ item|val_from_key:"Medida"|val_from_key:"Valor de la medida" }} {{ item|val_from_key:"Medida"|val_from_key:"Unidad de medida" }}</span>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
<div class="tile-block">
<div class="data-row">
<span class="data-label">Servicios : </span>
<span class="data-value">{{ caracteristica|val_from_key:'Servicios' }}</span>
</div>
</div>
<div class="tile-block">
{% if caracteristica|has_key:"Valorización" %}
<div class="data-row">
<span class="data-label">Valorización : </span>
<span class="data-value">{{caracteristica|val_from_key:"Valorización"|val_from_key:"@value"}} </span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-label" style="width: 37%;">Ponderación total : </span>
<span class="data-value" style="width: 63%;">{{caracteristica|val_from_key:"Valorización"|val_from_key:"Ponderación total"}} </span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-label" style="width: 37%;">Valor resultante : </span>
<span class="data-value" style="width: 63%;">{{caracteristica|val_from_key:"Valorización"|val_from_key:"Valor resultante"}} </span>
</div>
{% endif %}
</div>
<div class="tile-block">
<div class="data-row">
<span class="data-label">Factores de deterioro : </span>
<span class="data-value">{{ caracteristica|val_from_key:'Factores de deterioro' }}</span>
</div>
<div class="data-row">
<span class="data-label">Estado de conservación : </span>
<span class="data-value">{{ caracteristica|val_from_key:'Estado de conservación' }}</span>
</div>
</div>
<div class="tile-block">
<div class="data-label">Datos del inmueble</div>
{% if caracteristica|has_key:"Datos del inmueble" %}
{% if caracteristica|val_from_key:"Datos del inmueble"|val_from_key:"Interior"|has_key:"Sección interior" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Sección Interior</b></span>
</div>
{% for sec_int in caracteristica|val_from_key:"Datos del inmueble"|val_from_key:"Interior"|val_from_key:"Sección interior" %}
{% if sec_int|has_key:"Elemento sección interior" %}
<div class="data-row" style="margin-left: 30px;">
<span class="data-value" style="width: 100%;"><b>{{ sec_int|val_from_key:"@value" }}</b>{{ sec_int|val_from_key:"Elemento sección interior"|val_from_key:"@value" }} </span>
</div>
<div class="rtable">
<div class="rrow rheader">
<div class="rcell rcol-larga">Elemento</div>
<div class="rcell rcol-media">Material(es)</div>
<div class="rcell rcol-media">Detalles artísticos</div>
<div class="rcell rcol-corta">Estado</div>
<div class="rcell rcol-corta">Cambios</div>
</div>
{% for elem in sec_int|val_from_key:"Elemento sección interior"%}
<div class="rrow">
<div class="rcell data-title="Elemento">{{elem|val_from_key:"@value"}}</div>
<div class="rcell data-title="Material(es)"">{{elem|val_from_key:"Material"}}</div>
<div class="rcell data-title="Detalles artísticos"">{{elem|val_from_key:"Detalles artísticos"}}</div>
<div class="rcell data-title="Estado"">{{elem|val_from_key:"Estado"}}</div>
<div class="rcell data-title="Cambios"">{{elem|val_from_key:"Cambios"}}</div>
</div>
{% endfor %}
</div>
{% endif %}
{% endfor %}
{% endif %}
{% if caracteristica|val_from_key:"Datos del inmueble"|val_from_key:"Exterior"|has_key:"Sección exterior" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Sección Exterior</b></span>
</div>
{% for sec_ext in caracteristica|val_from_key:"Datos del inmueble"|val_from_key:"Exterior"|val_from_key:"Sección exterior" %}
{% if sec_ext|has_key:"Elemento - sección exterior" %}
<div class="data-row" style="margin-left: 30px;">
<span class="data-value" style="width: 100%;"><b>{{ sec_ext|val_from_key:"@value" }}</b>{{ sec_ext|val_from_key:"Elemento - sección exterior"|val_from_key:"@value" }} </span>
</div>
<div class="rtable">
<div class="rrow rheader">
<div class="rcell rcol-larga">Elemento</div>
<div class="rcell rcol-media">Material(es)</div>
<div class="rcell rcol-media">Detalles artísticos</div>
<div class="rcell rcol-corta">Estado</div>
<div class="rcell rcol-corta">Cambios</div>
</div>
{% for elem in sec_ext|val_from_key:"Elemento - sección exterior"%}
<div class="rrow">
<div class="rcell data-title="Elemento">{{elem|val_from_key:"@value"}}</div>
<div class="rcell data-title="Material(es)"">{{elem|val_from_key:"Material"}}</div>
<div class="rcell data-title="Detalles artísticos"">{{elem|val_from_key:"Detalles artísticos"}}</div>
<div class="rcell data-title="Estado"">{{elem|val_from_key:"Estado"}}</div>
<div class="rcell data-title="Cambios"">{{elem|val_from_key:"Cambios"}}</div>
</div>
{% endfor %}
</div>
{% endif %}
{% endfor %}
{% endif %}
{% if caracteristica|val_from_key:"Datos del inmueble"|val_from_key:"Espacios exteriores "|has_key:"Sección espacios exteriores" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Espacios exteriores</b></span>
</div>
{% for esp_ext in caracteristica|val_from_key:"Datos del inmueble"|val_from_key:"Espacios exteriores "|val_from_key:"Sección espacios exteriores" %}
{% if esp_ext|has_key:"Elemento - espacio exterior" %}
<div class="data-row" style="margin-left: 30px;">
<span class="data-value" style="width: 100%;"><b>{{ esp_ext|val_from_key:"@value" }}</b>{{ esp_ext|val_from_key:"Elemento - espacio exterior"|val_from_key:"@value" }} </span>
</div>
<div class="rtable">
<div class="rrow rheader">
<div class="rcell rcol-larga">Elemento</div>
<div class="rcell rcol-media">Material(es)</div>
<div class="rcell rcol-media">Detalles artísticos</div>
<div class="rcell rcol-corta">Estado</div>
<div class="rcell rcol-corta">Cambios</div>
</div>
{% for elem in esp_ext|val_from_key:"Elemento - espacio exterior"%}
<div class="rrow">
<div class="rcell data-title="Elemento">{{elem|val_from_key:"@value"}}</div>
<div class="rcell data-title="Material(es)"">{{elem|val_from_key:"Material"}}</div>
<div class="rcell data-title="Detalles artísticos"">{{elem|val_from_key:"Detalles artísticos"}}</div>
<div class="rcell data-title="Estado"">{{elem|val_from_key:"Estado"}}</div>
<div class="rcell data-title="Cambios"">{{elem|val_from_key:"Cambios"}}</div>
</div>
{% endfor %}
</div>
{% endif %}
{% endfor %}
{% endif %}
{% if caracteristica|val_from_key:"Datos del inmueble"|val_from_key:"Espacios de circulación"|has_key:"Sección espacios de circulación" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Espacios de circulación</b></span>
</div>
{% for esp_circ in caracteristica|val_from_key:"Datos del inmueble"|val_from_key:"Espacios de circulación"|val_from_key:"Sección espacios de circulación" %}
{% if esp_circ|has_key:"Elemento - espacio de circulación" %}
<div class="data-row" style="margin-left: 30px;">
<span class="data-value" style="width: 100%;"><b>{{ esp_circ|val_from_key:"@value" }}</b>{{ esp_circ|val_from_key:"Elemento - espacio de circulación"|val_from_key:"@value" }} </span>
</div>
<div class="rtable">
<div class="rrow rheader">
<div class="rcell rcol-larga">Elemento</div>
<div class="rcell rcol-media">Material(es)</div>
<div class="rcell rcol-media">Detalles artísticos</div>
<div class="rcell rcol-corta">Estado</div>
<div class="rcell rcol-corta">Cambios</div>
</div>
{% for elem in esp_circ|val_from_key:"Elemento - espacio de circulación"%}
<div class="rrow">
<div class="rcell data-title="Elemento">{{elem|val_from_key:"@value"}}</div>
<div class="rcell data-title="Material(es)"">{{elem|val_from_key:"Material"}}</div>
<div class="rcell data-title="Detalles artísticos"">{{elem|val_from_key:"Detalles artísticos"}}</div>
<div class="rcell data-title="Estado"">{{elem|val_from_key:"Estado"}}</div>
<div class="rcell data-title="Cambios"">{{elem|val_from_key:"Cambios"}}</div>
</div>
{% endfor %}
</div>
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
</div>
<div class="tile-block">
<div class="data-label">Intervenciones</div>
{% if caracteristica|has_key:"Intervenciones" %}
{% for desc in caracteristica|val_from_key:"Intervenciones" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>{{ desc|val_from_key:"Tipo de intervención" }} ({{desc|val_from_key:"Fecha"}}): </b>{{ desc|val_from_key:"@value"|safe|cut:"<p>&nbsp;</p>" }} </span>
</div>
{% endfor %}
{% endif %}
</div>
{% if caracteristica|has_key:"Descripción asignada" %}
<div class="tile-block">
<div class="data-label">{{ caracteristica|val_from_key:"Descripción asignada"|val_from_key:"Tipo de descripción" }} : </div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;">{{ caracteristica|val_from_key:"Descripción asignada"|val_from_key:"Descripción"|safe|cut:"<p>&nbsp;</p>" }} </span>
</div>
</div>
{% endif %}
{% endwith %}
{% endif %}
</div>
<div class="tile-block">
<div class="tile-title">Medios adjuntos</div>
{% if resource_data|has_key:"Recursos" %}
<div class="flex-container">
{% for medio in resource_data|val_from_key:'Recursos'|val_from_key:'Medio de información' %}
<div class="flex-item">
<div class="data-row" style="margin-left: 15px;">
<a href={{resource.sprpcb_url}}{{ medio.url }} >{{ medio.tipo }} : {{ medio|val_from_key:'@value' }} ({{ medio.formato|slice:"-4:" }})</a>
</div>
</div>
{% endfor %}
</div>
{% endif %}
</div>
<div class="tile-block">
<div class="tile-title">Observaciones</div>
{% if resource_data|has_key:"Descripción asignada" %}
{% for desc in resource_data|val_from_key:"Descripción asignada" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>{{ desc|val_from_key:"Tipo de descripción" }} : </b>{{ desc|val_from_key:"Descripción"|safe|cut:"<p>&nbsp;</p>" }} </span>
</div>
{% endfor %}
{% endif %}
</div>
<div class="tile-block">
<div class="tile-title">Responsables</div>
{% if resource_data|has_key:"Responsables" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Entidad administrativa : </b>{{ resource_data|val_from_key:"Responsables"|val_from_key:"Entidad administrativa" }} </span>
</div>
{% if resource_data|val_from_key:"Responsables"|has_key:"Responsable" %}
{% for item in resource_data|val_from_key:"Responsables"|val_from_key:"Responsable" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>{{ item|val_from_key:"Rol" }} ({{ item|val_from_key:"Fecha" }}) : </b>{{ item|val_from_key:"@value" }}</span>
</div>
{% endfor %}
{% endif %}
{% endif %}
</div>
{% if resource_data|has_key:"Recursos" and resource.print_imgs %}
<h2>Anexo de imágenes</h2>
<div class="gallery">
{% for medio in resource_data|val_from_key:'Recursos'|val_from_key:'Medio de información' %}
{% if medio.formato in "image/bmp, image/gif, image/jpg, image/jpeg, image/png, image/tif, image/tiff" %}
<div class="gallery-item">
<img src="{{resource.sprpcb_url}}{{ medio.url }}" alt="{{medio.file}}">
<a href="{{resource.sprpcb_url}}{{ medio.url }}">&nbsp; {{ medio.tipo }} : {{ medio|val_from_key:'@value' }}&nbsp; </a>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% else %}
<p class="no-data">El recurso no tiene información.</p>
{% endif %}
</body>
{% endwith %}
{% endfor %}
</html>

365
reports/bm_pdf_report.html Normal file
View File

@@ -0,0 +1,365 @@
<!-- mi_proyecto/templates/reports/bm_pdf_report.html -->
{% load template_tags %}
{% for resource in resources %}
{% with resource_data=resource.resource %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
:root {--oscuro: #242424; --carbon: #4c4c4c; --ceniza: #999; --claro: #fafafa; --resaltado: #d1a21c;}
html { color: var(carbon); font-family: 'Helvetica', sans-serif; font-size: 9pt; font-weight: 300; line-height: 1.2;}
body { margin: 0;}
h1 { color: var(--resaltado); font-size: 13pt; text-align: center; width: 100%;}
h2, h3, h4 { color: black; font-weight: 400;}
h2 { break-before: always; font-size: 12pt;}
h3 { font-size: 12pt;}
h4 { font-size: 11pt;}
a { font-size:.85em;}
.flex-container { display: flex; flex-wrap: wrap; gap: 0 4px; margin-top: 5px;}
.flex-item {flex: 0 0 calc(50% - 5px); box-sizing: border-box;}
.tiles-grid-grp { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 2px;}
.tiles-grid-grp-col { grid-column: 2; contain: size;}
.tile-block { border: 1px solid var(--ceniza); border-radius: 4px; padding: 2px; margin: 2px 0; background-color: var(--claro);}
.tile-title { font-size: 11pt; font-weight: bold; color: var(--oscuro); border-bottom: 1px solid var(--ceniza); padding-bottom: 2px; margin-bottom: 5px;}
.data-row { display: flex; padding: 2px 0; border-bottom: 1px solid var(--claro);}
.data-label { font-weight: 600; letter-spacing: -0.05em; width: 40%; color: var(--oscuro);}
.data-value { width: 60%; font-size:.9em; word-wrap: break-word;}
.no-data { color: var(--ceniza); font-style: italic;}
.tiles-grid-grp-col .tile-block img { object-fit: cover; width: 330px; max-height: 300px;}
.gallery { display: grid; grid-template-columns: repeat(2, 340px); grid-auto-rows: 272px; gap: 5px; justify-content: center; }
.gallery-item { overflow: hidden; border-radius: 5px; background-color: var(--ceniza); position: relative;}
.gallery-item img { width: 100%; height: 100%; object-fit: cover;}
.gallery-item a {position: absolute; bottom: 6px; left: 6px; color: var(--carbon); text-decoration: none; background-color: rgb(255 255 255 / 50%); font-size: .75em;}
@page {
@top-left { background: var(--resaltado); content: counter(page); height: 1cm; text-align: center; width: 1cm;}
@top-center { background: var(--resaltado); content: ''; display: block; height: .05cm; opacity: .5; width: 100%;}
@top-right { content: '{{ resource.grafo }} \A UUID: {{ resource.resourceinstanceid }}'; white-space: pre-line; color: var(--ceniza); font-size: 8pt; height: 1cm; vertical-align: middle; width: 100%;}
@bottom-center { background: var(--resaltado); content: ''; display: block; height: .05cm; opacity: .5; width: 100%;}
@bottom-left { content: 'Sistema Plurinacional de Registro de Patrimonio Cultural Boliviano\ASPRPCB - {{ resource.eta_group }}'; white-space: pre-line; color: var(--ceniza); font-size: 8pt; height: 1cm; vertical-align: middle; width: 100%;}
@bottom-right { content: '{{ resource.fecha }} \A BOLIVIA'; white-space: pre-line; color: var(--ceniza); font-size: 8pt; height: 1cm; vertical-align: middle; width: 100%;}
size: Letter;
margin-top: 1.5cm; margin-bottom: 1.8cm; margin-left: 2cm; margin-right: 1.5cm;
}
</style>
<title>{{ resource.grafo }} ID de sistema: {{ resource.resourceinstanceid }}</title>
<meta name="description" content="Ficha PDF">
</head>
<body>
{% if resource_data %}
<h1>{{ resource.displayname|truncatewords:10 }}</h1>
<div class="tiles-grid-grp">
<div class="tile-block" >
<div class="tile-title">Identificación</div>
{% if resource_data|has_key:"Identificación" %}
<div class="data-row">
<span class="data-label">Ámbito / subámbito: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:'Ámbito / subámbito' }}</span>
</div>
<div class="data-row">
<span class="data-label">Código principal: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:"Código principal" }}</span>
</div>
{% if resource_data|val_from_key:"Identificación"|has_key:"Código institucional" %}
<span class="data-label">Código alternativo: </span>
{% for cod in resource_data|val_from_key:"Identificación"|val_from_key:"Código institucional" %}
<div class="data-row" style="margin-left: 20px;">
<span class="data-label">{{ cod|val_from_key:"Tipo de código" }}: </span>
<span class="data-value">{{ cod|val_from_key:"@value" }}</span>
</div>
{% endfor %}
{% endif %}
<div class="data-row">
<span class="data-label">Denominación : </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:'Denominación'|val_from_key:"@value" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Tipo de Bien mueble : </b>{{ resource_data|val_from_key:"Identificación"|val_from_key:'Denominación'|val_from_key:"Tipo de nombre" }}</span>
</div>
{% if resource_data|val_from_key:"Identificación"|has_key:"Bienes muebles histórico-artístico" %}
<span class="data-label" style="width: 100%;">Bienes muebles histórico-artístico : </span>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Época : </b>{{ resource_data|val_from_key:"Identificación"|val_from_key:'Bienes muebles histórico-artístico'|val_from_key:"Época"|val_from_key:"@value" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Otra época : </b>{{ resource_data|val_from_key:"Identificación"|val_from_key:'Bienes muebles histórico-artístico'|val_from_key:"Época"|val_from_key:"Otra época" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Estilo : </b>{{ resource_data|val_from_key:"Identificación"|val_from_key:'Bienes muebles histórico-artístico'|val_from_key:"Estilo"|val_from_key:"@value" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Otros estilos : </b>{{ resource_data|val_from_key:"Identificación"|val_from_key:'Bienes muebles histórico-artístico'|val_from_key:"Estilo"|val_from_key:"Otros estilos" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Escuela : </b>{{ resource_data|val_from_key:"Identificación"|val_from_key:'Bienes muebles histórico-artístico'|val_from_key:"Escuela"|val_from_key:"@value" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Otra escuela : </b>{{ resource_data|val_from_key:"Identificación"|val_from_key:'Bienes muebles histórico-artístico'|val_from_key:"Escuela"|val_from_key:"Otra escuela" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Autor / atribución : </b>{{ resource_data|val_from_key:"Identificación"|val_from_key:'Bienes muebles histórico-artístico'|val_from_key:"Autor / atribución" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Origen o procedencia : </b>{{ resource_data|val_from_key:"Identificación"|val_from_key:'Bienes muebles histórico-artístico'|val_from_key:"Origen o procedencia" }}</span>
</div>
{% endif %}
{% if resource_data|val_from_key:"Identificación"|has_key:"Bienes muebles arqueológicos" %}
<span class="data-label" style="width: 100%;">Bienes muebles arqueológicos: </span>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Periodo : </b>{{ resource_data|val_from_key:"Identificación"|val_from_key:'Bienes muebles arqueológicos'|val_from_key:"Periodo" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Filiación cultural : </b>{{ resource_data|val_from_key:"Identificación"|val_from_key:'Bienes muebles arqueológicos'|val_from_key:"Filiación cultural" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Material asociado : </b>{{ resource_data|val_from_key:"Identificación"|val_from_key:'Bienes muebles arqueológicos'|val_from_key:"Material asociado" }}</span>
</div>
{% endif %}
{% endif %}
</div>
<div class="tiles-grid-grp-col">
<div class="tile-block">
<div class="tile-title">Imagen de referencia</div>
{% if resource_data|val_from_key:"Identificación"|has_key:"Imagen principal" %}
<img src="{{resource.sprpcb_url}}{{ resource_data|val_from_key:"Identificación"|val_from_key:"Imagen principal" }}" alt="Medio no encontrado o formato no soportado">
{% endif %}
</div>
</div>
</div>
{% if resource_data|val_from_key:"Identificación"|has_key:"Bienes muebles arqueológicos" %}
<div class="tile-block">
<span class="tile-title">Cronología : </span>
<div class="data-row">
<span class="data-value" style="width: 100%;">{{ resource_data|val_from_key:"Identificación"|val_from_key:'Bienes muebles arqueológicos'|val_from_key:"Cronología"|safe|cut:"<p>&nbsp;</p>" }}</span>
</div>
</div>
{% endif %}
<div class="tiles-grid-grp">
<div class="tile-block">
<div class="tile-title">Ubicación</div>
{% if resource_data|has_key:"Localización" %}
<div class="data-row">
<span class="data-label">Localidad: </span>
<span class="data-value">{{ resource_data|val_from_key:"Localización"|val_from_key:"Departamento / Localidad" }}</span>
</div>
<div class="data-row">
<span class="data-label">Departamento: </span>
<span class="data-value">{{ resource_data|val_from_key:"Localización"|val_from_key:"Ubicación extendida" }}</span>
</div>
<div class="data-row">
<span class="data-label">Espacio: </span>
<span class="data-value">{{ resource_data|val_from_key:"Localización"|val_from_key:"Espacio" }}</span>
</div>
<div class="data-row">
<span class="data-label">Inmueble: </span>
<span class="data-value">{{ resource_data|val_from_key:"Localización"|val_from_key:"Inmueble" }}</span>
</div>
<div class="data-row">
<span class="data-label">Colección: </span>
<span class="data-value">{{ resource_data|val_from_key:"Localización"|val_from_key:"Colección" }}</span>
</div>
{% if resource_data|val_from_key:"Localización"|has_key:"Ubicación" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Ambiente : </b> {{resource_data|val_from_key:"Localización"|val_from_key:"Ubicación"|val_from_key:"Ambiente" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>N° de ambiente : </b> {{resource_data|val_from_key:"Localización"|val_from_key:"Ubicación"|val_from_key:"N° de ambiente" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>N° de bandeja : </b> {{resource_data|val_from_key:"Localización"|val_from_key:"Ubicación"|val_from_key:"N° de bandeja" }}</span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>N° de caja : </b> {{resource_data|val_from_key:"Localización"|val_from_key:"Ubicación"|val_from_key:"N° de caja" }}</span>
</div>
<div class="data-row">
<span class="data-value" style="width: 100%;"><b>Ubicación actual : </b> {{resource_data|val_from_key:"Localización"|val_from_key:"Ubicación"|val_from_key:"Ubicación actual" }}</span>
</div>
{% endif %}
<div class="data-row">
<span class="data-label" style="width: 100%;">Coordenadas / Geometría: </span>
</div>
{% if resource_data|val_from_key:"Localización"|has_key:"Coordenadas / Geometría" %}
{% with gis_vector=resource_data|val_from_key:"Localización"|val_from_key:"Coordenadas / Geometría"|val_from_key:"@value"|json_to_obj %}
{% for gis in gis_vector.features %}
<div class="data-row">
<span class="data-value" style="width: 100%;">{{ gis.geometry }}</span>
</div>
{% endfor %}
{% endwith %}
<div class="data-row">
<span class="data-value" style="width: 100%;"><b>Geometría principal : </b>{{ resource_data|val_from_key:"Localización"|val_from_key:"Coordenadas / Geometría"|val_from_key:"Tipo de geometría" }}</span>
</div>
{% endif %}
{% endif %}
</div>
<div class="tiles-grid-grp-col">
<div class="tile-block">
<div class="tile-title">Mapa de referencia</div>
</div>
</div>
</div>
<div class="tile-block">
<div class="tile-title">Marco legal</div>
{% if resource_data|has_key:"Marco Legal" %}
<div class="tiles-grid-grp">
<div class="tile-block">
<div class="data-row">
<span class="data-value" style="width: 100%;"><b>Reconocimiento Internacional : </b>{{ resource_data|val_from_key:"Marco Legal"|val_from_key:" Reconocimiento Internacional" }}</span>
</div>
<div class="data-row">
<span class="data-value" style="width: 100%;"><b>Patrimonio Cultural Departamental : </b>{{ resource_data|val_from_key:"Marco Legal"|val_from_key:"Patrimonio Cultural Departamental" }}</span>
</div>
<div class="data-row">
<span class="data-value" style="width: 100%;"><b>Patrimonio Cultural Nacional : </b>{{ resource_data|val_from_key:"Marco Legal"|val_from_key:"Patrimonio Cultural Nacional" }}</span>
</div>
<div class="data-row">
<span class="data-value" style="width: 100%;"><b>Patrimonio Cultural Municipal : </b>{{ resource_data|val_from_key:"Marco Legal"|val_from_key:"Patrimonio Cultural Municipal" }}</span>
</div>
</div>
<div class="tiles-grid-grp-col">
<div class="tile-block">
{% if resource_data|val_from_key:"Marco Legal"|has_key:"Forma de ingreso" %}
{% if resource_data|val_from_key:"Marco Legal"|val_from_key:"Forma de ingreso"|has_key:"Ingreso" %}
<div class="data-row">
<span class="data-value" style="width: 100%;"><b>Forma de ingreso : </b>{{ resource_data|val_from_key:"Marco Legal"|val_from_key:"Forma de ingreso"|val_from_key:"Ingreso"|val_from_key:"@value" }}</span>
</div>
{% if resource_data|val_from_key:"Marco Legal"|val_from_key:"Forma de ingreso"|val_from_key:"Ingreso"|has_key:"Otros" %}
<div class="data-row">
<span class="data-value" style="width: 100%;"><b>Otra forma de ingreso : </b>{{ resource_data|val_from_key:"Marco Legal"|val_from_key:"Forma de ingreso"|val_from_key:"Ingreso"|val_from_key:"Otros"|val_from_key:"@value" }}</span>
</div>
<div class="data-row">
<span class="data-value" style="width: 100%;"><b>Tipo de documento : </b>{{ resource_data|val_from_key:"Marco Legal"|val_from_key:"Forma de ingreso"|val_from_key:"Ingreso"|val_from_key:"Otros"|val_from_key:"Tipo de documento de entrega" }}</span>
</div>
{% endif %}
{% endif %}
{% endif %}
</div>
</div>
</div>
{% endif %}
</div>
<div class="tile-block">
<div class="tile-title">Características</div>
{% if resource_data|has_key:"Características" %}
{% for desc in resource_data|val_from_key:"Características" %}
{% if desc == "Principales transformaciones de la expresión Cultural" or desc == "Riesgos y amenazas" %}
<div class="data-row">
<span class="data-label" style="width: 100%;">{{ desc }} : </span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;">{{ resource_data|val_from_key:"Características"|val_from_key:desc|safe|cut:"<p>&nbsp;</p>" }}</span>
</div>
{% elif desc == "Medidas de la pieza" %}
<div class="data-row">
<span class="data-label" style="width: 100%;">{{ desc }} (cm. y gr.) : </span>
</div>
{% if resource_data|val_from_key:"Características"|val_from_key:desc|has_key:"Medidas" %}
{% for item in resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Medidas" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>{{item.Medida}} : </b>Medida mínima: {{ item|val_from_key:"Medida mínima" }} | Medida máxima : {{ item|val_from_key:"Medida máxima" }}</span>
</div>
{% endfor %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Observaciones : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Observaciones a las medidas"|safe|cut:"<p>&nbsp;</p>" }}</span>
</div>
{% endif %}
{% elif desc == "Estado de conservación" %}
<div class="data-row">
<span class="data-value" style="width: 100%;"><b>Estado de conservación : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"@value"|safe|cut:"<p>&nbsp;</p>" }} </span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Observaciones : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Observaciones"|safe|cut:"<p>&nbsp;</p>" }}</span>
</div>
{% elif desc == "Uso Actual" or desc == "Nivel de integridad" %}
<div class="data-row">
<span class="data-value" style="width: 100%;"><b>{{ desc }} : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc }}</span>
</div>
{% elif desc == "Intervenciones" %}
<div class="data-row">
<span class="data-label" style="width: 100%;">{{ desc }} : </span>
</div>
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Tiene intervenciones : </b>{{resource_data|val_from_key:"Características"|val_from_key:"Intervenciones"|val_from_key:"Sin intervención"|yesno:"Si,No"}}</span>
</div>
{% if resource_data|val_from_key:"Características"|val_from_key:desc|has_key:"Intervenciónes" %}
{% for item in resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Intervenciónes" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Intervención : </b>{{ item }}</span>
</div>
{% endfor %}
{% endif %}
{% elif desc == "Características Iconográficas/ornamentales" %}
<div class="data-row">
<span class="data-label" style="width: 100%;">{{ desc }} : </span>
</div>
{% for item in resource_data|val_from_key:"Características"|val_from_key:desc %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;">{{ item|safe|cut:"<p>&nbsp;</p>" }}</span>
</div>
{% endfor %}
{% endif %}
{% endfor %}
<div class="data-row">
<span class="data-value" style="width: 100%;"><b>Condiciones de seguridad : </b>{{ resource_data|val_from_key:"Características"|val_from_key:"Condiciones de seguridad" }} </span>
</div>
{% endif %}
</div>
<div class="tile-block">
<div class="tile-title">Medios adjuntos</div>
{% if resource_data|has_key:"Recursos adjuntos" %}
<div class="flex-container">
{% for medio in resource_data|val_from_key:'Recursos adjuntos'|val_from_key:'Medio de información' %}
<div class="flex-item">
<div class="data-row" style="margin-left: 15px;">
<a href={{resource.sprpcb_url}}{{ medio.url }} >{{ medio.tipo }} : {{ medio|val_from_key:'@value' }} ({{ medio.formato|slice:"-4:" }})</a>
</div>
</div>
{% endfor %}
</div>
{% endif %}
</div>
<div class="tile-block">
<div class="tile-title">Observaciones</div>
{% if resource_data|has_key:"Observaciones" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>{{ resource_data|val_from_key:"Observaciones"|val_from_key:"Tipo de descripción" }} : </b>{{ resource_data|val_from_key:"Observaciones"|val_from_key:"Descripción"|safe|cut:"<p>&nbsp;</p>" }} </span>
</div>
{% endif %}
</div>
<div class="tile-block">
<div class="tile-title">Responsables</div>
{% if resource_data|has_key:"Responsables" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>Entidad administrativa : </b>{{ resource_data|val_from_key:"Responsables"|val_from_key:"Entidad administrativa" }} </span>
</div>
{% if resource_data|val_from_key:"Responsables"|has_key:"Responsable" %}
{% for item in resource_data|val_from_key:"Responsables"|val_from_key:"Responsable" %}
<div class="data-row" style="margin-left: 15px;">
<span class="data-value" style="width: 100%;"><b>{{ item|val_from_key:"Rol" }} ({{ item|val_from_key:"Fecha" }}) : </b>{{ item|val_from_key:"@value" }}</span>
</div>
{% endfor %}
{% endif %}
{% endif %}
</div>
{% if resource_data|has_key:"Recursos adjuntos" and resource.print_imgs %}
<h2>Anexo de imágenes</h2>
<div class="gallery">
{% for medio in resource_data|val_from_key:'Recursos adjuntos'|val_from_key:'Medio de información' %}
{% if medio.formato in "image/bmp, image/gif, image/jpg, image/jpeg, image/png, image/tif, image/tiff" %}
<div class="gallery-item">
<img src="{{resource.sprpcb_url}}{{ medio.url }}" alt="{{medio.file}}">
<a href="{{resource.sprpcb_url}}{{ medio.url }}">&nbsp; {{ medio.tipo }} : {{ medio|val_from_key:'@value' }}&nbsp; </a>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% else %}
<p class="no-data">El recurso no tiene información.</p>
{% endif %}
</body>
{% endwith %}
{% endfor %}
</html>

312
reports/pi_pdf_report.html Normal file
View File

@@ -0,0 +1,312 @@
<!-- mi_proyecto/templates/reports/pi_pdf_report.html -->
{% load template_tags %}
{% for resource in resources %}
{% with resource_data=resource.resource %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
:root {--oscuro: #242424; --carbon: #4c4c4c; --ceniza: #999; --claro: #fafafa; --resaltado: #d1a21c;}
html { color: var(carbon); font-family: 'Helvetica', sans-serif; font-size: 9pt; font-weight: 300; line-height: 1.2;}
body { margin: 0;}
h1 { color: var(--resaltado); font-size: 13pt; text-align: center; width: 100%;}
h2, h3, h4 { color: black; font-weight: 400;}
h2 { break-before: always; font-size: 12pt;}
h3 { font-size: 12pt;}
h4 { font-size: 11pt;}
a { font-size:.85em;}
.flex-container { display: flex; flex-wrap: wrap; gap: 0 4px; margin-top: 5px;}
.flex-item {flex: 0 0 calc(50% - 5px); box-sizing: border-box;}
.tiles-grid-grp { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 2px;}
.tiles-grid-grp-col { grid-column: 2; contain: size;}
.tile-block { border: 1px solid var(--ceniza); border-radius: 4px; padding: 2px; margin: 2px 0; background-color: var(--claro);}
.tile-title { font-size: 11pt; font-weight: bold; color: var(--oscuro); border-bottom: 1px solid var(--ceniza); padding-bottom: 2px; margin-bottom: 5px;}
.data-row { display: flex; padding: 2px 0; border-bottom: 1px solid var(--claro);}
.data-label { font-weight: 600; letter-spacing: -0.05em; width: 40%; color: var(--oscuro);}
.data-value { width: 60%; font-size:.9em; word-wrap: break-word;}
.no-data { color: var(--ceniza); font-style: italic;}
.tiles-grid-grp-col .tile-block img { object-fit: cover; width: 330px; max-height: 230px;}
.gallery { display: grid; grid-template-columns: repeat(2, 340px); grid-auto-rows: 272px; gap: 5px; justify-content: center; }
.gallery-item { overflow: hidden; border-radius: 5px; background-color: var(--ceniza); position: relative;}
.gallery-item img { width: 100%; height: 100%; object-fit: cover;}
.gallery-item a {position: absolute; bottom: 6px; left: 6px; color: var(--carbon); text-decoration: none; background-color: rgb(255 255 255 / 50%); font-size: .75em;}
@page {
@top-left { background: var(--resaltado); content: counter(page); height: 1cm; text-align: center; width: 1cm;}
@top-center { background: var(--resaltado); content: ''; display: block; height: .05cm; opacity: .5; width: 100%;}
@top-right { content: '{{ resource.grafo }} \A UUID: {{ resource.resourceinstanceid }}'; white-space: pre-line; color: var(--ceniza); font-size: 8pt; height: 1cm; vertical-align: middle; width: 100%;}
@bottom-center { background: var(--resaltado); content: ''; display: block; height: .05cm; opacity: .5; width: 100%;}
@bottom-left { content: 'Sistema Plurinacional de Registro de Patrimonio Cultural Boliviano\ASPRPCB - {{ resource.eta_group }}'; white-space: pre-line; color: var(--ceniza); font-size: 8pt; height: 1cm; vertical-align: middle; width: 100%;}
@bottom-right { content: '{{ resource.fecha }} \A BOLIVIA'; white-space: pre-line; color: var(--ceniza); font-size: 8pt; height: 1cm; vertical-align: middle; width: 100%;}
size: Letter;
margin-top: 1.5cm; margin-bottom: 1.8cm; margin-left: 2cm; margin-right: 1.5cm;
}
</style>
<title>{{ resource.grafo }} ID de sistema: {{ resource.resourceinstanceid }}</title>
<meta name="description" content="Ficha PDF">
</head>
<body>
{% if resource_data %}
<h1>{{ resource.displayname|truncatewords:10 }}</h1>
<div class="tiles-grid-grp">
<div class="tile-block column" >
<div class="tile-title">Identificación</div>
{% if resource_data|has_key:"Identificación" %}
<div class="data-row">
<span class="data-label">Código principal: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:"Código principal" }}</span>
</div>
<div class="data-row">
<span class="data-label">Código anterior: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:"Código anterior" }}</span>
</div>
<div class="data-row">
<span class="data-label">Código alternativo: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:"Código alternativo" }}</span>
</div>
<div class="data-row">
<span class="data-label">Filiación cultural: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:"Filiación cultural" }}</span>
</div>
<div class="data-row">
<span class="data-label">Ámbito / subámbito: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:'Ámbito / subámbito' }}</span>
</div>
<div class="data-row">
<span class="data-label">Nominación actual: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:'Nominación actual' }}</span>
</div>
<div class="data-row">
<span class="data-label">Origen o procedencia: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:'Origen o procedencia' }}</span>
</div>
<div class="data-row">
<span class="data-label">Nominación anterior: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:'Nominación anterior' }}</span>
</div>
<div class="data-row">
<span class="data-label">Manifestación cultural: </span>
<span class="data-value">{{ resource_data|val_from_key:"Identificación"|val_from_key:'Manifestación cultural' }}</span>
</div>
{% endif %}
</div>
<div class="tiles-grid-grp-col">
<div class="tile-block">
<div class="tile-title">Imagen de referencia</div>
{% if resource_data|has_key:"Información gráfica" %}
{% with medios=resource_data|val_from_key:'Información gráfica'|val_from_key:'Medio de información' %}
<img class="imagen-calzada" src="{{resource.sprpcb_url}}{{ medios.0.url }}" alt="{{medios.0.file}}">
{% endwith %}
{% endif %}
</div>
</div>
</div>
<div class="tiles-grid-grp">
<div class="tile-block">
<div class="tile-title">Ubicación</div>
{% if resource_data|has_key:"Ubicación 2" %}
<div class="data-row">
<span class="data-label">Localidad: </span>
<span class="data-value">{{ resource_data|val_from_key:"Ubicación 2"|val_from_key:"Departamento" }}</span>
</div>
<div class="data-row">
<span class="data-label">Departamento: </span>
<span class="data-value">{{ resource_data|val_from_key:"Ubicación 2"|val_from_key:"Ubicación extendida" }}</span>
</div>
<div class="data-row">
<span class="data-label">Otra localidad: </span>
<span class="data-value">{{ resource_data|val_from_key:"Ubicación 2"|val_from_key:"Otra localidad" }}</span>
</div>
<div class="data-row">
<span class="data-label" style="width: 100%;">Coordenadas / Geometría: </span>
</div>
{% if resource_data|val_from_key:"Ubicación 2"|has_key:"Coordenadas / Geometría" %}
{% with gis_vector=resource_data|val_from_key:"Ubicación 2"|val_from_key:"Coordenadas / Geometría"|val_from_key:"@value"|json_to_obj %}
{% for gis in gis_vector.features %}
<div class="data-row">
<span class="data-value" style="width: 100%;">{{ gis.geometry }}</span>
</div>
{% endfor %}
{% endwith %}
<div class="data-row">
<span class="data-label">Geometría principal: </span>
<span class="data-value">{{ resource_data|val_from_key:"Ubicación 2"|val_from_key:"Coordenadas / Geometría"|val_from_key:"Tipo de geometría" }}</span>
</div>
{% endif %}
{% endif %}
</div>
<div class="tiles-grid-grp-col">
<div class="tile-block">
<div class="tile-title">Mapa de referencia</div>
</div>
</div>
</div>
<div class="tile-block">
<div class="tile-title">Marco legal</div>
{% if resource_data|has_key:"Marco legal" %}
<div class="data-row">
<span class="data-label">Reconocimiento Internacional: </span>
<span class="data-value">{{ resource_data|val_from_key:"Marco legal"|val_from_key:" Reconocimiento Internacional" }}</span>
</div>
<div class="data-row">
<span class="data-label">Patrimonio Cultural Departamental: </span>
<span class="data-value">{{ resource_data|val_from_key:"Marco legal"|val_from_key:"Patrimonio Cultural Departamental" }}</span>
</div>
<div class="data-row">
<span class="data-label">Patrimonio Cultural Nacional: </span>
<span class="data-value">{{ resource_data|val_from_key:"Marco legal"|val_from_key:"Patrimonio Cultural Nacional" }}</span>
</div>
<div class="data-row">
<span class="data-label">Patrimonio Cultural Municipal: </span>
<span class="data-value">{{ resource_data|val_from_key:"Marco legal"|val_from_key:"Patrimonio Cultural Municipal" }}</span>
</div>
{% endif %}
</div>
<div class="tile-block">
<div class="tile-title">Características</div>
{% if resource_data|has_key:"Características" %}
{% for desc in resource_data|val_from_key:"Características" %}
{% if desc == "Principales transformaciones de la expresión Cultural" or desc == "Riesgos y amenazas" %}
<div class="data-row">
<span class="data-label" style="width: 100%;">{{ desc }} : </span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;">{{ resource_data|val_from_key:"Características"|val_from_key:desc|safe|cut:"<p>&nbsp;</p>" }}</span>
</div>
{% elif resource_data|val_from_key:"Características"|val_from_key:desc|has_key:"Descripción resumida" and resource_data|val_from_key:"Características"|val_from_key:desc|has_key:"@value" %}
<div class="data-row">
<span class="data-label" style="width: 100%;">{{ desc }} : </span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;">{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"@value" }}</span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Descripción resumida : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Descripción resumida"|safe|cut:"<p>&nbsp;</p>" }}</span>
</div>
{% elif desc == "Descripción del ámbito" %}
<div class="data-row">
<span class="data-label" style="width: 100%;">{{ desc }} : </span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;">{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"@value" }}</span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;">{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Descripción" }}</span>
</div>
{% elif desc == "Mecanismo de transmisión" %}
<div class="data-row">
<span class="data-label" style="width: 100%;">{{ desc }} : </span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Mecanismo : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Mecanismo" }}</span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Otro mecanismo : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Otro mecanismo" }}</span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Descripción resumida : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Descripción resumida"|safe|cut:"<p>&nbsp;</p>" }}</span>
</div>
{% elif desc == "Expresiones musicales" %}
<div class="data-row">
<span class="data-label" style="width: 100%;">{{ desc }} : </span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Historias de vida (música, canto y danza) : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Historias de vida (música, canto y danza)" }}</span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Género musical : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Género musical" }}</span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Forma musical (subgénero) : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Forma musical (subgénero)" }}</span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Canto : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Canto" }}</span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Danza : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Danza" }}</span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Descripción resumida : </b>{{ resource_data|val_from_key:"Características"|val_from_key:desc|val_from_key:"Descripción resumida"|safe|cut:"<p>&nbsp;</p>" }}</span>
</div>
{% elif desc == "Elementos significativos" %}
<div class="data-row">
<span class="data-label" style="width: 100%;">{{ desc }} : </span>
</div>
{% for item in resource_data|val_from_key:"Características"|val_from_key:"Elementos significativos" %}
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Nombre : </b>{{ item|val_from_key:"Nombre" }}</span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Tipo : </b>{{ item|val_from_key:"Tipo" }}</span>
</div>
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Detalle del elemento : </b>{{ item|val_from_key:"Detalle del elemento" }}</span>
</div>
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
</div>
<div class="tile-block">
<div class="tile-title">Medios adjuntos</div>
{% if resource_data|has_key:"Información gráfica" %}
<div class="flex-container">
{% for medio in resource_data|val_from_key:'Información gráfica'|val_from_key:'Medio de información' %}
<div class="flex-item">
<div class="data-row" style="margin-left: 15px;">
<a href={{resource.sprpcb_url}}{{ medio.url }} >{{ medio.tipo }} : {{ medio|val_from_key:'@value' }} ({{ medio.formato|slice:"-4:" }})</a>
</div>
</div>
{% endfor %}
</div>
{% endif %}
</div>
<div class="tile-block">
<div class="tile-title">Descripción general</div>
{% if resource_data|has_key:"Descripción asignada" %}
<div class="data-row">
<span class="data-label" style="width: 100%;">{{ resource_data|val_from_key:"Descripción asignada"|val_from_key:"Tipo de descripción" }} : </span>
</div>
<div class="data-row">
<span class="data-value" style="width: 100%;">{{ resource_data|val_from_key:"Descripción asignada"|val_from_key:"Descripción"|safe|cut:"<p>&nbsp;</p>" }}</span>
</div>
{% endif %}
</div>
<div class="tile-block">
<div class="tile-title">Responsables</div>
{% if resource_data|has_key:"Responsables" %}
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>Entidad administrativa : </b>{{ resource_data|val_from_key:"Responsables"|val_from_key:"Entidad administrativa" }} </span>
</div>
{% if resource_data|val_from_key:"Responsables"|has_key:"Responsable" %}
{% for item in resource_data|val_from_key:"Responsables"|val_from_key:"Responsable" %}
<div class="data-row" style="margin-left: 20px;">
<span class="data-value" style="width: 100%;"><b>{{ item|val_from_key:"Rol" }} ({{ item|val_from_key:"Fecha" }}) : </b>{{ item|val_from_key:"@value" }}</span>
</div>
{% endfor %}
{% endif %}
{% endif %}
</div>
{% if resource_data|has_key:"Información gráfica" and resource.print_imgs %}
<h2>Anexo de imágenes</h2>
<div class="gallery">
{% for medio in resource_data|val_from_key:'Información gráfica'|val_from_key:'Medio de información' %}
{% if medio.formato in "image/bmp, image/gif, image/jpg, image/jpeg, image/png, image/tif, image/tiff" %}
<div class="gallery-item">
<img src="{{resource.sprpcb_url}}{{ medio.url }}" alt="{{medio.file}}">
<a href="{{resource.sprpcb_url}}{{ medio.url }}">&nbsp; {{ medio.tipo }} : {{ medio|val_from_key:'@value' }}&nbsp; </a>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% else %}
<p class="no-data">El recurso no tiene información.</p>
{% endif %}
</body>
{% endwith %}
{% endfor %}
</html>