let's call it save not bookmark

This commit is contained in:
Mouse Reeve 2021-08-23 15:07:38 -07:00
parent b7fb55e6ad
commit f267e53b56
6 changed files with 31 additions and 35 deletions

View file

@ -3,32 +3,32 @@
{% if request.user.is_authenticated %}
{% with request.user|bookmarked:list as bookmarked %}
{% with request.user|saved:list as saved %}
<form
name="bookmark-{{ list.id }}"
action="{% url 'list-bookmark' list.id %}"
name="save-{{ list.id }}"
action="{% url 'list-save' list.id %}"
method="POST"
class="interaction bookmark_{{ list.id }} {% if bookmarked %}is-hidden{% endif %}"
data-id="bookmark_{{ list.id }}"
class="interaction save_{{ list.id }} {% if saved %}is-hidden{% endif %}"
data-id="save_{{ list.id }}"
>
{% csrf_token %}
{% trans "Bookmark" as text %}
<button class="button">
{% trans "Save" as text %}
<button class="button" type="submit">
<span class="icon icon-bookmark m-0-mobile" title="{{ text }}"></span>
<span class="is-sr-only-mobile">{{ text }}</span>
</button>
</form>
<form
name="bookmark-{{ list.id }}"
action="{% url 'list-unbookmark' list.id %}"
name="unsave-{{ list.id }}"
action="{% url 'list-unsave' list.id %}"
method="POST"
class="interaction active bookmark_{{ list.id }} {% if not bookmarked %}is-hidden{% endif %}"
data-id="bookmark_{{ list.id }}"
class="interaction save_{{ list.id }} active {% if not saved %}is-hidden{% endif %}"
data-id="save_{{ list.id }}"
>
{% csrf_token %}
{% trans "Un-bookmark" as text %}
<button class="button">
{% trans "Un-save" as text %}
<button class="button" type="submit">
<span class="icon icon-bookmark m-0-mobile has-text-primary" title="{{ text }}"></span>
<span class="is-sr-only-mobile">{{ text }}</span>
</button>

View file

@ -31,12 +31,12 @@
<nav class="tabs">
<ul>
{% url 'lists' as url %}
<li{% if url in request.path %} class="is-active"{% endif %}>
<li{% if request.path in url %} class="is-active"{% endif %}>
<a href="{{ url }}">{% trans "All Lists" %}</a>
</li>
{% url 'bookmarked-lists' as url %}
{% url 'saved-lists' as url %}
<li{% if url in request.path %} class="is-active"{% endif %}>
<a href="{{ url }}">{% trans "Bookmarked Lists" %}</a>
<a href="{{ url }}">{% trans "Saved Lists" %}</a>
</li>
</ul>
</nav>

View file

@ -18,7 +18,7 @@ def get_user_boosted(user, status):
return status.boosters.filter(user=user).exists()
@register.filter(name="bookmarked")
def get_user_bookmarked(user, book_list):
"""did the user bookmark a list"""
@register.filter(name="saved")
def get_user_saved_lists(user, book_list):
"""did the user save a list"""
return user.saved_lists.filter(id=book_list.id).exists()

View file

@ -218,9 +218,7 @@ urlpatterns = [
# lists
re_path(r"%s/lists/?$" % USER_PATH, views.UserLists.as_view(), name="user-lists"),
re_path(r"^list/?$", views.Lists.as_view(), name="lists"),
re_path(
r"^list/bookmarks/?$", views.BookmarkedLists.as_view(), name="bookmarked-lists"
),
re_path(r"^list/saved/?$", views.SavedLists.as_view(), name="saved-lists"),
re_path(r"^list/(?P<list_id>\d+)(.json)?/?$", views.List.as_view(), name="list"),
re_path(r"^list/add-book/?$", views.list.add_book, name="list-add-book"),
re_path(
@ -236,10 +234,8 @@ urlpatterns = [
re_path(
r"^list/(?P<list_id>\d+)/curate/?$", views.Curate.as_view(), name="list-curate"
),
re_path(r"bookmark/(?P<list_id>\d+)/?$", views.bookmark, name="list-bookmark"),
re_path(
r"^unbookmark/(?P<list_id>\d+)/?$", views.unbookmark, name="list-unbookmark"
),
re_path(r"^save-list/(?P<list_id>\d+)/?$", views.saveList, name="list-save"),
re_path(r"^unsave-list/(?P<list_id>\d+)/?$", views.unsaveList, name="list-unsave"),
# User books
re_path(r"%s/books/?$" % USER_PATH, views.Shelf.as_view(), name="user-shelves"),
re_path(

View file

@ -25,8 +25,8 @@ from .invite import ManageInvites, Invite, InviteRequest
from .invite import ManageInviteRequests, ignore_invite_request
from .isbn import Isbn
from .landing import About, Home, Landing
from .list import Lists, BookmarkedLists, List, Curate, UserLists
from .list import bookmark, unbookmark
from .list import Lists, SavedLists, List, Curate, UserLists
from .list import saveList, unsaveList
from .notifications import Notifications
from .outbox import Outbox
from .reading import edit_readthrough, create_readthrough

View file

@ -64,8 +64,8 @@ class Lists(View):
@method_decorator(login_required, name="dispatch")
class BookmarkedLists(View):
"""bookmarked book list page"""
class SavedLists(View):
"""saved book list page"""
def get(self, request):
"""display book lists"""
@ -244,18 +244,18 @@ class Curate(View):
@require_POST
@login_required
def bookmark(request, list_id):
"""bookmark a list"""
book_list = models.List.objects.get(id=list_id)
def saveList(request, list_id):
"""save a list"""
book_list = get_object_or_404(models.List, id=list_id)
request.user.saved_lists.add(book_list)
return redirect("list", list_id)
@require_POST
@login_required
def unbookmark(request, list_id):
def unsaveList(request, list_id):
"""unsave a list"""
book_list = models.List.objects.get(id=list_id)
book_list = get_object_or_404(models.List, id=list_id)
request.user.saved_lists.remove(book_list)
return redirect("list", list_id)