Merge pull request #832 from mouse-reeve/shelves-naming

Moves away from "shelves" metaphor
This commit is contained in:
Mouse Reeve 2021-03-31 10:35:09 -07:00 committed by GitHub
commit 2d37d70606
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 2343 additions and 1485 deletions

View file

@ -49,7 +49,7 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel):
def get_remote_id(self):
""" shelf identifier instead of id """
base_path = self.user.remote_id
return "%s/shelf/%s" % (base_path, self.identifier)
return "%s/books/%s" % (base_path, self.identifier)
class Meta:
""" user/shelf unqiueness """

View file

@ -55,7 +55,7 @@
<div class="navbar-start">
{% if request.user.is_authenticated %}
<a href="{% url 'user-shelves' request.user.localname %}" class="navbar-item">
{% trans "Your shelves" %}
{% trans "Your books" %}
</a>
<a href="/#feed" class="navbar-item">
{% trans "Feed" %}

View file

@ -1,7 +1,7 @@
{% extends 'components/dropdown.html' %}
{% load i18n %}
{% block dropdown-trigger %}
<span>{% trans "Change shelf" %}</span>
<span>{% trans "Move book" %}</span>
<span class="icon icon-arrow-down" aria-hidden="true"></span>
{% endblock %}
@ -25,7 +25,7 @@
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="shelf" value="{{ current.id }}">
<button class="button is-fullwidth is-small is-danger is-light" type="submit">{% trans "Unshelve" %}</button>
<button class="button is-fullwidth is-small is-danger is-light" type="submit">{% trans "Remove" %}</button>
</form>
</li>
{% endblock %}

View file

@ -45,7 +45,7 @@
{% csrf_token %}
<input type="hidden" name="book" value="{{ active_shelf.book.id }}">
<input type="hidden" name="shelf" value="{{ active_shelf.shelf.id }}">
<button class="button is-fullwidth is-small is-danger is-light" type="submit">{% trans "Unshelve" %}</button>
<button class="button is-fullwidth is-small is-danger is-light" type="submit">{% blocktrans with name=active_shelf.shelf.name %}Remove from {{ name }}{% endblocktrans %}</button>
</form>
</div>
</li>

View file

@ -0,0 +1,6 @@
{% load i18n %}
{% if is_self %}
{% trans "Your books" %}
{% else %}
{% blocktrans with username=user.display_name %}{{ username }}'s books{% endblocktrans %}
{% endif %}

View file

@ -3,14 +3,14 @@
{% load humanize %}
{% load i18n %}
{% block title %}
{% include 'user/books_header.html' %}
{% endblock %}
{% block header %}
<header class="columns">
<h1 class="title">
{% if is_self %}
{% trans "Your Shelves" %}
{% else %}
{% blocktrans with username=user.display_name %}{{ username }}: Shelves{% endblocktrans %}
{% endif %}
{% include 'user/books_header.html' %}
</h1>
</header>
{% endblock %}
@ -22,7 +22,7 @@
<ul>
{% for shelf_tab in shelves %}
<li class="{% if shelf_tab.identifier == shelf.identifier %}is-active{% endif %}">
<a href="/user/{{ user | username }}/shelf/{{ shelf_tab.identifier }}"{% if shelf_tab.identifier == shelf.identifier %} aria-current="page"{% endif %}>{% if shelf_tab.identifier == 'to-read' %}{% trans "To Read" %}{% elif shelf_tab.identifier == 'reading' %}{% trans "Currently Reading" %}{% elif shelf_tab.identifier == 'read' %}{% trans "Read" %}{% else %}{{ shelf_tab.name }}{% endif %}</a>
<a href="{{ shelf_tab.local_path }}"{% if shelf_tab.identifier == shelf.identifier %} aria-current="page"{% endif %}>{% if shelf_tab.identifier == 'to-read' %}{% trans "To Read" %}{% elif shelf_tab.identifier == 'reading' %}{% trans "Currently Reading" %}{% elif shelf_tab.identifier == 'read' %}{% trans "Read" %}{% else %}{{ shelf_tab.name }}{% endif %}</a>
</li>
{% endfor %}
</ul>

View file

@ -1,5 +1,6 @@
{% extends 'user/user_layout.html' %}
{% load i18n %}
{% load bookwyrm_tags %}
{% block title %}{{ user.display_name }}{% endblock %}
@ -23,12 +24,14 @@
{% block panel %}
{% if user.bookwyrm_user %}
<div class="block">
<h2 class="title">{% trans "Shelves" %}</h2>
<h2 class="title">
{% include 'user/books_header.html' %}
</h2>
<div class="columns">
{% for shelf in shelves %}
<div class="column is-narrow">
<h3>{{ shelf.name }}
{% if shelf.size > 3 %}<small>(<a href="{{ shelf.local_path }}">{% blocktrans with size=shelf.size %}See all {{ size }}{% endblocktrans %}</a>)</small>{% endif %}</h3>
{% if shelf.size > 3 %}<small>(<a href="{{ shelf.local_path }}">{% blocktrans with size=shelf.size %}View all {{ size }}{% endblocktrans %}</a>)</small>{% endif %}</h3>
<div class="is-mobile field is-grouped">
{% for book in shelf.books %}
<div class="control">
@ -41,7 +44,7 @@
</div>
{% endfor %}
</div>
<small><a href="{{ user.local_path }}/shelves">{% blocktrans %}See all {{ shelf_count }} shelves{% endblocktrans %}</a></small>
<small><a href="{% url 'user-shelves' user|username %}">{% trans "View all books" %}</a></small>
</div>
{% endif %}

View file

@ -42,7 +42,7 @@
{% endif %}
</div>
{% with user|username as username %}
{% if 'user/'|add:username|add:'/shelf' not in request.path and 'user/'|add:username|add:'/shelves' not in request.path %}
{% if 'user/'|add:username|add:'/books' not in request.path and 'user/'|add:username|add:'/shelf' not in request.path %}
<nav class="tabs">
<ul>
{% url 'user-feed' user|username as url %}
@ -65,7 +65,7 @@
{% if user.shelf_set.exists %}
{% url 'user-shelves' user|username as url %}
<li{% if url in request.path %} class="is-active"{% endif %}>
<a href="{{ url }}">{% trans "Shelves" %}</a>
<a href="{{ url }}">{% trans "Books" %}</a>
</li>
{% endif %}
</ul>

View file

@ -27,7 +27,7 @@ class Shelf(TestCase):
shelf = models.Shelf.objects.create(
name="Test Shelf", identifier="test-shelf", user=self.local_user
)
expected_id = "https://%s/user/mouse/shelf/test-shelf" % settings.DOMAIN
expected_id = "https://%s/user/mouse/books/test-shelf" % settings.DOMAIN
self.assertEqual(shelf.get_remote_id(), expected_id)
models.Shelf.broadcast = real_broadcast

View file

@ -138,16 +138,8 @@ urlpatterns = [
views.Following.as_view(),
name="user-following",
),
re_path(r"%s/shelves/?$" % user_path, views.user_shelves_page, name="user-shelves"),
re_path(r"%s/lists/?$" % user_path, views.UserLists.as_view(), name="user-lists"),
# goals
re_path(
r"%s/goal/(?P<year>\d{4})/?$" % user_path,
views.Goal.as_view(),
name="user-goal",
),
re_path(r"^hide-goal/?$", views.hide_goal, name="hide-goal"),
# 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/(?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"),
@ -159,6 +151,29 @@ urlpatterns = [
re_path(
r"^list/(?P<list_id>\d+)/curate/?$", views.Curate.as_view(), name="list-curate"
),
# shelf
re_path(r"%s/books/?$" % user_path, views.user_shelves_page, name="user-shelves"),
re_path(
r"^%s/(helf|books)/(?P<shelf_identifier>[\w-]+)(.json)?/?$" % user_path,
views.Shelf.as_view(),
name="shelf",
),
re_path(
r"^%s/(books|shelf)/(?P<shelf_identifier>[\w-]+)(.json)?/?$" % local_user_path,
views.Shelf.as_view(),
name="shelf",
),
re_path(r"^create-shelf/?$", views.create_shelf, name="shelf-create"),
re_path(r"^delete-shelf/(?P<shelf_id>\d+)?$", views.delete_shelf),
re_path(r"^shelve/?$", views.shelve),
re_path(r"^unshelve/?$", views.unshelve),
# goals
re_path(
r"%s/goal/(?P<year>\d{4})/?$" % user_path,
views.Goal.as_view(),
name="user-goal",
),
re_path(r"^hide-goal/?$", views.hide_goal, name="hide-goal"),
# preferences
re_path(r"^preferences/profile/?$", views.EditUser.as_view(), name="prefs-profile"),
re_path(r"^preferences/password/?$", views.ChangePassword.as_view()),
@ -199,20 +214,6 @@ urlpatterns = [
re_path(r"^tag/(?P<tag_id>.+)/?$", views.Tag.as_view()),
re_path(r"^tag/?$", views.AddTag.as_view()),
re_path(r"^untag/?$", views.RemoveTag.as_view()),
# shelf
re_path(
r"^%s/shelf/(?P<shelf_identifier>[\w-]+)(.json)?/?$" % user_path,
views.Shelf.as_view(),
name="shelf",
),
re_path(
r"^%s/shelf/(?P<shelf_identifier>[\w-]+)(.json)?/?$" % local_user_path,
views.Shelf.as_view(),
),
re_path(r"^create-shelf/?$", views.create_shelf, name="shelf-create"),
re_path(r"^delete-shelf/(?P<shelf_id>\d+)?$", views.delete_shelf),
re_path(r"^shelve/?$", views.shelve),
re_path(r"^unshelve/?$", views.unshelve),
# reading progress
re_path(r"^edit-readthrough/?$", views.edit_readthrough, name="edit-readthrough"),
re_path(r"^delete-readthrough/?$", views.delete_readthrough),

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff