Skip to content

Commit

Permalink
force donation threshold for #266
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Nov 14, 2024
1 parent c35a756 commit be90334
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
7 changes: 7 additions & 0 deletions auctions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,7 @@ class Meta:
"minimum_bid",
"winning_bid_percent_to_club_for_club_members",
"lot_entry_fee_for_club_members",
"force_donation_threshold",
"require_phone_number",
"reserve_price",
"buy_now",
Expand Down Expand Up @@ -1685,6 +1686,12 @@ def __init__(self, *args, **kwargs):
"%",
wrapper_class="col-lg-3",
),
PrependedAppendedText(
"force_donation_threshold",
"$",
".00",
wrapper_class="col-lg-3",
),
css_class="row",
),
HTML("<h4>Lot fee discounts</h4>"),
Expand Down
25 changes: 25 additions & 0 deletions auctions/migrations/0164_auction_force_donation_threshold.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.1.1 on 2024-11-14 18:05

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("auctions", "0163_alter_auction_summernote_description_and_more"),
]

operations = [
migrations.AddField(
model_name="auction",
name="force_donation_threshold",
field=models.PositiveIntegerField(
blank=True,
default=None,
help_text="Most auctions should leave this blank. Force lots to be a donation if they sell for this amount or less.",
null=True,
validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(10)],
verbose_name="Donation threshold",
),
),
]
17 changes: 17 additions & 0 deletions auctions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,16 @@ class Auction(models.Model):
pre_register_lot_entry_fee_discount.help_text = (
"Decrease the lot entry fee by this amount if users add lots through this website"
)
force_donation_threshold = models.PositiveIntegerField(
default=None,
blank=True,
null=True,
validators=[MinValueValidator(0), MaxValueValidator(10)],
verbose_name="Donation threshold",
)
force_donation_threshold.help_text = (
"Most auctions should leave this blank. Force lots to be a donation if they sell for this amount or less."
)
date_posted = models.DateTimeField(auto_now_add=True)
date_start = models.DateTimeField("Auction start date")
date_start.help_text = "Bidding starts on this date"
Expand Down Expand Up @@ -2186,6 +2196,13 @@ def save(self, *args, **kwargs):
# when an auction is set to be buy now only
# if self.auction and self.auction.online_bidding == "buy_now_only":
# self.reserve_price = self.buy_now_price
if (
self.auction
and self.auction.force_donation_threshold
and self.winning_price
and self.winning_price <= self.auction.force_donation_threshold
):
self.donation = True
super().save(*args, **kwargs)

# chat history subscription for the owner
Expand Down
1 change: 1 addition & 0 deletions auctions/templates/auction.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ <h5>The following rules will be automatically enforced by this site:</h5>
{% if auction.lot_entry_fee %} <li>You will be charged a flat rate of ${{ auction.lot_entry_fee }} per lot you sell</li> {% endif %}
{% endif %}
{% if auction.unsold_lot_fee %}<li>If your lot does not sell, you will be charged ${{ auction.unsold_lot_fee }}</li>{% endif %}
{% if auction.force_donation_threshold %}<li>If your lot sells for ${{auction.force_donation_threshold}} or less, it will be considered a donation to the club</li>{% endif %}
{% if auction.minimum_bid > 2 %} <li>There will be a minimum bid of ${{auction.minimum_bid}} on all lots{% if auction.reserve_price != "disable" %}, and sellers can set their own minimum bids{% endif %}</li> {% endif %}
{% if auction.buy_now != 'disable' %} <li>Sellers can set a buy now price on their lots, which will allow a lot to be sold without bidding</li> {% endif %}
</ul>
Expand Down
1 change: 1 addition & 0 deletions auctions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3912,6 +3912,7 @@ def form_valid(self, form, **kwargs):
"auto_add_images",
"message_users_when_lots_sell",
"label_print_fields",
"force_donation_threshold",
]
for field in fields_to_clone:
setattr(auction, field, getattr(original_auction, field))
Expand Down

0 comments on commit be90334

Please sign in to comment.