From 2b483488aa853aa3872aecca3700212a434f59f3 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Wed, 2 Mar 2022 01:37:58 -0800 Subject: [PATCH] Remove slugs from shelf as their id has text in it already --- bookwyrm/models/shelf.py | 4 ++++ bookwyrm/urls.py | 10 ---------- bookwyrm/views/shelf/shelf.py | 5 +---- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/bookwyrm/models/shelf.py b/bookwyrm/models/shelf.py index 749049e3..a83b8251 100644 --- a/bookwyrm/models/shelf.py +++ b/bookwyrm/models/shelf.py @@ -59,6 +59,10 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel): """can the shelf be safely deleted?""" return self.editable and not self.shelfbook_set.exists() + def get_remote_id(self): + """do not use slugs""" + return self.get_permalink() + def get_permalink(self): """shelf identifier instead of id""" base_path = self.user.remote_id diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 6ad7d65a..fd854278 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -439,21 +439,11 @@ urlpatterns = [ views.Shelf.as_view(), name="shelf", ), - re_path( - rf"^{USER_PATH}/(shelf|books)/(?P[\w-]+){regex.SLUG}/?$", - views.Shelf.as_view(), - name="shelf", - ), re_path( rf"^{LOCAL_USER_PATH}/(books|shelf)/(?P[\w-]+)(.json)?/?$", views.Shelf.as_view(), name="shelf", ), - re_path( - rf"^{LOCAL_USER_PATH}/(books|shelf)/(?P[\w-]+){regex.SLUG}/?$", - views.Shelf.as_view(), - name="shelf", - ), re_path(r"^create-shelf/?$", views.create_shelf, name="shelf-create"), re_path(r"^delete-shelf/(?P\d+)/?$", views.delete_shelf), re_path(r"^shelve/?$", views.shelve), diff --git a/bookwyrm/views/shelf/shelf.py b/bookwyrm/views/shelf/shelf.py index b92a7917..beeb7043 100644 --- a/bookwyrm/views/shelf/shelf.py +++ b/bookwyrm/views/shelf/shelf.py @@ -14,7 +14,7 @@ from django.views import View from bookwyrm import forms, models from bookwyrm.activitypub import ActivitypubResponse from bookwyrm.settings import PAGE_LENGTH -from bookwyrm.views.helpers import is_api_request, get_user_from_username, maybe_redirect_local_path +from bookwyrm.views.helpers import is_api_request, get_user_from_username # pylint: disable=no-self-use @@ -56,9 +56,6 @@ class Shelf(View): if is_api_request(request) and shelf_identifier: return ActivitypubResponse(shelf.to_activity(**request.GET)) - if r := maybe_redirect_local_path(request, shelf): - return r - reviews = models.Review.objects if not is_self: reviews = models.Review.privacy_filter(request.user)