Fix for read/unread for anonymous users

pull/121/head
Jack Darlington 8 years ago
parent fb6a37eec3
commit b6da3c3153

@ -107,6 +107,7 @@
</div> </div>
</p> </p>
{% endif %} {% endif %}
{% if not g.user.is_anonymous() %}
<p> <p>
<div class="custom_columns" id="have_read"> <div class="custom_columns" id="have_read">
Read Read
@ -119,6 +120,7 @@
</form> </form>
</div> </div>
</p> </p>
{% endif %}
{% if entry.comments|length > 0 and entry.comments[0].text|length > 0%} {% if entry.comments|length > 0 and entry.comments[0].text|length > 0%}

@ -1141,9 +1141,12 @@ def show_book(id):
#return render_title_template('detail.html', entry=entries, cc=cc, #return render_title_template('detail.html', entry=entries, cc=cc,
# title=entries.title, books_shelfs=book_in_shelfs) # title=entries.title, books_shelfs=book_in_shelfs)
if not current_user.is_anonymous():
matching_have_read_book=ub.session.query(ub.ReadBook).filter(ub.and_(ub.ReadBook.user_id == int(current_user.id), matching_have_read_book=ub.session.query(ub.ReadBook).filter(ub.and_(ub.ReadBook.user_id == int(current_user.id),
ub.ReadBook.book_id == id)).all() ub.ReadBook.book_id == id)).all()
have_read=len(matching_have_read_book) > 0 and matching_have_read_book[0].is_read have_read=len(matching_have_read_book) > 0 and matching_have_read_book[0].is_read
else:
have_read=None
return render_title_template('detail.html', entry=entries, cc=cc, return render_title_template('detail.html', entry=entries, cc=cc,
title=entries.title, books_shelfs=book_in_shelfs, have_read=have_read) title=entries.title, books_shelfs=book_in_shelfs, have_read=have_read)

Loading…
Cancel
Save