Skip to content

Commit

Permalink
fix #180
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Aug 17, 2024
1 parent 2bb0793 commit 501290a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 5 deletions.
14 changes: 10 additions & 4 deletions auctions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class Meta:
fields = [
'custom_lot_number',
'lot_name',
'description',
'species_category',
'i_bred_this_fish',
'quantity',
Expand Down Expand Up @@ -124,8 +125,12 @@ def __init__(self, *args, **kwargs):
self.fields['reserve_price'].help_text = ""
self.fields['buy_now_price'].help_text = ""
self.fields['species_category'].initial = Category.objects.get(pk=21) # uncategorized
self.fields['quantity'].initial = 1

if not self.auction.advanced_lot_adding:
self.fields['quantity'].initial = 1
self.fields['quantity'].widget = HiddenInput()
self.fields['description'].widget = HiddenInput()
self.fields['custom_lot_number'].widget = HiddenInput()
self.fields['description'].help_text = ""
if self.auction.reserve_price == "disable":
self.fields['reserve_price'].widget = HiddenInput()
# always required anyway...
Expand Down Expand Up @@ -539,7 +544,7 @@ def __init__(self, user, lot, auction, *args, **kwargs):
else:
self.fields['custom_lot_number'].help_text = "Leave blank to automatically generate"
self.fields['lot_name'].initial = self.lot.lot_name
self.fields['description'].initial = self.lot.lot_name
self.fields['description'].initial = self.lot.description
#self.fields['auctiontos_seller'].initial = self.lot.auctiontos_seller
self.fields['quantity'].initial = self.lot.quantity
self.fields['donation'].initial = self.lot.donation
Expand Down Expand Up @@ -1230,7 +1235,7 @@ class Meta:
'lot_submission_end_date', 'sealed_bid','use_categories', 'promote_this_auction', 'max_lots_per_user', 'allow_additional_lots_as_donation',
'email_users_when_invoices_ready', 'pre_register_lot_discount_percent', 'only_approved_sellers', 'only_approved_bidders',
'invoice_payment_instructions', 'minimum_bid', 'winning_bid_percent_to_club_for_club_members', 'lot_entry_fee_for_club_members', 'require_phone_number',
'reserve_price', 'buy_now', 'tax',
'reserve_price', 'buy_now', 'tax', 'advanced_lot_adding',
]
widgets = {
'date_start': DateTimePickerInput(),
Expand Down Expand Up @@ -1349,6 +1354,7 @@ def __init__(self, *args, **kwargs):
Div('email_users_when_invoices_ready', css_class='col-md-3',),
Div('invoice_payment_instructions', css_class='col-md-6',),
Div('use_categories',css_class='col-md-3',),
Div('advanced_lot_adding',css_class='col-md-3',),
Div('minimum_bid',css_class='col-md-3',),
Div('reserve_price', css_class='col-md-3',),
Div('buy_now', css_class='col-md-3',),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Generated by Django 5.0.8 on 2024-08-17 18:32

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


class Migration(migrations.Migration):

dependencies = [
('auctions', '0139_alter_auction_buy_now_and_more'),
]

operations = [
migrations.AddField(
model_name='auction',
name='advanced_lot_adding',
field=models.BooleanField(default=False, help_text='Show lot number, quantity and description fields when bulk adding lots'),
),
migrations.AlterField(
model_name='auction',
name='buy_now',
field=models.CharField(choices=[('disable', "Don't allow"), ('allow', 'Allow'), ('required', 'Required for all lots'), ('forced', 'Required, and disable bidding')], default='allow', help_text="Allow lots to be sold without bidding, for a user-specified price. If required with bidding disabled, people will only buy now and won't be able to bid against each other.", max_length=20),
),
migrations.AlterField(
model_name='auction',
name='minimum_bid',
field=models.PositiveIntegerField(default=2, help_text='Lowest price any lot will be sold for', validators=[django.core.validators.MinValueValidator(1)]),
),
migrations.AlterField(
model_name='auction',
name='only_approved_bidders',
field=models.BooleanField(default=False, help_text='Require admin approval before users can bid. This only applies to new users: Users that you manually add and users who have a paid invoice in a past auctions will be allowed to bid.'),
),
migrations.AlterField(
model_name='auction',
name='reserve_price',
field=models.CharField(choices=[('disable', "Don't allow"), ('allow', 'Allow'), ('required', 'Required for all lots')], default='allow', help_text='Allow users to set a minimum bid on their lots', max_length=20, verbose_name='Seller set minimum bid'),
),
migrations.AlterField(
model_name='lot',
name='reserve_price',
field=models.PositiveIntegerField(default=2, help_text='Also called a reserve price. Lot will not be sold unless someone bids at least this much', validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(2000)], verbose_name='Minimum bid'),
),
migrations.AlterField(
model_name='pickuplocation',
name='address',
field=models.CharField(blank=True, help_text="Enter an address to search the map below. What you enter here won't be shown to users.", max_length=500, null=True),
),
]
2 changes: 2 additions & 0 deletions auctions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ class Auction(models.Model):
reserve_price.help_text = "Allow users to set a minimum bid on their lots"
tax = models.PositiveIntegerField(default = 0, validators=[MinValueValidator(0)])
tax.help_text = 'Added to invoices for all won lots'
advanced_lot_adding = models.BooleanField(default=False)
advanced_lot_adding.help_text = "Show lot number, quantity and description fields when bulk adding lots"

def __str__(self):
result = self.title
Expand Down
2 changes: 1 addition & 1 deletion auctions/templates/view_lot_images.html
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ <h5>Exchange info</h5>
_="on htmx:afterOnLoad wait 10ms then add .show to #modal then add .show to #modal-backdrop"><i class="bi bi-calendar-x"></i> Remove or refund</button>
{% endif %}
{% if is_auction_admin or lot.user.pk == request.user.pk%}
<a class="btn btn-primary me-2" href="{% url 'single_lot_label' pk=lot.pk %}"><i class="bi bi-tag"></i> {% if lot.label_printed%}Reprint label{% else %}Print label{% endif %}</button>
<a class="btn btn-primary me-2" href="{% url 'single_lot_label' pk=lot.pk %}"><i class="bi bi-tag"></i> {% if lot.label_printed%}Reprint label{% else %}Print label{% endif %}</a>
{% endif %}
{% endif %}
{% if request.user.is_superuser %}
Expand Down
2 changes: 2 additions & 0 deletions auctions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2013,6 +2013,7 @@ def dispatch(self, request, *args, **kwargs):
self.LotFormSet = modelformset_factory(Lot, extra=extra, fields = (
'custom_lot_number',
'lot_name',
'description',
'species_category',
'i_bred_this_fish',
'quantity',
Expand Down Expand Up @@ -2939,6 +2940,7 @@ def form_valid(self, form, **kwargs):
'buy_now',
'reserve_price',
'tax',
'advanced_lot_adding',
]
for field in fields_to_clone:
setattr(auction, field, getattr(original_auction, field))
Expand Down

0 comments on commit 501290a

Please sign in to comment.