mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-18 22:26:34 +00:00
Adds action views
This commit is contained in:
parent
135fcbd269
commit
42abc145c8
6 changed files with 35 additions and 6 deletions
|
@ -6,7 +6,7 @@
|
||||||
{% with request.user|bookmarked:list as bookmarked %}
|
{% with request.user|bookmarked:list as bookmarked %}
|
||||||
<form
|
<form
|
||||||
name="bookmark-{{ list.id }}"
|
name="bookmark-{{ list.id }}"
|
||||||
action="/"
|
action="{% url 'list-bookmark' list.id %}"
|
||||||
method="POST"
|
method="POST"
|
||||||
class="interaction bookmark_{{ list.id }} {% if bookmarked %}is-hidden{% endif %}"
|
class="interaction bookmark_{{ list.id }} {% if bookmarked %}is-hidden{% endif %}"
|
||||||
data-id="bookmark_{{ list.id }}"
|
data-id="bookmark_{{ list.id }}"
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
<form
|
<form
|
||||||
name="bookmark-{{ list.id }}"
|
name="bookmark-{{ list.id }}"
|
||||||
action="/"
|
action="{% url 'list-unbookmark' list.id %}"
|
||||||
method="POST"
|
method="POST"
|
||||||
class="interaction active bookmark_{{ list.id }} {% if not bookmarked %}is-hidden{% endif %}"
|
class="interaction active bookmark_{{ list.id }} {% if not bookmarked %}is-hidden{% endif %}"
|
||||||
data-id="bookmark_{{ list.id }}"
|
data-id="bookmark_{{ list.id }}"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{% with request.user|liked:status as liked %}
|
{% with request.user|liked:status as liked %}
|
||||||
<form
|
<form
|
||||||
name="favorite"
|
name="favorite"
|
||||||
action="/favorite/{{ status.id }}"
|
action="{% url 'fav' status.id %}"
|
||||||
method="POST"
|
method="POST"
|
||||||
class="interaction fav_{{ status.id }}_{{ uuid }} {% if liked %}is-hidden{% endif %}"
|
class="interaction fav_{{ status.id }}_{{ uuid }} {% if liked %}is-hidden{% endif %}"
|
||||||
data-id="fav_{{ status.id }}_{{ uuid }}"
|
data-id="fav_{{ status.id }}_{{ uuid }}"
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
<form
|
<form
|
||||||
name="unfavorite"
|
name="unfavorite"
|
||||||
action="/unfavorite/{{ status.id }}"
|
action="{% url 'unfav' status.id %}"
|
||||||
method="POST"
|
method="POST"
|
||||||
class="interaction fav_{{ status.id }}_{{ uuid }} active {% if not liked %}is-hidden{% endif %}"
|
class="interaction fav_{{ status.id }}_{{ uuid }} active {% if not liked %}is-hidden{% endif %}"
|
||||||
data-id="fav_{{ status.id }}_{{ uuid }}"
|
data-id="fav_{{ status.id }}_{{ uuid }}"
|
||||||
|
|
|
@ -17,6 +17,7 @@ def get_user_boosted(user, status):
|
||||||
"""did the given user fav a status?"""
|
"""did the given user fav a status?"""
|
||||||
return status.boosters.filter(user=user).exists()
|
return status.boosters.filter(user=user).exists()
|
||||||
|
|
||||||
|
|
||||||
@register.filter(name="bookmarked")
|
@register.filter(name="bookmarked")
|
||||||
def get_user_bookmarked(user, book_list):
|
def get_user_bookmarked(user, book_list):
|
||||||
"""did the user bookmark a list"""
|
"""did the user bookmark a list"""
|
||||||
|
|
|
@ -233,6 +233,10 @@ urlpatterns = [
|
||||||
re_path(
|
re_path(
|
||||||
r"^list/(?P<list_id>\d+)/curate/?$", views.Curate.as_view(), name="list-curate"
|
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"
|
||||||
|
),
|
||||||
# User books
|
# User books
|
||||||
re_path(r"%s/books/?$" % USER_PATH, views.Shelf.as_view(), name="user-shelves"),
|
re_path(r"%s/books/?$" % USER_PATH, views.Shelf.as_view(), name="user-shelves"),
|
||||||
re_path(
|
re_path(
|
||||||
|
@ -294,8 +298,10 @@ urlpatterns = [
|
||||||
name="redraft",
|
name="redraft",
|
||||||
),
|
),
|
||||||
# interact
|
# interact
|
||||||
re_path(r"^favorite/(?P<status_id>\d+)/?$", views.Favorite.as_view()),
|
re_path(r"^favorite/(?P<status_id>\d+)/?$", views.Favorite.as_view(), name="fav"),
|
||||||
re_path(r"^unfavorite/(?P<status_id>\d+)/?$", views.Unfavorite.as_view()),
|
re_path(
|
||||||
|
r"^unfavorite/(?P<status_id>\d+)/?$", views.Unfavorite.as_view(), name="unfav"
|
||||||
|
),
|
||||||
re_path(r"^boost/(?P<status_id>\d+)/?$", views.Boost.as_view()),
|
re_path(r"^boost/(?P<status_id>\d+)/?$", views.Boost.as_view()),
|
||||||
re_path(r"^unboost/(?P<status_id>\d+)/?$", views.Unboost.as_view()),
|
re_path(r"^unboost/(?P<status_id>\d+)/?$", views.Unboost.as_view()),
|
||||||
# books
|
# books
|
||||||
|
|
|
@ -26,6 +26,7 @@ from .invite import ManageInviteRequests, ignore_invite_request
|
||||||
from .isbn import Isbn
|
from .isbn import Isbn
|
||||||
from .landing import About, Home, Landing
|
from .landing import About, Home, Landing
|
||||||
from .list import Lists, List, Curate, UserLists
|
from .list import Lists, List, Curate, UserLists
|
||||||
|
from .list import bookmark, unbookmark
|
||||||
from .notifications import Notifications
|
from .notifications import Notifications
|
||||||
from .outbox import Outbox
|
from .outbox import Outbox
|
||||||
from .reading import edit_readthrough, create_readthrough
|
from .reading import edit_readthrough, create_readthrough
|
||||||
|
|
|
@ -224,6 +224,25 @@ class Curate(View):
|
||||||
|
|
||||||
|
|
||||||
@require_POST
|
@require_POST
|
||||||
|
@login_required
|
||||||
|
def bookmark(request, list_id):
|
||||||
|
"""bookmark a list"""
|
||||||
|
book_list = models.List.objects.get(id=list_id)
|
||||||
|
request.user.saved_lists.add(book_list)
|
||||||
|
return redirect("list", list_id)
|
||||||
|
|
||||||
|
|
||||||
|
@require_POST
|
||||||
|
@login_required
|
||||||
|
def unbookmark(request, list_id):
|
||||||
|
"""unsave a list"""
|
||||||
|
book_list = models.List.objects.get(id=list_id)
|
||||||
|
request.user.saved_lists.remove(book_list)
|
||||||
|
return redirect("list", list_id)
|
||||||
|
|
||||||
|
|
||||||
|
@require_POST
|
||||||
|
@login_required
|
||||||
def add_book(request):
|
def add_book(request):
|
||||||
"""put a book on a list"""
|
"""put a book on a list"""
|
||||||
book_list = get_object_or_404(models.List, id=request.POST.get("list"))
|
book_list = get_object_or_404(models.List, id=request.POST.get("list"))
|
||||||
|
@ -273,6 +292,7 @@ def add_book(request):
|
||||||
|
|
||||||
|
|
||||||
@require_POST
|
@require_POST
|
||||||
|
@login_required
|
||||||
def remove_book(request, list_id):
|
def remove_book(request, list_id):
|
||||||
"""remove a book from a list"""
|
"""remove a book from a list"""
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
|
@ -289,6 +309,7 @@ def remove_book(request, list_id):
|
||||||
|
|
||||||
|
|
||||||
@require_POST
|
@require_POST
|
||||||
|
@login_required
|
||||||
def set_book_position(request, list_item_id):
|
def set_book_position(request, list_item_id):
|
||||||
"""
|
"""
|
||||||
Action for when the list user manually specifies a list position, takes
|
Action for when the list user manually specifies a list position, takes
|
||||||
|
|
Loading…
Reference in a new issue