Skip to content

Commit

Permalink
Merge pull request #212 from iragm/in-person-proxy-bidding
Browse files Browse the repository at this point in the history
In person proxy bidding
  • Loading branch information
iragm authored Sep 8, 2024
2 parents 81af715 + 0379acf commit e57c38a
Show file tree
Hide file tree
Showing 13 changed files with 323 additions and 178 deletions.
2 changes: 1 addition & 1 deletion auctions/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def check_chat_permissions(lot, user):

def check_all_permissions(lot, user):
"""Returns false if everything is OK, or a string error message"""
if UserBan.objects.filter(banned_user=user.pk, user=lot.user.pk).first():
if lot.user and UserBan.objects.filter(banned_user=user.pk, user=lot.user.pk).first():
return "This user has banned you from bidding on their lots"
if lot.banned:
return "This lot has been removed"
Expand Down
81 changes: 38 additions & 43 deletions auctions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,12 @@ def __init__(self, *args, **kwargs):
self.fields["description"].help_text = ""
if self.auction.reserve_price == "disable":
self.fields["reserve_price"].widget = HiddenInput()
# always required anyway...
# if self.auction.reserve_price == "required":
# self.fields['reserve_price'].required = True
if self.auction.reserve_price == "required":
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":
# self.fields['buy_now_price'].required = True

if self.auction.buy_now == "required" or self.auction.buy_now == "forced":
self.fields["buy_now_price"].required = True
if not self.auction.use_categories:
self.fields["i_bred_this_fish"].widget = HiddenInput()

Expand Down Expand Up @@ -408,6 +406,7 @@ def __init__(self, auction, *args, **kwargs):
});
});
</script>
<span id='make_online_bidder_winner'></span>
</div>
</div>
</div>
Expand Down Expand Up @@ -664,7 +663,7 @@ def __init__(self, user, lot, auction, *args, **kwargs):
self.fields["auctiontos_winner"].label = "Winner"
winner_help_test = ""
if lot.high_bidder:
winner_help_test = f"High bidder: <span class='text-warning'>{lot.high_bidder_for_admins}</span> Bid: <span class='text-warning'>${lot.high_bid}</span>"
winner_help_test = f"High bidder: <span class='text-warning'>{lot.high_bidder_for_admins}</span> Bid: <span class='text-warning'>${lot.high_bid}</span> {lot.auction_show_high_bidder_template}"
self.fields["auctiontos_winner"].help_text = winner_help_test
# self.fields['auctiontos_seller'].label = "Seller"
# self.fields['auctiontos_seller'].help_text = ""
Expand Down Expand Up @@ -1545,12 +1544,16 @@ class Meta:
"tax",
"advanced_lot_adding",
"allow_bidding_on_lots", # it's back...for now
"date_online_bidding_ends",
"date_online_bidding_starts",
]
widgets = {
"date_start": DateTimePickerInput(),
"date_end": DateTimePickerInput(),
"lot_submission_start_date": DateTimePickerInput(),
"lot_submission_end_date": DateTimePickerInput(),
"date_online_bidding_ends": DateTimePickerInput(),
"date_online_bidding_starts": DateTimePickerInput(),
"notes": forms.Textarea(),
}

Expand Down Expand Up @@ -1579,8 +1582,10 @@ def __init__(self, *args, **kwargs):
# self.fields['pre_register_lot_entry_fee_discount'].widget=forms.HiddenInput()
self.fields["pre_register_lot_discount_percent"].widget = forms.HiddenInput()
# self.fields['set_lot_winners_url'].widget=forms.HiddenInput()
self.fields["date_online_bidding_starts"].widget = forms.HiddenInput()
self.fields["date_online_bidding_ends"].widget = forms.HiddenInput()
else:
self.fields["only_approved_bidders"].widget = forms.HiddenInput()
# self.fields["only_approved_bidders"].widget = forms.HiddenInput()
self.fields["unsold_lot_fee"].widget = forms.HiddenInput()
self.fields[
"allow_bidding_on_lots"
Expand All @@ -1598,37 +1603,16 @@ def __init__(self, *args, **kwargs):
self.fields["date_start"].help_text = "When the auction actually starts"
self.fields["user_cut"].initial = 100 - self.instance.winning_bid_percent_to_club
self.fields["club_member_cut"].initial = 100 - self.instance.winning_bid_percent_to_club_for_club_members
if self.instance.pk:
# editing existing auction
pass
else:
# this is a new auction
# if self.cloned_from:
# print(self.cloned_from)
# try:
# originalAuction = Auction.objects.get(slug=self.cloned_from, is_deleted=False)
# #if (originalAuction.created_by.pk == self.user.pk) or self.user.is_superuser:
# # you can only clone your own auctions
# cloneFields = ['notes', 'lot_entry_fee','unsold_lot_fee','winning_bid_percent_to_club',
# 'sealed_bid','use_categories', 'promote_this_auction', 'max_lots_per_user', 'allow_additional_lots_as_donation',
# 'email_users_when_invoices_ready', 'pre_register_lot_entry_fee_discount', 'pre_register_lot_discount_percent', 'allow_bidding_on_lots','only_approved_sellers',
# 'invoice_payment_instructions', 'minimum_bid', 'winning_bid_percent_to_club_for_club_members', 'lot_entry_fee_for_club_members',
# ]
# for field in cloneFields:
# self.fields[field].initial = getattr(originalAuction, field)
# self.fields['cloned_from'].initial = self.cloned_from
# except Exception as e:
# print(e)
# try:
# lastAuction = Auction.objects.filter(created_by=self.user).order_by('-date_end')[0]
# self.fields['notes'].initial = "These rules are unchanged from the last auction\n\n" + lastAuction.notes
# except Exception as e:
# no old auction
# else:
if not self.cloned_from:
self.fields[
"notes"
].initial = "## General information\n\nYou should remove this line and edit this section to suit your auction. Use the formatting here as an example.\n\n## Prohibited items\n- You cannot sell any fish or plants banned by state law.\n- You cannot sell large hardware items such as tanks.\n\n## Rules\n- All lots must be properly bagged. No leaking bags!\n- You do not need to be a club member to buy or sell lots."

# if self.instance.pk:
# # editing existing auction
# pass
# else:
# # this is a new auction
# if not self.cloned_from:
# self.fields[
# "notes"
# ].initial = "## General information\n\nYou should remove this line and edit this section to suit your auction. Use the formatting here as an example.\n\n## Prohibited items\n- You cannot sell any fish or plants banned by state law.\n- You cannot sell large hardware items such as tanks.\n\n## Rules\n- All lots must be properly bagged. No leaking bags!\n- You do not need to be a club member to buy or sell lots."
self.helper = FormHelper()
self.helper.form_method = "post"
self.helper.form_id = "auction-form"
Expand Down Expand Up @@ -1715,6 +1699,21 @@ def __init__(self, *args, **kwargs):
css_class="row",
),
HTML("<h4>Lot permissions</h4>"),
Div(
Div(
"allow_bidding_on_lots",
css_class="col-md-4",
),
Div(
"date_online_bidding_starts",
css_class="col-md-4",
),
Div(
"date_online_bidding_ends",
css_class="col-md-4",
),
css_class="row",
),
Div(
Div(
"max_lots_per_user",
Expand All @@ -1734,10 +1733,6 @@ def __init__(self, *args, **kwargs):
),
css_class="row",
),
Div(
"allow_bidding_on_lots",
css_class="col-md-3",
),
HTML("<h4>General</h4>"),
Div(
Div(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 5.0.8 on 2024-09-07 16:23

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("auctions", "0143_auction_extra_promo_link_auction_extra_promo_text"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.AddField(
model_name="auction",
name="date_online_bidding_ends",
field=models.DateTimeField(blank=True, null=True, verbose_name="Online bidding ends"),
),
migrations.AddField(
model_name="auction",
name="date_online_bidding_starts",
field=models.DateTimeField(blank=True, null=True, verbose_name="Online bidding opens"),
),
migrations.AddField(
model_name="lot",
name="max_bid_revealed_by",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="max_bid_revealed_by",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name="auction",
name="date_end",
field=models.DateTimeField(
blank=True,
help_text="Bidding will end on this date. If last-minute bids are placed, bidding can go up to 1 hour past this time on those lots.",
null=True,
verbose_name="Bidding end date",
),
),
]
Loading

0 comments on commit e57c38a

Please sign in to comment.