mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-24 09:00:33 +00:00
Adds button to template
This commit is contained in:
parent
457415f874
commit
135fcbd269
4 changed files with 66 additions and 9 deletions
39
bookwyrm/templates/lists/bookmark_button.html
Normal file
39
bookwyrm/templates/lists/bookmark_button.html
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
{% load i18n %}
|
||||||
|
{% load interaction %}
|
||||||
|
|
||||||
|
{% if request.user.is_authenticated %}
|
||||||
|
|
||||||
|
{% with request.user|bookmarked:list as bookmarked %}
|
||||||
|
<form
|
||||||
|
name="bookmark-{{ list.id }}"
|
||||||
|
action="/"
|
||||||
|
method="POST"
|
||||||
|
class="interaction bookmark_{{ list.id }} {% if bookmarked %}is-hidden{% endif %}"
|
||||||
|
data-id="bookmark_{{ list.id }}"
|
||||||
|
>
|
||||||
|
{% csrf_token %}
|
||||||
|
{% trans "Bookmark" as text %}
|
||||||
|
<button class="button">
|
||||||
|
<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="/"
|
||||||
|
method="POST"
|
||||||
|
class="interaction active bookmark_{{ list.id }} {% if not bookmarked %}is-hidden{% endif %}"
|
||||||
|
data-id="bookmark_{{ list.id }}"
|
||||||
|
>
|
||||||
|
{% csrf_token %}
|
||||||
|
{% trans "Un-bookmark" as text %}
|
||||||
|
<button class="button">
|
||||||
|
<span class="icon icon-bookmark m-0-mobile has-text-primary" title="{{ text }}"></span>
|
||||||
|
<span class="is-sr-only-mobile">{{ text }}</span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
|
@ -11,12 +11,13 @@
|
||||||
{% include 'lists/created_text.html' with list=list %}
|
{% include 'lists/created_text.html' with list=list %}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{% if request.user == list.user %}
|
<div class="column is-narrow is-flex">
|
||||||
<div class="column is-narrow">
|
{% if request.user == list.user %}
|
||||||
{% trans "Edit List" as button_text %}
|
{% trans "Edit List" as button_text %}
|
||||||
{% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="pencil" controls_text="edit_list" focus="edit_list_header" %}
|
{% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="pencil" controls_text="edit_list" focus="edit_list_header" %}
|
||||||
|
{% endif %}
|
||||||
|
{% include "lists/bookmark_button.html" with list=list %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="block content">
|
<div class="block content">
|
||||||
|
|
|
@ -4,15 +4,27 @@
|
||||||
|
|
||||||
{% with status.id|uuid as uuid %}
|
{% with status.id|uuid as uuid %}
|
||||||
{% with request.user|liked:status as liked %}
|
{% with request.user|liked:status as liked %}
|
||||||
<form name="favorite" action="/favorite/{{ status.id }}" method="POST" class="interaction fav_{{ status.id }}_{{ uuid }} {% if liked %}is-hidden{% endif %}" data-id="fav_{{ status.id }}_{{ uuid }}">
|
<form
|
||||||
|
name="favorite"
|
||||||
|
action="/favorite/{{ status.id }}"
|
||||||
|
method="POST"
|
||||||
|
class="interaction fav_{{ status.id }}_{{ uuid }} {% if liked %}is-hidden{% endif %}"
|
||||||
|
data-id="fav_{{ status.id }}_{{ uuid }}"
|
||||||
|
>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button class="button is-small is-light is-transparent" type="submit">
|
<button class="button is-small is-light is-transparent" type="submit">
|
||||||
<span class="icon icon-heart m-0-mobile" title="{% trans 'Like' %}">
|
<span class="icon icon-heart m-0-mobile" title="{% trans 'Like' %}"></span>
|
||||||
</span>
|
|
||||||
<span class="is-sr-only-mobile">{% trans "Like" %}</span>
|
<span class="is-sr-only-mobile">{% trans "Like" %}</span>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<form name="unfavorite" action="/unfavorite/{{ status.id }}" method="POST" class="interaction fav_{{ status.id }}_{{ uuid }} active {% if not liked %}is-hidden{% endif %}" data-id="fav_{{ status.id }}_{{ uuid }}">
|
|
||||||
|
<form
|
||||||
|
name="unfavorite"
|
||||||
|
action="/unfavorite/{{ status.id }}"
|
||||||
|
method="POST"
|
||||||
|
class="interaction fav_{{ status.id }}_{{ uuid }} active {% if not liked %}is-hidden{% endif %}"
|
||||||
|
data-id="fav_{{ status.id }}_{{ uuid }}"
|
||||||
|
>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button class="button is-light is-transparent is-small" type="submit">
|
<button class="button is-light is-transparent is-small" type="submit">
|
||||||
<span class="icon icon-heart has-text-primary m-0-mobile" title="{% trans 'Un-like' %}"></span>
|
<span class="icon icon-heart has-text-primary m-0-mobile" title="{% trans 'Un-like' %}"></span>
|
||||||
|
|
|
@ -16,3 +16,8 @@ def get_user_liked(user, status):
|
||||||
def get_user_boosted(user, status):
|
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")
|
||||||
|
def get_user_bookmarked(user, book_list):
|
||||||
|
"""did the user bookmark a list"""
|
||||||
|
return user.saved_lists.filter(id=book_list.id).exists()
|
||||||
|
|
Loading…
Reference in a new issue