@@ -33,9 +33,7 @@ def check_bidding_permissions(lot, user):
33
33
if lot .user and lot .user .pk == user .pk :
34
34
return "You can't bid on your own lot"
35
35
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 ()
39
37
if not tos :
40
38
return "You haven't joined this auction"
41
39
else :
@@ -72,12 +70,7 @@ def check_all_permissions(lot, user):
72
70
return "This user has banned you from bidding on their lots"
73
71
if lot .banned :
74
72
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 ():
81
74
return "You don't have permission to bid in this auction"
82
75
return False
83
76
@@ -133,9 +126,7 @@ def bid_on_lot(lot, user, amount):
133
126
result ["message" ] = "This lot has already been sold"
134
127
return result
135
128
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 ()
139
130
if invoice and invoice .status != "DRAFT" :
140
131
result ["message" ] = (
141
132
"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):
174
165
bid .last_bid_time = timezone .now ()
175
166
bid .save ()
176
167
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"
180
169
result ["send_to" ] = "user"
181
170
# result["high_bidder_pk"] = user.pk
182
171
# result["high_bidder_name"] = str(user)
@@ -198,9 +187,7 @@ def bid_on_lot(lot, user, amount):
198
187
if bid .amount >= lot .buy_now_price :
199
188
lot .winner = user
200
189
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 ()
204
191
if auctiontos_winner :
205
192
lot .auctiontos_winner = auctiontos_winner
206
193
invoice , created = Invoice .objects .get_or_create (
@@ -254,9 +241,7 @@ def bid_on_lot(lot, user, amount):
254
241
bid .last_bid_time = timezone .now ()
255
242
bid .save ()
256
243
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
260
245
# there's a high bidder already
261
246
bid .save () # save the current bid regardless
262
247
# 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):
278
263
if originalHighBidder .pk == lot .high_bidder .pk :
279
264
# user is upping their own price, don't tell other people about it
280
265
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 } "
284
267
# print(f"{user_string} has raised their bid on {lot} to ${bid.amount}")
285
268
return result
286
269
except :
287
270
pass
288
271
# New high bidder! If we get to this point, the user has bid against someone else and changed the price
289
272
result ["date_end" ] = reset_lot_end_time (lot )
290
273
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 } "
294
275
if result ["date_end" ]:
295
276
result ["message" ] += ". End time extended!"
296
277
result ["high_bidder_pk" ] = lot .high_bidder .pk
@@ -351,19 +332,13 @@ def connect(self):
351
332
self .lot = Lot .objects .get (pk = self .lot_number )
352
333
353
334
# 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 )
357
336
358
337
# 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 )
362
339
self .accept ()
363
340
# 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 ]
367
342
# send oldest first
368
343
for history in reversed (allHistory ):
369
344
try :
@@ -417,9 +392,7 @@ def connect(self):
417
392
418
393
def disconnect (self , close_code ):
419
394
# 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 )
423
396
# bit redundant, but 'seen' is used for lot notifications for the owner of a given lot
424
397
user_pk = None
425
398
if self .lot .user :
@@ -431,13 +404,9 @@ def disconnect(self, close_code):
431
404
LotHistory .objects .filter (lot = self .lot .pk , seen = False ).update (seen = True )
432
405
# this is for everyone else
433
406
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 ()
437
408
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 } " )
441
410
existing_subscription .last_seen = timezone .now ()
442
411
existing_subscription .last_notification_sent = timezone .now ()
443
412
existing_subscription .save ()
@@ -516,12 +485,8 @@ def receive(self, text_data):
516
485
"info" : result ["type" ],
517
486
"message" : result ["message" ],
518
487
"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" ],
525
490
},
526
491
)
527
492
else :
0 commit comments