Skip to content

Commit

Permalink
Merge pull request #247 from iragm/fix-proxy-bidding
Browse files Browse the repository at this point in the history
Fix proxy bidding
  • Loading branch information
iragm authored Oct 19, 2024
2 parents c1906e6 + 9ee8328 commit 518dc67
Show file tree
Hide file tree
Showing 21 changed files with 232 additions and 335 deletions.
15 changes: 14 additions & 1 deletion auctions/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def check_bidding_permissions(lot, user):
else:
if not tos.bidding_allowed:
return "This auction requires admin approval before you can bid"
if not lot.auction.is_online and lot.auction.online_bidding == "disable":
return "This auction does not allow online bidding"
return False


Expand Down Expand Up @@ -136,7 +138,15 @@ def bid_on_lot(lot, user, amount):
"Your invoice for this auction is not open. An administrator can reopen it and allow you to bid."
)
return result

if (
lot.auction
and not lot.auction.is_online
and lot.auction.online_bidding == "buy_now_only"
and lot.buy_now_price
):
if amount < lot.buy_now_price:
result["message"] = "This auction does not allow bids, you can only buy this lot now."
return result
originalHighBidder = lot.high_bidder
originalBid = lot.high_bid
bid, created = Bid.objects.get_or_create(
Expand Down Expand Up @@ -200,6 +210,9 @@ def bid_on_lot(lot, user, amount):
lot.create_update_invoices
lot.winning_price = lot.buy_now_price
lot.buy_now_used = True
if lot.label_printed:
lot.label_printed = False
lot.label_needs_reprinting = True
# this next line makes the lot end immediately after buy now is used
# I have put it in and taken it out a few times now, it is controversial because it causes lots to "disappear" when sold
# see also lot.ended - setting this is needed to make buy now lots go into invoices immediately
Expand Down
7 changes: 4 additions & 3 deletions auctions/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def __init__(self, *args, **kwargs):
except:
pass
# "all", "open", "unsold", or "ended". If regarding an auction, should default to all
self.status = "open"
self.status = "all"
self.showShipping = True
self.shippingLocation = 52 # USA, later we might set this with a cookie like we do with lat and lng
if self.user.is_authenticated:
Expand Down Expand Up @@ -569,7 +569,7 @@ def qs(self):
if self.status == "open":
primary_queryset = primary_queryset.filter(active=True)
if self.status == "unsold":
primary_queryset = primary_queryset.filter(active=True, winner__isnull=True)
primary_queryset = primary_queryset.filter(active=True, winning_price__isnull=True)
# if not self.regardingAuction and not self.regardingUser:
# # no auction or user selected in the filter
# primary_queryset = primary_queryset.exclude(auction__promote_this_auction=False)
Expand Down Expand Up @@ -655,6 +655,7 @@ def qs(self):
if self.user.is_superuser:
show_very_new_lots = True
if self.regardingAuction:
# might want to change this to be `and self.regardingAuction.online_bidding == 'disable'`
if not self.regardingAuction.is_online:
show_very_new_lots = True
if not show_very_new_lots:
Expand Down Expand Up @@ -787,7 +788,7 @@ def text_filter(self, queryset, name, value):
for fragment in split:
fragment = fragment.strip()
qList |= (
Q(description__icontains=fragment)
Q(summernote_description__icontains=fragment)
| Q(lot_name__icontains=fragment)
| Q(user__username=fragment)
| Q(custom_lot_number=fragment)
Expand Down
19 changes: 8 additions & 11 deletions auctions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def __init__(self, *args, **kwargs):
self.fields["reserve_price"].required = True
if self.auction.buy_now == "disable":
self.fields["buy_now_price"].widget = HiddenInput()
if self.auction.buy_now == "required" or self.auction.buy_now == "forced":
if self.auction.buy_now == "required":
self.fields["buy_now_price"].required = True
if not self.auction.use_categories:
self.fields["i_bred_this_fish"].widget = HiddenInput()
Expand All @@ -197,9 +197,7 @@ def clean(self):
cleaned_data["reserve_price"] = self.auction.minimum_bid
if self.auction.buy_now == "disable" and cleaned_data.get("buy_now_price"):
cleaned_data["buy_now_price"] = None
if (self.auction.buy_now == "require" or self.auction.buy_now == "forced") and not cleaned_data.get(
"buy_now_price"
):
if (self.auction.buy_now == "require") and not cleaned_data.get("buy_now_price"):
self.add_error("buy_now_price", "Buy Now price is required in this auction")
# we need to make sure users can't add extra lots
if not self.is_admin and self.auction.max_lots_per_user:
Expand Down Expand Up @@ -864,9 +862,9 @@ def __init__(self, is_edit_form, auctiontos, auction, *args, **kwargs):
self.fields["is_club_member"].initial = self.auctiontos.is_club_member
self.fields["selling_allowed"].initial = self.auctiontos.selling_allowed
self.fields["bidding_allowed"].initial = self.auctiontos.bidding_allowed
if not auction.allow_bidding_on_lots and not self.auctiontos:
if auction.online_bidding == "disable" and not self.auctiontos:
self.fields["bidding_allowed"].widget = HiddenInput()
if not auction.allow_bidding_on_lots and self.auctiontos and self.auctiontos.bidding_allowed:
if auction.online_bidding == "disable" and self.auctiontos and self.auctiontos.bidding_allowed:
self.fields["bidding_allowed"].widget = HiddenInput()
else:
self.fields["is_admin"].widget = HiddenInput()
Expand Down Expand Up @@ -1562,7 +1560,7 @@ class Meta:
"buy_now",
"tax",
"advanced_lot_adding",
"allow_bidding_on_lots", # it's back...for now
"online_bidding",
"date_online_bidding_ends",
"date_online_bidding_starts",
"allow_deleting_bids",
Expand Down Expand Up @@ -1599,8 +1597,7 @@ def __init__(self, *args, **kwargs):
self.fields[
"lot_submission_end_date"
].help_text = "This should be 1-24 hours before the end of your auction"
self.fields["allow_bidding_on_lots"].help_text = "Leave this checked or people won't be able to bid!"
self.fields["allow_bidding_on_lots"].widget = forms.HiddenInput()
self.fields["online_bidding"].widget = forms.HiddenInput()
self.fields["message_users_when_lots_sell"].widget = forms.HiddenInput()
self.fields["advanced_lot_adding"].widget = forms.HiddenInput()
# self.fields['pre_register_lot_entry_fee_discount'].widget=forms.HiddenInput()
Expand All @@ -1611,7 +1608,7 @@ def __init__(self, *args, **kwargs):
else:
# self.fields["only_approved_bidders"].widget = forms.HiddenInput()
self.fields["unsold_lot_fee"].widget = forms.HiddenInput()
self.fields["allow_bidding_on_lots"].help_text = "Most auctions should leave this off, it confuses people"
self.fields["online_bidding"].help_text = "Most auctions should leave this off, it confuses people"
self.fields[
"date_end"
].help_text = "You should probably leave this blank so that you can manually set winners. This field has been indefinitely set to hidden - see https://github.com/iragm/fishauctions/issues/116"
Expand Down Expand Up @@ -1714,7 +1711,7 @@ def __init__(self, *args, **kwargs):
HTML("<h4>Lot permissions</h4>"),
Div(
Div(
"allow_bidding_on_lots",
"online_bidding",
css_class="col-md-3",
),
Div(
Expand Down
14 changes: 14 additions & 0 deletions auctions/management/commands/auctiontos_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ def handle(self, *args, **options):
tos.save()
if tos.unbanned_lot_count:
send_tos_notification("auction_print_reminder", tos)

# for auctions that allow buy now, we need to send a reminder email to sellers to print their lot labels
auctions_that_need_print_reminder = Auction.objects.filter(
is_deleted=False, is_online=False, date_online_bidding_ends__lt=timezone.now(), reprint_reminder_sent=False
)
for auction in auctions_that_need_print_reminder:
auction.reprint_reminder_sent = True
auction.save()
if auction.date_start > timezone.now() + datetime.timedelta(hours=4):
sellers_to_remind = base_qs.filter(auction=auction)
for seller in sellers_to_remind:
if seller.unprinted_labels_qs.filter(label_needs_reprinting=True).count():
send_tos_notification("reprint_reminder", seller)

# this is a quick reminder to join auctions that you've viewed but haven't joined. Fixes #134
join_auction_reminder = AuctionCampaign.objects.filter(
timestamp__lte=timezone.now() - datetime.timedelta(hours=24),
Expand Down
Loading

0 comments on commit 518dc67

Please sign in to comment.