From 931981a37aec9192136b3c003a40198d812bd27b Mon Sep 17 00:00:00 2001 From: Cervinko Cera Date: Thu, 21 Apr 2016 12:46:26 +0200 Subject: [PATCH] fix for custom column 'rating' --- cps/templates/edit_book.html | 4 +--- cps/web.py | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cps/templates/edit_book.html b/cps/templates/edit_book.html index cd8b2aa1..7b74d7e2 100644 --- a/cps/templates/edit_book.html +++ b/cps/templates/edit_book.html @@ -70,9 +70,7 @@ {% if c.datatype == 'rating' %} 0 %} - {% for column in book['custom_column_' ~ c.id] %} - value="{{ column.value }}{% if not loop.last %}, {% endif %} - {% endfor %}" + value="{{ book['custom_column_' ~ c.id][0].value / 2 }}" {% endif %}> {% endif %} diff --git a/cps/web.py b/cps/web.py index 27fb8713..9ac0441a 100755 --- a/cps/web.py +++ b/cps/web.py @@ -822,7 +822,8 @@ def edit_book(book_id): old_rating = False if len(book.ratings) > 0: old_rating = book.ratings[0].rating - ratingx2 = int(to_save["rating"]) *2 + ratingx2 = int(float(to_save["rating"]) *2) + print ratingx2 if ratingx2 != old_rating: is_rating = db.session.query(db.Ratings).filter(db.Ratings.rating == ratingx2).first() if is_rating: @@ -844,6 +845,9 @@ def edit_book(book_id): else: cc_db_value = None if to_save[cc_string].strip(): + if c.datatype == 'rating': + to_save[cc_string] = str(int(float(to_save[cc_string]) *2)) + print to_save[cc_string] if to_save[cc_string].strip() != cc_db_value: if cc_db_value != None: #remove old cc_val