diff --git a/bookwyrm/models/base_model.py b/bookwyrm/models/base_model.py index f729efb8..26d8d36a 100644 --- a/bookwyrm/models/base_model.py +++ b/bookwyrm/models/base_model.py @@ -40,7 +40,7 @@ class BookWyrmModel(models.Model): base_path = f"https://{DOMAIN}" if hasattr(self, "user"): base_path = f"{base_path}{self.user.local_path}" - + model_name = type(self).__name__.lower() return f"{base_path}/{model_name}/{self.id}" diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index fd854278..bf12c276 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -404,7 +404,9 @@ urlpatterns = [ re_path(r"^list/?$", views.Lists.as_view(), name="lists"), re_path(r"^list/saved/?$", views.SavedLists.as_view(), name="saved-lists"), re_path(rf"^list/(?P\d+)(\.json)?/?$", views.List.as_view(), name="list"), - re_path(rf"^list/(?P\d+){regex.SLUG}/?$", views.List.as_view(), name="list"), + re_path( + rf"^list/(?P\d+){regex.SLUG}/?$", views.List.as_view(), name="list" + ), re_path( r"^list/(?P\d+)/item/(?P\d+)/?$", views.ListItem.as_view(), @@ -561,7 +563,9 @@ urlpatterns = [ rf"^author/(?P\d+)(.json)?/?$", views.Author.as_view(), name="author" ), re_path( - rf"^author/(?P\d+){regex.SLUG}/?$", views.Author.as_view(), name="author" + rf"^author/(?P\d+){regex.SLUG}/?$", + views.Author.as_view(), + name="author", ), re_path( r"^author/(?P\d+)/edit/?$", diff --git a/bookwyrm/views/books/books.py b/bookwyrm/views/books/books.py index 1e88f19f..48b148e3 100644 --- a/bookwyrm/views/books/books.py +++ b/bookwyrm/views/books/books.py @@ -30,7 +30,11 @@ class Book(View): ) return ActivitypubResponse(book.to_activity()) - user_statuses = kwargs.get("user_statuses", False) if request.user.is_authenticated else False + user_statuses = ( + kwargs.get("user_statuses", False) + if request.user.is_authenticated + else False + ) # it's safe to use this OR because edition and work and subclasses of the same # table, so they never have clashing IDs diff --git a/bookwyrm/views/helpers.py b/bookwyrm/views/helpers.py index d62812e1..baf301cb 100644 --- a/bookwyrm/views/helpers.py +++ b/bookwyrm/views/helpers.py @@ -203,6 +203,7 @@ def filter_stream_by_status_type(activities, allowed_types=None): return activities + def maybe_redirect_local_path(request, model): """ if the request had an invalid path, return a permanent redirect response to the correct one, including a slug if any. @@ -211,7 +212,7 @@ def maybe_redirect_local_path(request, model): if request.path == model.local_path: return False - new_path = model.local_path + new_path = model.local_path if len(request.GET) > 0: new_path = f"{model.local_path}?{request.GET.urlencode()}" diff --git a/bookwyrm/views/list/list.py b/bookwyrm/views/list/list.py index baf70470..e66f94fe 100644 --- a/bookwyrm/views/list/list.py +++ b/bookwyrm/views/list/list.py @@ -37,7 +37,7 @@ class List(View): return ActivitypubResponse(book_list.to_activity(**request.GET)) if r := maybe_redirect_local_path(request, book_list): - return r; + return r query = request.GET.get("q") suggestions = None