From 7e0d9fbace922e60c34d89aea16d6bc061b52c81 Mon Sep 17 00:00:00 2001 From: Michael Knepher Date: Mon, 29 Jun 2020 23:34:26 -0700 Subject: [PATCH] series_index filter to show x.0 as x --- cps/jinjia.py | 7 +++++++ cps/templates/author.html | 4 ++-- cps/templates/detail.html | 2 +- cps/templates/discover.html | 2 +- cps/templates/index.html | 4 ++-- cps/templates/search.html | 2 +- cps/templates/shelf.html | 2 +- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/cps/jinjia.py b/cps/jinjia.py index 28c2621a..b01ad69f 100644 --- a/cps/jinjia.py +++ b/cps/jinjia.py @@ -111,3 +111,10 @@ def timestamptodate(date, fmt=None): @jinjia.app_template_filter('yesno') def yesno(value, yes, no): return yes if value else no + +@jinjia.app_template_filter('formatseriesindex') +def formatseriesindex_filter(series_index): + if int(series_index) - series_index == 0: + return int(series_index) + else: + return series_index \ No newline at end of file diff --git a/cps/templates/author.html b/cps/templates/author.html index cce173b0..5148dfef 100644 --- a/cps/templates/author.html +++ b/cps/templates/author.html @@ -75,7 +75,7 @@ {{entry.series[0].name}} - ({{entry.series_index}}) + ({{entry.series_index|formatseriesindex}})

{% endif %} {% if entry.ratings.__len__() > 0 %} @@ -127,7 +127,7 @@ {{entry.series[0].name}} - ({{entry.series_index}}) + ({{entry.series_index|formatseriesindex}})

{% endif %}
diff --git a/cps/templates/detail.html b/cps/templates/detail.html index 24ba10c7..d348b7f6 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -114,7 +114,7 @@ {% endif %} {% if entry.series|length > 0 %} -

{{_('Book')}} {{entry.series_index}} {{_('of')}} {{entry.series[0].name}}

+

{{_('Book')}} {{entry.series_index|formatseriesindex}} {{_('of')}} {{entry.series[0].name}}

{% endif %} {% if entry.languages.__len__() > 0 %} diff --git a/cps/templates/discover.html b/cps/templates/discover.html index dd8dc9bb..dac0afb7 100644 --- a/cps/templates/discover.html +++ b/cps/templates/discover.html @@ -39,7 +39,7 @@ {{entry.series[0].name}} - ({{entry.series_index}}) + ({{entry.series_index|formatseriesindex}})

{% endif %} {% if entry.ratings.__len__() > 0 %} diff --git a/cps/templates/index.html b/cps/templates/index.html index f39a7181..1fed6be2 100644 --- a/cps/templates/index.html +++ b/cps/templates/index.html @@ -38,7 +38,7 @@ {{entry.series[0].name}} - ({{entry.series_index}}) + ({{entry.series_index|formatseriesindex}})

{% endif %} {% if entry.ratings.__len__() > 0 %} @@ -114,7 +114,7 @@ {{entry.series[0].name}} - ({{entry.series_index}}) + ({{entry.series_index|formatseriesindex}})

{% endif %} {% if entry.ratings.__len__() > 0 %} diff --git a/cps/templates/search.html b/cps/templates/search.html index 7e546c8e..213bed84 100644 --- a/cps/templates/search.html +++ b/cps/templates/search.html @@ -81,7 +81,7 @@ {{entry.series[0].name}} - ({{entry.series_index}}) + ({{entry.series_index|formatseriesindex}})

{% endif %} diff --git a/cps/templates/shelf.html b/cps/templates/shelf.html index cf44cccf..6551bef6 100644 --- a/cps/templates/shelf.html +++ b/cps/templates/shelf.html @@ -48,7 +48,7 @@ {{entry.series[0].name}} - ({{entry.series_index|int}}) + ({{entry.series_index|formatseriesindex}})

{% endif %} {% if entry.ratings.__len__() > 0 %}