mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-12 11:16:33 +00:00
Merge branch 'main' into production
This commit is contained in:
commit
b20de604d3
7 changed files with 46 additions and 17 deletions
|
@ -49,7 +49,7 @@ class ShelfBook(BookWyrmModel):
|
|||
return activitypub.Add(
|
||||
id='%s#add' % self.remote_id,
|
||||
actor=user.remote_id,
|
||||
object=self.book.local_id,
|
||||
object=self.book.to_activity(),
|
||||
target=self.shelf.remote_id,
|
||||
).serialize()
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class Tag(OrderedCollectionMixin, BookWyrmModel):
|
|||
return activitypub.Add(
|
||||
id='%s#add' % self.remote_id,
|
||||
actor=user.remote_id,
|
||||
object=self.book.local_id,
|
||||
object=self.book.to_activity(),
|
||||
target=self.remote_id,
|
||||
).serialize()
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
{% if shelf.books %}
|
||||
{% with shelf_counter=forloop.counter %}
|
||||
<li>
|
||||
<p>{{ shelf.name }}</p>
|
||||
<p>
|
||||
{{ shelf.name }}
|
||||
</p>
|
||||
<div class="tabs is-small is-toggle">
|
||||
<ul>
|
||||
{% for book in shelf.books %}
|
||||
|
|
|
@ -67,16 +67,7 @@
|
|||
</td>
|
||||
{% endif %}
|
||||
<td>
|
||||
<form name="unshelve" action="/unshelve/" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
<input type="hidden" name="shelf" value="{{ shelf.id }}">
|
||||
<button class="button is-danger is-small" type="submit" style="">
|
||||
<span class="icon icon-x">
|
||||
<span class="is-sr-only">Remove from shelf</span>
|
||||
</span>
|
||||
</button>
|
||||
</form>
|
||||
{% include 'snippets/shelf_selector.html' with current=shelf %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
31
bookwyrm/templates/snippets/shelf_selector.html
Normal file
31
bookwyrm/templates/snippets/shelf_selector.html
Normal file
|
@ -0,0 +1,31 @@
|
|||
<div class="dropdown is-hoverable">
|
||||
<div class="dropdown-trigger button">
|
||||
<p>Change shelf</p>
|
||||
<span class="icon icon-arrow-down"></span>
|
||||
</div>
|
||||
<div class="dropdown-menu">
|
||||
<ul class="dropdown-content">
|
||||
{% for shelf in request.user.shelf_set.all %}
|
||||
{% if shelf.identifier != current.identifier %}
|
||||
<li>
|
||||
<form class="dropdown-item pt-0 pb-0" name="shelve" action="/shelve/" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
<input type="hidden" name="shelf" value="{{ shelf.identifier }}">
|
||||
<button class="button is-small" type="submit">{{ shelf.name }}</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<hr class="navbar-divider">
|
||||
<li>
|
||||
<form class="dropdown-item pt-0 pb-0" name="shelve" action="/unshelve/" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
<input type="hidden" name="shelf" value="{{ current.id }}">
|
||||
<button class="button is-small is-danger" type="submit">Unshelve</button>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
|
@ -87,10 +87,13 @@ def home_tab(request, tab):
|
|||
def get_suggested_books(user, max_books=5):
|
||||
''' helper to get a user's recent books '''
|
||||
book_count = 0
|
||||
preset_shelves = ['reading', 'read', 'to-read']
|
||||
preset_shelves = [
|
||||
('reading', max_books), ('read', 2), ('to-read', max_books)
|
||||
]
|
||||
suggested_books = []
|
||||
for preset in preset_shelves:
|
||||
limit = max_books - book_count
|
||||
for (preset, shelf_max) in preset_shelves:
|
||||
limit = shelf_max if shelf_max < (max_books - book_count) \
|
||||
else max_books - book_count
|
||||
shelf = user.shelf_set.get(identifier=preset)
|
||||
|
||||
shelf_books = shelf.shelfbook_set.order_by(
|
||||
|
|
|
@ -58,15 +58,17 @@ def nodeinfo(request):
|
|||
return HttpResponseNotFound()
|
||||
|
||||
status_count = models.Status.objects.filter(user__local=True).count()
|
||||
user_count = models.User.objects.count()
|
||||
user_count = models.User.objects.filter(local=True).count()
|
||||
|
||||
month_ago = datetime.now() - relativedelta(months=1)
|
||||
last_month_count = models.User.objects.filter(
|
||||
local=True,
|
||||
last_active_date__gt=month_ago
|
||||
).count()
|
||||
|
||||
six_months_ago = datetime.now() - relativedelta(months=6)
|
||||
six_month_count = models.User.objects.filter(
|
||||
local=True,
|
||||
last_active_date__gt=six_months_ago
|
||||
).count()
|
||||
return JsonResponse({
|
||||
|
|
Loading…
Reference in a new issue