forked from mirrors/bookwyrm
in progress fixes for pylint
This commit is contained in:
parent
594fa5d058
commit
f2d7bdbf27
|
@ -372,7 +372,7 @@ urlpatterns = [
|
||||||
# groups
|
# groups
|
||||||
re_path(rf"{USER_PATH}/groups/?$", views.UserGroups.as_view(), name="user-groups"),
|
re_path(rf"{USER_PATH}/groups/?$", views.UserGroups.as_view(), name="user-groups"),
|
||||||
re_path(
|
re_path(
|
||||||
rf"^group/(?P<group_id>\d+)(.json)?/?$", views.Group.as_view(), name="group"
|
r"^group/(?P<group_id>\d+)(.json)?/?$", views.Group.as_view(), name="group"
|
||||||
),
|
),
|
||||||
re_path(
|
re_path(
|
||||||
rf"^group/(?P<group_id>\d+){regex.SLUG}/?$", views.Group.as_view(), name="group"
|
rf"^group/(?P<group_id>\d+){regex.SLUG}/?$", views.Group.as_view(), name="group"
|
||||||
|
@ -403,7 +403,7 @@ urlpatterns = [
|
||||||
re_path(rf"{USER_PATH}/lists/?$", views.UserLists.as_view(), name="user-lists"),
|
re_path(rf"{USER_PATH}/lists/?$", views.UserLists.as_view(), name="user-lists"),
|
||||||
re_path(r"^list/?$", views.Lists.as_view(), name="lists"),
|
re_path(r"^list/?$", views.Lists.as_view(), name="lists"),
|
||||||
re_path(r"^list/saved/?$", views.SavedLists.as_view(), name="saved-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(r"^list/(?P<list_id>\d+)(\.json)?/?$", views.List.as_view(), name="list"),
|
||||||
re_path(
|
re_path(
|
||||||
rf"^list/(?P<list_id>\d+){regex.SLUG}/?$", views.List.as_view(), name="list"
|
rf"^list/(?P<list_id>\d+){regex.SLUG}/?$", views.List.as_view(), name="list"
|
||||||
),
|
),
|
||||||
|
@ -560,7 +560,7 @@ urlpatterns = [
|
||||||
re_path(r"^isbn/(?P<isbn>\d+)(.json)?/?$", views.Isbn.as_view()),
|
re_path(r"^isbn/(?P<isbn>\d+)(.json)?/?$", views.Isbn.as_view()),
|
||||||
# author
|
# author
|
||||||
re_path(
|
re_path(
|
||||||
rf"^author/(?P<author_id>\d+)(.json)?/?$", views.Author.as_view(), name="author"
|
r"^author/(?P<author_id>\d+)(.json)?/?$", views.Author.as_view(), name="author"
|
||||||
),
|
),
|
||||||
re_path(
|
re_path(
|
||||||
rf"^author/(?P<author_id>\d+){regex.SLUG}/?$",
|
rf"^author/(?P<author_id>\d+){regex.SLUG}/?$",
|
||||||
|
|
|
@ -26,8 +26,8 @@ class Author(View):
|
||||||
if is_api_request(request):
|
if is_api_request(request):
|
||||||
return ActivitypubResponse(author.to_activity())
|
return ActivitypubResponse(author.to_activity())
|
||||||
|
|
||||||
if r := maybe_redirect_local_path(request, author):
|
if redirect := maybe_redirect_local_path(request, author):
|
||||||
return r
|
return redirect
|
||||||
|
|
||||||
books = (
|
books = (
|
||||||
models.Work.objects.filter(Q(authors=author) | Q(editions__authors=author))
|
models.Work.objects.filter(Q(authors=author) | Q(editions__authors=author))
|
||||||
|
|
|
@ -50,8 +50,8 @@ class Book(View):
|
||||||
if not book or not book.parent_work:
|
if not book or not book.parent_work:
|
||||||
raise Http404()
|
raise Http404()
|
||||||
|
|
||||||
if r := maybe_redirect_local_path(request, book):
|
if redirect := maybe_redirect_local_path(request, book):
|
||||||
return r
|
return redirect
|
||||||
|
|
||||||
# all reviews for all editions of the book
|
# all reviews for all editions of the book
|
||||||
reviews = models.Review.privacy_filter(request.user).filter(
|
reviews = models.Review.privacy_filter(request.user).filter(
|
||||||
|
|
|
@ -130,8 +130,8 @@ class Status(View):
|
||||||
status.to_activity(pure=not is_bookwyrm_request(request))
|
status.to_activity(pure=not is_bookwyrm_request(request))
|
||||||
)
|
)
|
||||||
|
|
||||||
if r := maybe_redirect_local_path(request, status):
|
if redirect := maybe_redirect_local_path(request, status):
|
||||||
return r
|
return redirect
|
||||||
|
|
||||||
visible_thread = (
|
visible_thread = (
|
||||||
models.Status.privacy_filter(request.user)
|
models.Status.privacy_filter(request.user)
|
||||||
|
|
|
@ -26,8 +26,8 @@ class Group(View):
|
||||||
group = get_object_or_404(models.Group, id=group_id)
|
group = get_object_or_404(models.Group, id=group_id)
|
||||||
group.raise_visible_to_user(request.user)
|
group.raise_visible_to_user(request.user)
|
||||||
|
|
||||||
if r := maybe_redirect_local_path(request, group):
|
if redirect := maybe_redirect_local_path(request, group):
|
||||||
return r
|
return redirect
|
||||||
|
|
||||||
lists = (
|
lists = (
|
||||||
models.List.privacy_filter(request.user)
|
models.List.privacy_filter(request.user)
|
||||||
|
|
|
@ -206,12 +206,13 @@ def filter_stream_by_status_type(activities, allowed_types=None):
|
||||||
|
|
||||||
def maybe_redirect_local_path(request, model):
|
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.
|
if the request had an invalid path, return a permanent redirect response to the
|
||||||
|
correct one, including a slug if any.
|
||||||
if path is valid, returns False.
|
if path is valid, returns False.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# don't redirect empty path for unit tests which currently have this
|
# don't redirect empty path for unit tests which currently have this
|
||||||
if request.path == "/" or request.path == model.local_path:
|
if request.path in ("/", model.local_path):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
new_path = model.local_path
|
new_path = model.local_path
|
||||||
|
|
Loading…
Reference in a new issue