mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-16 21:26:33 +00:00
Make requested changes.
Signed-off-by: Faiazov Dmitrii <jjsolutions0110@gmail.com>
This commit is contained in:
parent
ce16f36fe8
commit
1abbc67483
2 changed files with 15 additions and 9 deletions
|
@ -127,10 +127,12 @@
|
||||||
<th>{% trans "Cover"%}</th>
|
<th>{% trans "Cover"%}</th>
|
||||||
<th>{% trans "Title" as text %}{% include 'snippets/table-sort-header.html' with field="title" sort=sort text=text %}</th>
|
<th>{% trans "Title" as text %}{% include 'snippets/table-sort-header.html' with field="title" sort=sort text=text %}</th>
|
||||||
<th>{% trans "Author" as text %}{% include 'snippets/table-sort-header.html' with field="author" sort=sort text=text %}</th>
|
<th>{% trans "Author" as text %}{% include 'snippets/table-sort-header.html' with field="author" sort=sort text=text %}</th>
|
||||||
|
{% if request.user.is_authenticated %}
|
||||||
|
{% if is_self %}
|
||||||
<th>{% trans "Shelved" as text %}{% include 'snippets/table-sort-header.html' with field="shelved_date" sort=sort text=text %}</th>
|
<th>{% trans "Shelved" as text %}{% include 'snippets/table-sort-header.html' with field="shelved_date" sort=sort text=text %}</th>
|
||||||
<th>{% trans "Started" as text %}{% include 'snippets/table-sort-header.html' with field="start_date" sort=sort text=text %}</th>
|
<th>{% trans "Started" as text %}{% include 'snippets/table-sort-header.html' with field="start_date" sort=sort text=text %}</th>
|
||||||
<th>{% trans "Finished" as text %}{% include 'snippets/table-sort-header.html' with field="finish_date" sort=sort text=text %}</th>
|
<th>{% trans "Finished" as text %}{% include 'snippets/table-sort-header.html' with field="finish_date" sort=sort text=text %}</th>
|
||||||
{% if request.user.is_authenticated %}
|
{% endif %}
|
||||||
<th>{% trans "Rating" as text %}{% include 'snippets/table-sort-header.html' with field="rating" sort=sort text=text %}</th>
|
<th>{% trans "Rating" as text %}{% include 'snippets/table-sort-header.html' with field="rating" sort=sort text=text %}</th>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if shelf.user == request.user %}
|
{% if shelf.user == request.user %}
|
||||||
|
@ -151,6 +153,8 @@
|
||||||
<td data-title="{% trans "Author" %}">
|
<td data-title="{% trans "Author" %}">
|
||||||
{% include 'snippets/authors.html' %}
|
{% include 'snippets/authors.html' %}
|
||||||
</td>
|
</td>
|
||||||
|
{% if request.user.is_authenticated %}
|
||||||
|
{% if is_self %}
|
||||||
<td data-title="{% trans "Shelved" %}">
|
<td data-title="{% trans "Shelved" %}">
|
||||||
{{ book.shelved_date|naturalday }}
|
{{ book.shelved_date|naturalday }}
|
||||||
</td>
|
</td>
|
||||||
|
@ -160,7 +164,7 @@
|
||||||
<td data-title="{% trans "Finished" %}">
|
<td data-title="{% trans "Finished" %}">
|
||||||
{{ book.finish_date|naturalday|default_if_none:""}}
|
{{ book.finish_date|naturalday|default_if_none:""}}
|
||||||
</td>
|
</td>
|
||||||
{% if request.user.is_authenticated %}
|
{% endif %}
|
||||||
<td data-title="{% trans "Rating" %}">
|
<td data-title="{% trans "Rating" %}">
|
||||||
{% include 'snippets/stars.html' with rating=book.rating %}
|
{% include 'snippets/stars.html' with rating=book.rating %}
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -69,20 +69,22 @@ class Shelf(View):
|
||||||
).order_by("-published_date")
|
).order_by("-published_date")
|
||||||
|
|
||||||
reading = models.ReadThrough.objects
|
reading = models.ReadThrough.objects
|
||||||
if not is_self:
|
|
||||||
reading = models.ReadThrough.privacy_filter(request.user)
|
|
||||||
|
|
||||||
reading = reading.filter(user=user, book__id=OuterRef("id")).order_by(
|
reading = reading.filter(user=user, book__id=OuterRef("id")).order_by(
|
||||||
"-start_date"
|
"start_date"
|
||||||
)
|
)
|
||||||
|
|
||||||
books = books.annotate(
|
books = books.annotate(
|
||||||
rating=Subquery(reviews.values("rating")[:1]),
|
rating=Subquery(reviews.values("rating")[:1]),
|
||||||
shelved_date=F("shelfbook__shelved_date"),
|
shelved_date=F("shelfbook__shelved_date"),
|
||||||
start_date=Subquery(reading.values("start_date")),
|
start_date=Subquery(reading.values("start_date")[:1]),
|
||||||
finish_date=Subquery(reading.values("finish_date")),
|
finish_date=Subquery(reading.values("finish_date")[:1]),
|
||||||
author=F("authors__name"),
|
author=Subquery(
|
||||||
)
|
models.Book.objects.filter(id=OuterRef("id")).values("authors__name")[
|
||||||
|
:1
|
||||||
|
]
|
||||||
|
),
|
||||||
|
).prefetch_related("authors")
|
||||||
|
|
||||||
books = sort_books(books, request.GET.get("sort"))
|
books = sort_books(books, request.GET.get("sort"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue