issue Add books you're a contributor to `My library` also #101

This commit is contained in:
Kostiantyn Stoliarskyi 2023-06-01 09:28:37 +03:00
parent 6dd7e67709
commit 2da8cb0728
2 changed files with 26 additions and 20 deletions

View File

@ -33,7 +33,6 @@
<dl class="bg-white dark:bg-gray-900 max-w-full p-3 text-gray-900 divide-y divide-gray-200 dark:text-white dark:divide-gray-700 m-3 border-2 border-gray-200 border-solid rounded-lg dark:border-gray-700"> <dl class="bg-white dark:bg-gray-900 max-w-full p-3 text-gray-900 divide-y divide-gray-200 dark:text-white dark:divide-gray-700 m-3 border-2 border-gray-200 border-solid rounded-lg dark:border-gray-700">
<div class="flex flex-row pb-3 p-3"> <div class="flex flex-row pb-3 p-3">
<div class="vote-block flex flex-col m-5 justify-center items-center"> <div class="vote-block flex flex-col m-5 justify-center items-center">
{% if interpretation.user_id != current_user.id %}
<div class="vote-button cursor-pointer" data-vote-for="interpretation" data-entity-id="{{ interpretation.id }}" data-positive="true"> <div class="vote-button cursor-pointer" data-vote-for="interpretation" data-entity-id="{{ interpretation.id }}" data-positive="true">
<svg class="w-6 h-6 select-none <svg class="w-6 h-6 select-none
{% if interpretation.current_user_vote %} {% if interpretation.current_user_vote %}
@ -41,7 +40,7 @@
{% endif %} {% endif %}
" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" > <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 10.5L12 3m0 0l7.5 7.5M12 3v18" /> </svg> " xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" > <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 10.5L12 3m0 0l7.5 7.5M12 3v18" /> </svg>
</div> </div>
{% endif %}
<span <span
class="vote-count text-3xl select-none class="vote-count text-3xl select-none
@ -55,7 +54,7 @@
{{ interpretation.vote_count }} {{ interpretation.vote_count }}
</span> </span>
{% if interpretation.user_id != current_user.id %}
<div class="vote-button cursor-pointer" data-vote-for="interpretation" data-entity-id="{{ interpretation.id }}" data-positive="false"> <div class="vote-button cursor-pointer" data-vote-for="interpretation" data-entity-id="{{ interpretation.id }}" data-positive="false">
<svg class="w-6 h-6 select-none <svg class="w-6 h-6 select-none
{% if interpretation.current_user_vote == False %} {% if interpretation.current_user_vote == False %}
@ -63,7 +62,6 @@
{% endif %} {% endif %}
" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 13.5L12 21m0 0l-7.5-7.5M12 21V3" /> </svg> " xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 13.5L12 21m0 0l-7.5-7.5M12 21V3" /> </svg>
</div> </div>
{% endif %}
</div> </div>
<!-- prettier-ignore --> <!-- prettier-ignore -->
<dt class="flex w-full mb-1 text-gray-500 md:text-lg dark:text-gray-400 flex-col"> <dt class="flex w-full mb-1 text-gray-500 md:text-lg dark:text-gray-400 flex-col">

View File

@ -46,8 +46,16 @@ def my_library():
if current_user.is_authenticated: if current_user.is_authenticated:
log(log.INFO, "Create query for my_library page for books") log(log.INFO, "Create query for my_library page for books")
books: m.Book = m.Book.query.order_by(m.Book.id) books: m.Book = (
books = books.filter_by(user_id=current_user.id, is_deleted=False) db.session.query(m.Book)
.join(m.BookContributor, m.BookContributor.book_id == m.Book.id, full=True)
.filter(
m.Book.user_id == current_user.id,
m.Book.is_deleted == False, # noqa: E712
)
.group_by(m.Book.id)
)
log(log.INFO, "Create pagination for books") log(log.INFO, "Create pagination for books")
pagination = create_pagination(total=books.count()) pagination = create_pagination(total=books.count())