Backwards compatibility with "shelf" urls

This commit is contained in:
Mouse Reeve 2021-03-31 09:50:16 -07:00
parent 4a490d25a8
commit f8ce9b0956
4 changed files with 6 additions and 5 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

@ -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

@ -42,7 +42,7 @@
{% endif %}
</div>
{% with user|username as username %}
{% if 'user/'|add:username|add:'/books' 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 %}

View file

@ -154,13 +154,14 @@ urlpatterns = [
# shelf
re_path(r"%s/books/?$" % user_path, views.user_shelves_page, name="user-shelves"),
re_path(
r"^%s/books/(?P<shelf_identifier>[\w-]+)(.json)?/?$" % user_path,
r"^%s/(helf|books)/(?P<shelf_identifier>[\w-]+)(.json)?/?$" % user_path,
views.Shelf.as_view(),
name="shelf",
),
re_path(
r"^%s/books/(?P<shelf_identifier>[\w-]+)(.json)?/?$" % local_user_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),