mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-27 20:11:14 +00:00
Curation view
This commit is contained in:
parent
a6c5341ad1
commit
13b38d40bb
6 changed files with 120 additions and 64 deletions
49
bookwyrm/templates/lists/curate.html
Normal file
49
bookwyrm/templates/lists/curate.html
Normal file
|
@ -0,0 +1,49 @@
|
|||
{% extends 'lists/list_layout.html' %}
|
||||
{% block panel %}
|
||||
|
||||
<section class="content block">
|
||||
<h2>Pending Books</h2>
|
||||
<p><a href="{% url 'list' list.id %}">Go to list</a></p>
|
||||
{% if not pending.exists %}
|
||||
<p>You're all set!</p>
|
||||
{% else %}
|
||||
<table class="table is-striped">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Book</th>
|
||||
<th>Suggested by</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
{% for item in pending %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=item.book size="small" %}</a>
|
||||
</td>
|
||||
<td>
|
||||
{% include 'snippets/book_titleby.html' with book=item.book %}
|
||||
</td>
|
||||
<td>
|
||||
{% include 'snippets/username.html' with user=item.added_by %}
|
||||
</td>
|
||||
<td>
|
||||
<div class="field has-addons">
|
||||
<form class="control" method="POST" action="{% url 'list-curate' list.id %}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="item" value="{{ item.id }}">
|
||||
<input type="hidden" name="approved" value="true">
|
||||
<button class="button">Approve</button>
|
||||
</form>
|
||||
<form class="control" method="POST" action="{% url 'list-curate' list.id %}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="item" value="{{ item.id }}">
|
||||
<input type="hidden" name="approved" value="false">
|
||||
<button class="button is-danger is-light">Discard</button>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endblock %}
|
|
@ -1,68 +1,12 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% extends 'lists/list_layout.html' %}
|
||||
{% load bookwyrm_tags %}
|
||||
{% block content %}
|
||||
{% block panel %}
|
||||
|
||||
<header class="columns content">
|
||||
<div class="column">
|
||||
<h1 class="title">{{ list.name }} <span class="subtitle">{% include 'snippets/privacy-icons.html' with item=list %}</span></h1>
|
||||
<p class="subtitle help">Created {% if list.curation != 'open' %} and curated{% endif %} by {% include 'snippets/username.html' with user=list.user %}</p>
|
||||
{% include 'snippets/trimmed_text.html' with full=list.description %}
|
||||
</div>
|
||||
{% if request.user == list.user %}
|
||||
<div class="column is-narrow">
|
||||
{% include 'snippets/toggle/open_button.html' with text="Edit list" icon="pencil" controls_text="create-list" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</header>
|
||||
|
||||
<form name="create-list" method="post" action="{% url 'list' list.id %}" class="box hidden" id="create-list">
|
||||
<h3 class="title">Edit list</h3>
|
||||
{% include 'lists/form.html' %}
|
||||
</form>
|
||||
|
||||
{% if pending.exists %}
|
||||
{% if request.user == list.user and pending_count %}
|
||||
<div class="block">
|
||||
<div>
|
||||
<p>{{ pending.count }} book{{pending.count | pluralize }} awaiting your approval</p>
|
||||
{% include 'snippets/toggle/open_button.html' with text="Curate suggestions" controls_text="pending-books" class="is-small" %}
|
||||
</div>
|
||||
<div class="box content hidden" id="pending-books">
|
||||
<header class="columns is-mobile">
|
||||
<h2 class="column">Pending Books</h2>
|
||||
<div class="column is-narrow">
|
||||
{% include 'snippets/toggle/toggle_button.html' with label="close" class="delete" nonbutton=True controls_text="pending-books" %}
|
||||
</div>
|
||||
</header>
|
||||
<table class="table is-striped">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Book</th>
|
||||
<th>Suggested by</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
{% for item in pending %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=item.book size="small" %}</a>
|
||||
</td>
|
||||
<td>
|
||||
{% include 'snippets/book_titleby.html' with book=item.book %}
|
||||
</td>
|
||||
<td>
|
||||
{% include 'snippets/username.html' with user=item.added_by %}
|
||||
</td>
|
||||
<td class="field has-addons">
|
||||
<div class="control">
|
||||
<button class="button">Approve</button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-danger is-light">Reject</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
<p>
|
||||
<a href="{% url 'list-curate' list.id %}">{{ pending_count }} book{{ pending_count | pluralize }} awaiting your approval</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
|
25
bookwyrm/templates/lists/list_layout.html
Normal file
25
bookwyrm/templates/lists/list_layout.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% load bookwyrm_tags %}
|
||||
{% block content %}
|
||||
|
||||
<header class="columns content">
|
||||
<div class="column">
|
||||
<h1 class="title">{{ list.name }} <span class="subtitle">{% include 'snippets/privacy-icons.html' with item=list %}</span></h1>
|
||||
<p class="subtitle help">Created {% if list.curation != 'open' %} and curated{% endif %} by {% include 'snippets/username.html' with user=list.user %}</p>
|
||||
{% include 'snippets/trimmed_text.html' with full=list.description %}
|
||||
</div>
|
||||
{% if request.user == list.user %}
|
||||
<div class="column is-narrow">
|
||||
{% include 'snippets/toggle/open_button.html' with text="Edit list" icon="pencil" controls_text="create-list" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</header>
|
||||
|
||||
<form name="create-list" method="post" action="{% url 'list' list.id %}" class="box hidden" id="create-list">
|
||||
<h3 class="title">Edit list</h3>
|
||||
{% include 'lists/form.html' %}
|
||||
</form>
|
||||
|
||||
{% block panel %}{% endblock %}
|
||||
|
||||
{% endblock %}
|
|
@ -92,6 +92,8 @@ urlpatterns = [
|
|||
views.List.as_view(), name='list'),
|
||||
re_path(r'^list/(?P<list_id>\d+)/add/?$',
|
||||
views.list.add_book, name='list-add-book'),
|
||||
re_path(r'^list/(?P<list_id>\d+)/curate/?$',
|
||||
views.Curate.as_view(), name='list-curate'),
|
||||
|
||||
# preferences
|
||||
re_path(r'^preferences/profile/?$', views.EditUser.as_view()),
|
||||
|
|
|
@ -14,7 +14,7 @@ from .import_data import Import, ImportStatus
|
|||
from .interaction import Favorite, Unfavorite, Boost, Unboost
|
||||
from .invite import ManageInvites, Invite
|
||||
from .landing import About, Home, Discover
|
||||
from .list import Lists, List
|
||||
from .list import Lists, List, Curate
|
||||
from .notifications import Notifications
|
||||
from .outbox import Outbox
|
||||
from .reading import edit_readthrough, create_readthrough, delete_readthrough
|
||||
|
|
|
@ -76,7 +76,8 @@ class List(View):
|
|||
'title': '%s | Lists' % book_list.name,
|
||||
'list': book_list,
|
||||
'items': book_list.listitem_set.filter(approved=True),
|
||||
'pending': book_list.listitem_set.filter(approved=False),
|
||||
'pending_count': book_list.listitem_set.filter(
|
||||
approved=False).count(),
|
||||
'suggested_books': suggestions,
|
||||
'list_form': forms.ListForm(instance=book_list),
|
||||
'query': query or ''
|
||||
|
@ -96,6 +97,41 @@ class List(View):
|
|||
return redirect(book_list.local_path)
|
||||
|
||||
|
||||
class Curate(View):
|
||||
''' approve or discard list suggestsions '''
|
||||
@method_decorator(login_required, name='dispatch')
|
||||
def get(self, request, list_id):
|
||||
''' display a pending list '''
|
||||
book_list = get_object_or_404(models.List, id=list_id)
|
||||
if not book_list.user == request.user:
|
||||
# only the creater can curate the list
|
||||
return HttpResponseNotFound()
|
||||
|
||||
data = {
|
||||
'title': 'Curate "%s" | Lists' % book_list.name,
|
||||
'list': book_list,
|
||||
'pending': book_list.listitem_set.filter(approved=False),
|
||||
'list_form': forms.ListForm(instance=book_list),
|
||||
}
|
||||
return TemplateResponse(request, 'lists/curate.html', data)
|
||||
|
||||
|
||||
@method_decorator(login_required, name='dispatch')
|
||||
# pylint: disable=unused-argument
|
||||
def post(self, request, list_id):
|
||||
''' edit a book_list '''
|
||||
book_list = get_object_or_404(models.List, id=list_id)
|
||||
suggestion = get_object_or_404(
|
||||
models.ListItem, id=request.POST.get('item'))
|
||||
approved = request.POST.get('approved') == 'true'
|
||||
if approved:
|
||||
suggestion.approved = True
|
||||
suggestion.save()
|
||||
else:
|
||||
suggestion.delete()
|
||||
return redirect('list-curate', book_list.id)
|
||||
|
||||
|
||||
@require_POST
|
||||
def add_book(request, list_id):
|
||||
''' put a book on a list '''
|
||||
|
|
Loading…
Reference in a new issue