Skip to content

Commit 1d6fb8c

Browse files
author
=
committed
fix #269
1 parent bcebe38 commit 1d6fb8c

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

auctions/forms.py

+18-15
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,7 @@ class Meta:
16681668
"custom_field_1_name",
16691669
"allow_bulk_adding_lots",
16701670
"copy_users_when_copying_this_auction",
1671+
"use_seller_dash_lot_numbering",
16711672
"use_donation_field",
16721673
"use_i_bred_this_fish_field",
16731674
"use_custom_checkbox_field",
@@ -1864,6 +1865,10 @@ def __init__(self, *args, **kwargs):
18641865
"copy_users_when_copying_this_auction",
18651866
css_class="col-md-4",
18661867
),
1868+
Div(
1869+
"use_seller_dash_lot_numbering",
1870+
css_class="col-md-4",
1871+
),
18671872
css_class="row",
18681873
),
18691874
HTML("""<h4>Fields</h4>Control what information your users can enter about lots.
@@ -1975,21 +1980,19 @@ def __init__(self, *args, **kwargs):
19751980
Submit("submit", "Save", css_class="create-update-auction btn-success"),
19761981
)
19771982

1978-
# as it stands right now, we are not cleaning this at all
1979-
# we are relying on the auction save receiver models.on_save_auction to clean anything up
1980-
# def clean(self):
1981-
# cleaned_data = super().clean()
1982-
# date_end = cleaned_data.get("date_end")
1983-
# date_start = cleaned_data.get("date_start")
1984-
# lot_submission_end_date = cleaned_data.get("lot_submission_end_date")
1985-
# if date_end < timezone.now() + datetime.timedelta(hours=2):
1986-
# self.add_error('date_end', "The end date can't be in the past")
1987-
# if date_end < date_start:
1988-
# self.add_error('date_end', "The end date can't be before the start date")
1989-
# if lot_submission_end_date:
1990-
# if lot_submission_end_date > date_end:
1991-
# self.add_error('lot_submission_end_date', "Submission should end before the auction ends")
1992-
# return cleaned_data
1983+
def clean(self):
1984+
cleaned_data = super().clean()
1985+
use_seller_dash_lot_numbering = cleaned_data.get("use_seller_dash_lot_numbering")
1986+
saved_instance = self.instance
1987+
1988+
if saved_instance and saved_instance.pk:
1989+
if use_seller_dash_lot_numbering is not saved_instance.use_seller_dash_lot_numbering:
1990+
if saved_instance.admin_checklist_lots_added:
1991+
self.add_error(
1992+
"use_seller_dash_lot_numbering", "This option cannot be changed after lots have been added."
1993+
)
1994+
1995+
return cleaned_data
19931996

19941997

19951998
class CreateLotForm(forms.ModelForm):

auctions/models.py

+1
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ class Auction(models.Model):
721721
default="qr_code,lot_name,min_bid_label,buy_now_label,quantity_label,seller_name,donation_label,custom_field_1,i_bred_this_fish_label,custom_checkbox_label",
722722
)
723723
use_seller_dash_lot_numbering = models.BooleanField(default=False, blank=True)
724+
use_seller_dash_lot_numbering.help_text = "Include the seller's bidder number with the lot number. This option is not recommended as users find it confusing."
724725

725726
def __str__(self):
726727
result = self.title

auctions/templates/auctions/auction_lot_admin.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{% block content %}
88
{% include 'auction_ribbon.html' %}
99
<small>This is a list of items for sale in your auction. Click a lot name to edit it. {% if auction.is_online %}You probably don't need to use this page; users will add their own lots to this auction{% else %}To add new lots, go to the <a href="{% url 'auction_tos_list' slug=auction.slug %}">users page</a> and click add lots under the appropriate user.{% endif %}<br>
10-
{% if auction.use_seller_dash_lot_numbering %}<br><div class="bg-secondary"><b>Lot numbering has changed:</b> This auction uses the older lot numbering system (seller-lot, for example 123-55 for lot seller 123's 55th lot). Newly created auctions will use only a number and no dash for lots, for example 55). This change is to reduce user confusion and does not impact how your auction works. <a href='https://github.com/iragm/fishauctions/issues/269'>Read more about this update and leave comments here.</a><br></div>{% endif %}
10+
{% if auction.use_seller_dash_lot_numbering and not auction.admin_checklist_lots_added %}<br><div class=""><b class="text-warning">Change your lot numbering:</b> This auction uses seller-dash-lot numbering. Go to the <a href="/auctions/{{auction.slug}}/edit">rules</a> and uncheck <b>Use seller dash lot numbering</b> to switch to a simpler lot numbering system that users find less confusing. <a href='https://github.com/iragm/fishauctions/issues/269'>Read more and leave feedback here.</a><br></div>{% endif %}
1111
</small>
1212
{% if not auction.is_online %}<a class='btn btn-sm btn-primary' href="{{ auction.set_lot_winners_link }}"><i class="bi bi-calendar-check"></i> Set winners</a>{% endif %}
1313
<a id='all_lot_list' href="{% url 'lot_list' slug=auction.slug %}" class="btn btn-sm mt-2 mb-2 btn-primary"><i class="bi bi-download"></i> Export lot CSV</a>

auctions/views.py

+1
Original file line numberDiff line numberDiff line change
@@ -4392,6 +4392,7 @@ def form_valid(self, form, **kwargs):
43924392
"copy_users_when_copying_this_auction",
43934393
"use_donation_field",
43944394
"use_i_bred_this_fish_field",
4395+
"use_seller_dash_lot_numbering",
43954396
]
43964397
for field in fields_to_clone:
43974398
setattr(auction, field, getattr(original_auction, field))

0 commit comments

Comments
 (0)