From f80c67828bbd70ee482ce4178bfaffffb1f415ef Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sun, 5 Jul 2020 14:35:57 +0200 Subject: [PATCH] Fix #1500 (Custom ratings of increment 0.5 are allowed) --- cps/templates/book_edit.html | 4 ++-- cps/templates/detail.html | 2 +- cps/templates/search_form.html | 2 +- cps/web.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cps/templates/book_edit.html b/cps/templates/book_edit.html index 14bc590a..8bbe2460 100644 --- a/cps/templates/book_edit.html +++ b/cps/templates/book_edit.html @@ -159,9 +159,9 @@ {% endif %} {% if c.datatype == 'rating' %} - 0 %} - value="{{ '%d' % (book['custom_column_' ~ c.id][0].value / 2) }}" + value="{{ '%.1f' % (book['custom_column_' ~ c.id][0].value / 2) }}" {% endif %}> {% endif %} diff --git a/cps/templates/detail.html b/cps/templates/detail.html index a87695eb..d4b4252c 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -174,7 +174,7 @@ {{ c.name }}: {% for column in entry['custom_column_' ~ c.id] %} {% if c.datatype == 'rating' %} - {{ '%d' % (column.value / 2) }} + {{ '%d' % (column.value / 2) }}{% if ((column.value /2) % 1) != 0 %}{{ '.%d' % (((column.value /2) % 1)*10) }} {% endif %} {% else %} {% if c.datatype == 'bool' %} {% if column.value == true %} diff --git a/cps/templates/search_form.html b/cps/templates/search_form.html index 60cffa1d..fdc2990b 100644 --- a/cps/templates/search_form.html +++ b/cps/templates/search_form.html @@ -165,7 +165,7 @@ {% endif %} {% if c.datatype == 'rating' %} - + {% endif %} {% endfor %} diff --git a/cps/web.py b/cps/web.py index 9af9858d..7e39054d 100644 --- a/cps/web.py +++ b/cps/web.py @@ -1142,7 +1142,7 @@ def advanced_search(): db.cc_classes[c.id].value == custom_query)) elif c.datatype == 'rating': q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( - db.cc_classes[c.id].value == int(custom_query) * 2)) + db.cc_classes[c.id].value == int(float(custom_query) * 2))) else: q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( func.lower(db.cc_classes[c.id].value).ilike("%" + custom_query + "%")))