From d495a25022e1b4bd1b3269f7971b959ce731541c Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Sun, 7 Aug 2022 14:56:43 +0200 Subject: get base url from settings --- client/views.py | 4 ++-- manager/settings.py | 2 ++ server/templates/server/approve_doc_direct.html | 4 ++-- version.txt | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/client/views.py b/client/views.py index 3ddc417..deeb93c 100644 --- a/client/views.py +++ b/client/views.py @@ -7,7 +7,7 @@ from django.http import HttpResponse, HttpResponseRedirect, FileResponse from django.contrib.auth.decorators import login_required from django.shortcuts import render from accounts.views import copy_from_midata -from django.conf import settings +from django.conf import Settings, settings from io import BytesIO import pdfkit @@ -58,7 +58,7 @@ def index(request): if request.POST["action"][0] == 'f': # generate approve pdf template = get_template('client/approve_doc_pdf.html') - context = {'doc': document, 'uri': request.build_absolute_uri(reverse('approve_direct')) + "?code=" + str(document.code)} + context = {'doc': document, 'uri': settings.FQD_BASE_URL + reverse('approve_direct') + "?code=" + str(document.code)} html = template.render(context) pdf = pdfkit.from_string(html, False) result = BytesIO(pdf) diff --git a/manager/settings.py b/manager/settings.py index 3432ae0..c2ffdf6 100644 --- a/manager/settings.py +++ b/manager/settings.py @@ -173,3 +173,5 @@ STATICFILES_DIRS = [ ] LOGIN_REDIRECT_URL = '/' LOGOUT_REDIRECT_URL = '/' + +FQD_BASE_URL = 'http://127.0.0.1:8000' \ No newline at end of file diff --git a/server/templates/server/approve_doc_direct.html b/server/templates/server/approve_doc_direct.html index a435b5f..7327b2f 100644 --- a/server/templates/server/approve_doc_direct.html +++ b/server/templates/server/approve_doc_direct.html @@ -108,8 +108,8 @@ function send() { {% if error %} function loadCode(code) { if (code.substring(0, 4) == 'http') { - window.location.replace(code); - return; + code = code.substring(code.length - 6); + console.log(code); } var currentUrl = window.location.href; diff --git a/version.txt b/version.txt index f4190dd..e019395 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ version=0.5 -rev=40 +rev=41 -- cgit v1.2.1