ajustes a la vista
This commit is contained in:
26
pdf/views.py
26
pdf/views.py
@@ -52,7 +52,8 @@ def static_map_view(geojson_colec, sat_map):
|
||||
else:
|
||||
style_id = "light-v11"
|
||||
|
||||
width, height = 340, 340
|
||||
width, height = 400, 400
|
||||
padding = 100
|
||||
|
||||
# Procedimiento pendiente para extraer el token desde la configuración del sistema
|
||||
access_token = 'pk.eyJ1IjoianNidXJnb3N2IiwiYSI6ImNsaWhoN3ZtMTBxeHUzZm1xaGM0cGpxOXIifQ.ki3vldVB5MwZMqDSpLSjLg'
|
||||
@@ -60,7 +61,7 @@ def static_map_view(geojson_colec, sat_map):
|
||||
mapbox_url = (
|
||||
f"https://api.mapbox.com/styles/v1/{username}/{style_id}/static/"
|
||||
f"geojson({encoded_geojson})/auto/{width}x{height}"
|
||||
f"?access_token={access_token}"
|
||||
f"?padding={padding}&access_token={access_token}"
|
||||
)
|
||||
|
||||
response = requests.get(mapbox_url)
|
||||
@@ -211,22 +212,23 @@ def export_resource_pdf(request, resourceid, printubic, satmap, printimgs, print
|
||||
merger = PdfWriter()
|
||||
merger.append(PdfReader(io.BytesIO(gen_pdf_file)))
|
||||
|
||||
root_path = Path(__file__).resolve().parent.parent
|
||||
|
||||
if ruta_medios is not None and bool(int(printpdfs)) :
|
||||
for medio in reduce(getitem, ruta_medios[:-1], resource_data)[ruta_medios[-1]] :
|
||||
if medio['formato'] == 'application/pdf' :
|
||||
medio_file = f'{root_path}/uploadedfiles/{medio["file"]}'
|
||||
with open(medio_file,'rb') as pdf_file :
|
||||
merger.append(pdf_file)
|
||||
try :
|
||||
response = requests.get(f'{sprpcb_url}{medio["url"]}', timeout=10)
|
||||
response.raise_for_status()
|
||||
remote_pdf_stream = io.BytesIO(response.content)
|
||||
merger.append(remote_pdf_stream)
|
||||
remote_pdf_stream.close()
|
||||
except requests.RequestException as e:
|
||||
return HttpResponse(f"Error al incluir el archivo PDF: {e}", status=502)
|
||||
|
||||
output_buffer = io.BytesIO()
|
||||
merger.write(output_buffer)
|
||||
merger.close()
|
||||
else:
|
||||
output_buffer = io.BytesIO()
|
||||
merger.write(output_buffer)
|
||||
merger.close()
|
||||
output_buffer.seek(0)
|
||||
merger.close()
|
||||
|
||||
response = HttpResponse(output_buffer.read(), content_type='application/pdf')
|
||||
response['Content-Disposition'] = f'attachment; filename="{nombre_pdf}.pdf"'
|
||||
return response
|
||||
Reference in New Issue
Block a user