1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-18 14:10:30 +00:00

Changed formating of float values. IF value ends not with "0" tailing "0" are printed

This commit is contained in:
Ozzie Isaacs 2024-08-04 16:39:05 +02:00
parent 0d359e9e57
commit bdac7a3257

View File

@ -26,6 +26,7 @@ from markupsafe import escape
import datetime import datetime
import mimetypes import mimetypes
from uuid import uuid4 from uuid import uuid4
import re
from flask import Blueprint, request, url_for from flask import Blueprint, request, url_for
from flask_babel import format_date from flask_babel import format_date
@ -112,7 +113,10 @@ def yesno(value, yes, no):
@jinjia.app_template_filter('formatfloat') @jinjia.app_template_filter('formatfloat')
def formatfloat(value, decimals=1): def formatfloat(value, decimals=1):
value = 0 if not value else value 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') @jinjia.app_template_filter('formatseriesindex')