From 0d359e9e579cef7661fb55bf5389fac4abfd9330 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sun, 4 Aug 2024 15:52:19 +0200 Subject: [PATCH 1/2] Add cookie prefix environment variable to config --- cps/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cps/__init__.py b/cps/__init__.py index 157dd14e..5ecc00eb 100644 --- a/cps/__init__.py +++ b/cps/__init__.py @@ -85,7 +85,9 @@ app.config.update( SESSION_COOKIE_HTTPONLY=True, SESSION_COOKIE_SAMESITE='Strict', REMEMBER_COOKIE_SAMESITE='Strict', # will be available in flask-login 0.5.1 earliest - WTF_CSRF_SSL_STRICT=False + WTF_CSRF_SSL_STRICT=False, + SESSION_COOKIE_NAME=os.environ.get('COOKIE_PREFIX', "") + "session", + REMEMBER_COOKIE_NAME=os.environ.get('COOKIE_PREFIX', "") + "remember_token" ) lm = MyLoginManager() From bdac7a3257ce16a357473ee9afdde56f9000ac7d Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sun, 4 Aug 2024 16:39:05 +0200 Subject: [PATCH 2/2] Changed formating of float values. IF value ends not with "0" tailing "0" are printed --- cps/jinjia.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cps/jinjia.py b/cps/jinjia.py index f0b3489d..80c2b7ea 100644 --- a/cps/jinjia.py +++ b/cps/jinjia.py @@ -26,6 +26,7 @@ from markupsafe import escape import datetime import mimetypes from uuid import uuid4 +import re from flask import Blueprint, request, url_for from flask_babel import format_date @@ -112,7 +113,10 @@ def yesno(value, yes, no): @jinjia.app_template_filter('formatfloat') def formatfloat(value, decimals=1): value = 0 if not value else value - return ('{0:.' + str(decimals) + 'f}').format(value).rstrip('0').rstrip('.') + formated_value = ('{0:.' + str(decimals) + 'f}').format(value) + if formated_value.endswith('.' + "0" * decimals): + formated_value = formated_value.rstrip('0').rstrip('.') + return formated_value @jinjia.app_template_filter('formatseriesindex')