Skip to content

Commit 0d69933

Browse files
author
=
committedSep 19, 2024
auction activity graph shows the most recent views up until your auction starts
1 parent cfb4721 commit 0d69933

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed
 

‎auctions/forms.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1590,9 +1590,7 @@ def __init__(self, *args, **kwargs):
15901590
else:
15911591
# self.fields["only_approved_bidders"].widget = forms.HiddenInput()
15921592
self.fields["unsold_lot_fee"].widget = forms.HiddenInput()
1593-
self.fields[
1594-
"allow_bidding_on_lots"
1595-
].help_text = "Allow people to place bids online. You should probably leave this unchecked."
1593+
self.fields["allow_bidding_on_lots"].help_text = "Most auctions should leave this off, it confuses people"
15961594
self.fields[
15971595
"date_end"
15981596
].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"

‎auctions/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ class Auction(models.Model):
583583
use_categories = models.BooleanField(default=True, verbose_name="This is a fish auction")
584584
use_categories.help_text = "Check to use categories like Cichlids, Livebearers, etc."
585585
is_deleted = models.BooleanField(default=False)
586-
allow_bidding_on_lots = models.BooleanField(default=True)
586+
allow_bidding_on_lots = models.BooleanField(default=True, verbose_name="Allow online bidding")
587587
only_approved_sellers = models.BooleanField(default=False)
588588
only_approved_sellers.help_text = "Require admin approval before users can add lots. This will not change permissions for users that have already joined."
589589
only_approved_bidders = models.BooleanField(default=False)

‎auctions/views.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -5697,6 +5697,7 @@ class AuctionStatsActivityJSONView(BaseLineChartView, AuctionStatsPermissionsMix
56975697
bins = 21
56985698
days_before = 16
56995699
days_after = bins - days_before
5700+
dates_messed_with = False
57005701

57015702
def dispatch(self, request, *args, **kwargs):
57025703
self.auction = Auction.objects.get(slug=kwargs["slug"], is_deleted=False)
@@ -5708,12 +5709,19 @@ def dispatch(self, request, *args, **kwargs):
57085709
else: # in person
57095710
self.date_start = self.auction.date_start - timezone.timedelta(days=self.days_before)
57105711
self.date_end = self.auction.date_start + timezone.timedelta(days=self.days_after)
5712+
# if date_end is in the future, shift the graph to show the same range, but for the present
5713+
if self.date_end > timezone.now():
5714+
time_difference = self.date_end - self.date_start
5715+
self.date_end = timezone.now()
5716+
self.date_start = self.date_end - time_difference
5717+
self.dates_messed_with = True
57115718
# self.bin_size = (self.date_end - self.date_start).total_seconds() / self.bins
57125719
# self.bin_edges = [self.date_start + timezone.timedelta(seconds=self.bin_size * i) for i in range(self.bins + 1)]
57135720
return super().dispatch(request, *args, **kwargs)
57145721

57155722
def get_labels(self):
5716-
# return [(f"Day {i}") for i in range(self.bins + 1)]
5723+
if self.dates_messed_with:
5724+
return [(f"{i-1} days ago") for i in range(self.bins, 0, -1)]
57175725
before = [(f"{i} days before") for i in range(self.days_before, 0, -1)]
57185726
after = [(f"{i} days after") for i in range(1, self.days_after)]
57195727
midpoint = "start"

0 commit comments

Comments
 (0)