Merge remote-tracking branch 'reading_state' into Develop
# Conflicts: # cps/kobo.py
This commit is contained in:
+14
-7
@@ -314,13 +314,19 @@ def toggle_read(book_id):
|
||||
book = ub.session.query(ub.ReadBook).filter(and_(ub.ReadBook.user_id == int(current_user.id),
|
||||
ub.ReadBook.book_id == book_id)).first()
|
||||
if book:
|
||||
book.is_read = not book.is_read
|
||||
if book.read_status == ub.ReadBook.STATUS_FINISHED:
|
||||
book.read_status = ub.ReadBook.STATUS_UNREAD
|
||||
else:
|
||||
book.read_status = ub.ReadBook.STATUS_FINISHED
|
||||
else:
|
||||
readBook = ub.ReadBook()
|
||||
readBook.user_id = int(current_user.id)
|
||||
readBook.book_id = book_id
|
||||
readBook.is_read = True
|
||||
readBook = ub.ReadBook(user_id=current_user.id, book_id = book_id)
|
||||
readBook.read_status = ub.ReadBook.STATUS_FINISHED
|
||||
book = readBook
|
||||
if not book.kobo_reading_state:
|
||||
kobo_reading_state = ub.KoboReadingState(user_id=current_user.id, book_id=book_id)
|
||||
kobo_reading_state.current_bookmark = ub.KoboBookmark()
|
||||
kobo_reading_state.statistics = ub.KoboStatistics()
|
||||
book.kobo_reading_state = kobo_reading_state
|
||||
ub.session.merge(book)
|
||||
ub.session.commit()
|
||||
else:
|
||||
@@ -980,7 +986,7 @@ def render_read_books(page, are_read, as_xml=False, order=None, *args, **kwargs)
|
||||
order = order or []
|
||||
if not config.config_read_column:
|
||||
readBooks = ub.session.query(ub.ReadBook).filter(ub.ReadBook.user_id == int(current_user.id))\
|
||||
.filter(ub.ReadBook.is_read == True).all()
|
||||
.filter(ub.ReadBook.read_status == ub.ReadBook.STATUS_FINISHED).all()
|
||||
readBookIds = [x.book_id for x in readBooks]
|
||||
else:
|
||||
try:
|
||||
@@ -1448,7 +1454,8 @@ def show_book(book_id):
|
||||
if not config.config_read_column:
|
||||
matching_have_read_book = ub.session.query(ub.ReadBook).\
|
||||
filter(and_(ub.ReadBook.user_id == int(current_user.id), ub.ReadBook.book_id == book_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].read_status == ub.ReadBook.STATUS_FINISHED
|
||||
else:
|
||||
try:
|
||||
matching_have_read_book = getattr(entries, 'custom_column_'+str(config.config_read_column))
|
||||
|
||||
Reference in New Issue
Block a user