From 4ff88884723e9555b1662c9de8e53c443d1ec00b Mon Sep 17 00:00:00 2001 From: Juan Burgos Date: Fri, 7 Aug 2026 23:19:25 +0000 Subject: [PATCH] =?UTF-8?q?protecci=C3=B3n=20del=20token=20de=20mapbox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pdf/views.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pdf/views.py b/pdf/views.py index 252a57d..3bd66f2 100644 --- a/pdf/views.py +++ b/pdf/views.py @@ -1,10 +1,11 @@ # 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.models import GraphModel from arches.app.models.resource import Resource from django.contrib.auth.models import Group from datetime import datetime @@ -19,9 +20,14 @@ import json import ast def static_map_view(geojson_colec, sat_map): + g_sys_cfg=GraphModel.objects.get(name='{"en": "Arches System Settings"}') + r_sys_cfg=Resource.objects.get(graph=g_sys_cfg) + r_sys_cfg_data=r_sys_cfg.to_json() + access_token = r_sys_cfg_data['Map Settings']['Mapbox']['MAPBOX_API_KEY'] geojson_dict = ast.literal_eval(geojson_colec) if sat_map: + style_id = "satellite-streets-v12" # streets-v12 | outdoors-v11 | satellite-streets-v12 for geo in geojson_dict['features'] : if geo['geometry'].get('type') == 'Polygon': geo['properties'] = { @@ -42,22 +48,16 @@ def static_map_view(geojson_colec, sat_map): "stroke-width": 2, "stroke-opacity": 0.8 } + else: + style_id = "light-v11" geojson_string = json.dumps(geojson_dict, separators=(',', ':')) encoded_geojson = urllib.parse.quote(geojson_string) username = "mapbox" - if sat_map: - style_id = "satellite-streets-v12" # streets-v12 | outdoors-v11 | satellite-streets-v12 - else: - style_id = "light-v11" - width, height = 400, 400 padding = 100 - # Procedimiento pendiente para extraer el token desde la configuración del sistema - access_token = 'pk.eyJ1IjoianNidXJnb3N2IiwiYSI6ImNsaWhoN3ZtMTBxeHUzZm1xaGM0cGpxOXIifQ.ki3vldVB5MwZMqDSpLSjLg' - mapbox_url = ( f"https://api.mapbox.com/styles/v1/{username}/{style_id}/static/" f"geojson({encoded_geojson})/auto/{width}x{height}"