Python formatting

This commit is contained in:
Mouse Reeve 2021-09-27 16:08:52 -07:00
parent af2f78095e
commit 62ff9d6199
7 changed files with 16 additions and 18 deletions

View file

@ -106,7 +106,6 @@ class BookWyrmModel(models.Model):
raise PermissionDenied()
@receiver(models.signals.post_save)
# pylint: disable=unused-argument
def set_remote_id(sender, instance, created, *args, **kwargs):

View file

@ -56,9 +56,7 @@ class BaseModel(TestCase):
instance = models.Work.objects.create(title="work title")
instance.remote_id = None
base_model.set_remote_id(None, instance, True)
self.assertEqual(
instance.remote_id, f"https://{DOMAIN}/book/{instance.id}"
)
self.assertEqual(instance.remote_id, f"https://{DOMAIN}/book/{instance.id}")
# shouldn't set remote_id if it's not created
instance.remote_id = None

View file

@ -95,8 +95,11 @@ class Status(View):
def get(self, request, username, status_id):
"""display a particular status (and replies, etc)"""
user = get_user_from_username(request.user, username)
status = get_object_or_404(models.Status.objects.select_subclasses(),
user=user, id=status_id, deleted=False
status = get_object_or_404(
models.Status.objects.select_subclasses(),
user=user,
id=status_id,
deleted=False,
)
# make sure the user is authorized to see the status
status.raise_visible_to_user(request.user)

View file

@ -77,8 +77,8 @@ def delete_follow_request(request):
username = request.POST["user"]
requester = get_user_from_username(request.user, username)
follow_request = get_object_or_404(models.UserFollowRequest,
user_subject=requester, user_object=request.user
follow_request = get_object_or_404(
models.UserFollowRequest, user_subject=requester, user_object=request.user
)
follow_request.raise_not_deletable(request.user)

View file

@ -352,9 +352,7 @@ def set_book_position(request, list_item_id):
try:
int_position = int(request.POST.get("position"))
except ValueError:
return HttpResponseBadRequest(
"bad value for position. should be an integer"
)
return HttpResponseBadRequest("bad value for position. should be an integer")
if int_position < 1:
return HttpResponseBadRequest("position cannot be less than 1")
@ -363,9 +361,9 @@ def set_book_position(request, list_item_id):
# the max position to which a book may be set is the highest order for
# books which are approved
order_max = book_list.listitem_set.filter(approved=True).aggregate(
Max("order")
)["order__max"]
order_max = book_list.listitem_set.filter(approved=True).aggregate(Max("order"))[
"order__max"
]
int_position = min(int_position, order_max)

View file

@ -45,8 +45,8 @@ class ReadingStatus(View):
if not identifier:
return HttpResponseBadRequest()
desired_shelf = get_object_or_404(models.Shelf,
identifier=identifier, user=request.user
desired_shelf = get_object_or_404(
models.Shelf, identifier=identifier, user=request.user
)
book = (

View file

@ -147,12 +147,12 @@ def shelve(request):
# first we need to remove from the specified shelf
change_from_current_identifier = request.POST.get("change-shelf-from")
if not change_from_current_identifier:
#find the shelfbook obj and delete it
# find the shelfbook obj and delete it
get_object_or_404(
models.ShelfBook,
book=book,
user=request.user,
shelf__identifier=change_from_current_identifier
shelf__identifier=change_from_current_identifier,
).delete()
# A book can be on multiple shelves, but only on one read status shelf at a time