Skip to content

Commit a9e7b3b

Browse files
author
=
committed
fix ruff and autopep8 fighting
1 parent 0d8bace commit a9e7b3b

File tree

2 files changed

+17
-51
lines changed

2 files changed

+17
-51
lines changed

auctions/consumers.py

+16-51
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ def check_bidding_permissions(lot, user):
3333
if lot.user and lot.user.pk == user.pk:
3434
return "You can't bid on your own lot"
3535
if lot.auction:
36-
tos = AuctionTOS.objects.filter(
37-
Q(user=user) | Q(email=user.email), auction=lot.auction
38-
).first()
36+
tos = AuctionTOS.objects.filter(Q(user=user) | Q(email=user.email), auction=lot.auction).first()
3937
if not tos:
4038
return "You haven't joined this auction"
4139
else:
@@ -72,12 +70,7 @@ def check_all_permissions(lot, user):
7270
return "This user has banned you from bidding on their lots"
7371
if lot.banned:
7472
return "This lot has been removed"
75-
if (
76-
lot.auction
77-
and UserBan.objects.filter(
78-
banned_user=user.pk, user=lot.auction.created_by.pk
79-
).first()
80-
):
73+
if lot.auction and UserBan.objects.filter(banned_user=user.pk, user=lot.auction.created_by.pk).first():
8174
return "You don't have permission to bid in this auction"
8275
return False
8376

@@ -133,9 +126,7 @@ def bid_on_lot(lot, user, amount):
133126
result["message"] = "This lot has already been sold"
134127
return result
135128
if lot.auction:
136-
invoice = Invoice.objects.filter(
137-
auctiontos_user__user=user, auction=lot.auction
138-
).first()
129+
invoice = Invoice.objects.filter(auctiontos_user__user=user, auction=lot.auction).first()
139130
if invoice and invoice.status != "DRAFT":
140131
result["message"] = (
141132
"Your invoice for this auction is not open. An administrator can reopen it and allow you to bid."
@@ -174,9 +165,7 @@ def bid_on_lot(lot, user, amount):
174165
bid.last_bid_time = timezone.now()
175166
bid.save()
176167
result["type"] = "INFO"
177-
result["message"] = (
178-
"Bid placed! You can change your bid at any time until the auction ends"
179-
)
168+
result["message"] = "Bid placed! You can change your bid at any time until the auction ends"
180169
result["send_to"] = "user"
181170
# result["high_bidder_pk"] = user.pk
182171
# result["high_bidder_name"] = str(user)
@@ -198,9 +187,7 @@ def bid_on_lot(lot, user, amount):
198187
if bid.amount >= lot.buy_now_price:
199188
lot.winner = user
200189
if lot.auction:
201-
auctiontos_winner = AuctionTOS.objects.filter(
202-
auction=lot.auction, user=user
203-
).first()
190+
auctiontos_winner = AuctionTOS.objects.filter(auction=lot.auction, user=user).first()
204191
if auctiontos_winner:
205192
lot.auctiontos_winner = auctiontos_winner
206193
invoice, created = Invoice.objects.get_or_create(
@@ -254,9 +241,7 @@ def bid_on_lot(lot, user, amount):
254241
bid.last_bid_time = timezone.now()
255242
bid.save()
256243
return result
257-
if (
258-
bid.amount <= originalBid
259-
): # changing this to < would allow bumping without being the high bidder
244+
if bid.amount <= originalBid: # changing this to < would allow bumping without being the high bidder
260245
# there's a high bidder already
261246
bid.save() # save the current bid regardless
262247
# print(f"{user_string} tried to bid on {lot} less than the current bid of ${originalBid}")
@@ -278,19 +263,15 @@ def bid_on_lot(lot, user, amount):
278263
if originalHighBidder.pk == lot.high_bidder.pk:
279264
# user is upping their own price, don't tell other people about it
280265
result["type"] = "INFO"
281-
result["message"] = (
282-
f"You've raised your proxy bid to ${bid.amount}"
283-
)
266+
result["message"] = f"You've raised your proxy bid to ${bid.amount}"
284267
# print(f"{user_string} has raised their bid on {lot} to ${bid.amount}")
285268
return result
286269
except:
287270
pass
288271
# New high bidder! If we get to this point, the user has bid against someone else and changed the price
289272
result["date_end"] = reset_lot_end_time(lot)
290273
result["type"] = "NEW_HIGH_BIDDER"
291-
result["message"] = (
292-
f"{lot.high_bidder_display} is now the high bidder at ${lot.high_bid}"
293-
)
274+
result["message"] = f"{lot.high_bidder_display} is now the high bidder at ${lot.high_bid}"
294275
if result["date_end"]:
295276
result["message"] += ". End time extended!"
296277
result["high_bidder_pk"] = lot.high_bidder.pk
@@ -351,19 +332,13 @@ def connect(self):
351332
self.lot = Lot.objects.get(pk=self.lot_number)
352333

353334
# Join room group
354-
async_to_sync(self.channel_layer.group_add)(
355-
self.room_group_name, self.channel_name
356-
)
335+
async_to_sync(self.channel_layer.group_add)(self.room_group_name, self.channel_name)
357336

358337
# Join private room for notifications only to this user
359-
async_to_sync(self.channel_layer.group_add)(
360-
self.user_room_name, self.channel_name
361-
)
338+
async_to_sync(self.channel_layer.group_add)(self.user_room_name, self.channel_name)
362339
self.accept()
363340
# send the most recent history
364-
allHistory = LotHistory.objects.filter(
365-
lot=self.lot, removed=False
366-
).order_by("-timestamp")[:200]
341+
allHistory = LotHistory.objects.filter(lot=self.lot, removed=False).order_by("-timestamp")[:200]
367342
# send oldest first
368343
for history in reversed(allHistory):
369344
try:
@@ -417,9 +392,7 @@ def connect(self):
417392

418393
def disconnect(self, close_code):
419394
# Leave room group
420-
async_to_sync(self.channel_layer.group_discard)(
421-
self.room_group_name, self.channel_name
422-
)
395+
async_to_sync(self.channel_layer.group_discard)(self.room_group_name, self.channel_name)
423396
# bit redundant, but 'seen' is used for lot notifications for the owner of a given lot
424397
user_pk = None
425398
if self.lot.user:
@@ -431,13 +404,9 @@ def disconnect(self, close_code):
431404
LotHistory.objects.filter(lot=self.lot.pk, seen=False).update(seen=True)
432405
# this is for everyone else
433406
if self.user.pk:
434-
existing_subscription = ChatSubscription.objects.filter(
435-
lot=self.lot, user=self.user.pk
436-
).first()
407+
existing_subscription = ChatSubscription.objects.filter(lot=self.lot, user=self.user.pk).first()
437408
if existing_subscription:
438-
print(
439-
f"Marking all ChatSubscription seen last time now for user {self.user.pk}"
440-
)
409+
print(f"Marking all ChatSubscription seen last time now for user {self.user.pk}")
441410
existing_subscription.last_seen = timezone.now()
442411
existing_subscription.last_notification_sent = timezone.now()
443412
existing_subscription.save()
@@ -516,12 +485,8 @@ def receive(self, text_data):
516485
"info": result["type"],
517486
"message": result["message"],
518487
"high_bidder_pk": result["high_bidder_pk"],
519-
"high_bidder_name": result[
520-
"high_bidder_name"
521-
],
522-
"current_high_bid": result[
523-
"current_high_bid"
524-
],
488+
"high_bidder_name": result["high_bidder_name"],
489+
"current_high_bid": result["current_high_bid"],
525490
},
526491
)
527492
else:

ruff.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
line-length = 120
12
[format]
23
exclude = ["get-pip.py"]
34

0 commit comments

Comments
 (0)