forked from mirrors/bookwyrm
black
This commit is contained in:
parent
2b483488aa
commit
440e2f8806
5 changed files with 15 additions and 6 deletions
|
@ -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}"
|
||||
|
||||
|
|
|
@ -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<list_id>\d+)(\.json)?/?$", views.List.as_view(), name="list"),
|
||||
re_path(rf"^list/(?P<list_id>\d+){regex.SLUG}/?$", views.List.as_view(), name="list"),
|
||||
re_path(
|
||||
rf"^list/(?P<list_id>\d+){regex.SLUG}/?$", views.List.as_view(), name="list"
|
||||
),
|
||||
re_path(
|
||||
r"^list/(?P<list_id>\d+)/item/(?P<list_item>\d+)/?$",
|
||||
views.ListItem.as_view(),
|
||||
|
@ -561,7 +563,9 @@ urlpatterns = [
|
|||
rf"^author/(?P<author_id>\d+)(.json)?/?$", views.Author.as_view(), name="author"
|
||||
),
|
||||
re_path(
|
||||
rf"^author/(?P<author_id>\d+){regex.SLUG}/?$", views.Author.as_view(), name="author"
|
||||
rf"^author/(?P<author_id>\d+){regex.SLUG}/?$",
|
||||
views.Author.as_view(),
|
||||
name="author",
|
||||
),
|
||||
re_path(
|
||||
r"^author/(?P<author_id>\d+)/edit/?$",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()}"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue