forked from mirrors/bookwyrm
Fixes model test
This commit is contained in:
parent
d73a1b4ec1
commit
4883231347
7 changed files with 58 additions and 11 deletions
|
@ -1,2 +1,2 @@
|
|||
<h4><a href="{{ list.local_path }}">{{ list.name }}</a> {% include 'snippets/privacy-icons.html' with item=list %}</h4>
|
||||
<h4><a href="{{ list.local_path }}">{{ list.name }}</a> <span class="subtitle">{% include 'snippets/privacy-icons.html' with item=list %}</span></h4>
|
||||
{% include 'snippets/trimmed_text.html' with full=list.description %}
|
||||
|
|
|
@ -1,7 +1,44 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% block content %}
|
||||
<h1>{{ list.name }}</h1>
|
||||
|
||||
{{ list }}
|
||||
<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>
|
||||
{% include 'snippets/trimmed_text.html' with full=list.description %}
|
||||
</div>
|
||||
<div class="column is-narrow">
|
||||
{% include 'snippets/toggle/open_button.html' with text="Edit list" icon="pencil" controls_text="edit-list" %}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="columns content">
|
||||
<section class="column">
|
||||
<h2>Books</h2>
|
||||
{% if not list.books.exists %}
|
||||
<p>This list is currently empty</p>
|
||||
{% else %}
|
||||
{% for book in list.books.all %}
|
||||
{{ book }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<section class="column is-one-quarter">
|
||||
<h2>Add Books</h2>
|
||||
{% for book in suggested_books %}
|
||||
<div class="block columns">
|
||||
<div class="column is-narrow">
|
||||
<a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=book size="small" %}</a>
|
||||
</div>
|
||||
<div class="column">
|
||||
<p>{% include 'snippets/book_titleby.html' with book=book %}</p>
|
||||
<form name="add-book" method="post" action="{% url 'list-add-book' list.id %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="button is-small is-link">Add</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</section>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
{% if request.user.list_set.exists %}
|
||||
<ul>
|
||||
{% for list in request.user.list_set.all %}
|
||||
<li>
|
||||
<li class="block">
|
||||
{% include 'lists/list-item.html' with list=list %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
@ -81,7 +81,7 @@
|
|||
<h2 class="title">Recent Lists</h2>
|
||||
<ul>
|
||||
{% for list in lists %}
|
||||
<li>
|
||||
<li class="block">
|
||||
{% include 'lists/list-item.html' with list=list %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div class="columns">
|
||||
<div class="column is-narrow">
|
||||
<div>
|
||||
<a href="/book/{{ book.id }}">{% include 'snippets/book_cover.html' with book=book %}</a>
|
||||
<a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=book %}</a>
|
||||
{% include 'snippets/shelve_button.html' with book=book %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -16,7 +16,7 @@ class List(TestCase):
|
|||
|
||||
def test_remote_id(self):
|
||||
''' shelves use custom remote ids '''
|
||||
expected_id = 'https://%s/user/mouse/list/%d' % \
|
||||
expected_id = 'https://%s/list/%d' % \
|
||||
(settings.DOMAIN, self.list.id)
|
||||
self.assertEqual(self.list.get_remote_id(), expected_id)
|
||||
|
||||
|
|
|
@ -88,7 +88,10 @@ urlpatterns = [
|
|||
|
||||
# lists
|
||||
re_path(r'^list/?$', views.Lists.as_view(), name='lists'),
|
||||
re_path(r'^list/(?P<list_id>\d+)(.json)?/?$', views.List.as_view(), name='list'),
|
||||
re_path(r'^list/(?P<list_id>\d+)(.json)?/?$',
|
||||
views.List.as_view(), name='list'),
|
||||
re_path(r'^list/(?P<list_id>\d+)/add/?$',
|
||||
views.List.as_view(), name='list-add-book'),
|
||||
|
||||
# preferences
|
||||
re_path(r'^preferences/profile/?$', views.EditUser.as_view()),
|
||||
|
|
|
@ -51,8 +51,15 @@ class List(View):
|
|||
|
||||
if is_api_request(request):
|
||||
return ActivitypubResponse(book_list.to_activity())
|
||||
|
||||
suggestions = request.user.shelfbook_set.all().filter(
|
||||
~Q(book__in=book_list.books)
|
||||
)
|
||||
|
||||
data = {
|
||||
'list': book_list
|
||||
'title': '%s | Lists' % book_list.name,
|
||||
'list': book_list,
|
||||
'suggested_books': [s.book for s in suggestions[:5]],
|
||||
}
|
||||
return TemplateResponse(request, 'lists/list.html', data)
|
||||
|
||||
|
@ -60,6 +67,6 @@ class List(View):
|
|||
@method_decorator(login_required, name='dispatch')
|
||||
# pylint: disable=unused-argument
|
||||
def post(self, request, list_id):
|
||||
''' create a book_list '''
|
||||
''' edit a book_list '''
|
||||
book_list = get_object_or_404(models.List, id=list_id)
|
||||
return redirect(book_list.local_path)
|
||||
|
|
Loading…
Reference in a new issue