Skip to content

Commit

Permalink
Merge pull request #246 from iragm/misc-fixes
Browse files Browse the repository at this point in the history
Misc fixes
  • Loading branch information
iragm authored Oct 18, 2024
2 parents 716d801 + 0f5a092 commit c1906e6
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 24 deletions.
2 changes: 1 addition & 1 deletion auctions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ def __init__(self, user, auction, *args, **kwargs):
if location.pickup_by_mail:
self.fields["i_agree"].label = "Yes, mail me my lots"
else:
self.fields["i_agree"].label = f"Yes, I will be at {location}"
self.fields["i_agree"].label = "Yes, I will be at this auction"

class Meta:
model = AuctionTOS
Expand Down
2 changes: 1 addition & 1 deletion auctions/management/commands/weekly_promo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def handle(self, *args, **options):
# get any users who have opted into the weekly email
exclude_newer_than = timezone.now() - datetime.timedelta(days=6)
exclude_older_than = timezone.now() - datetime.timedelta(days=400)
in_person_auctions_cutoff = timezone.now() + datetime.timedelta(days=14)
in_person_auctions_cutoff = timezone.now() + datetime.timedelta(days=7)
users = (
User.objects.filter(
Q(userdata__email_me_about_new_in_person_auctions=True)
Expand Down
38 changes: 38 additions & 0 deletions auctions/migrations/0158_alter_pickuplocation_name_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 5.1 on 2024-10-18 00:39

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("auctions", "0157_userlabelprefs_print_border_and_more"),
]

operations = [
migrations.AlterField(
model_name="pickuplocation",
name="name",
field=models.CharField(
blank=True,
default="",
help_text="Location name shown to users. e.x. University Mall in VT",
max_length=70,
null=True,
),
),
migrations.AlterField(
model_name="userlabelprefs",
name="preset",
field=models.CharField(
choices=[
("sm", "Small (Avery 5160) (Not recommended)"),
("lg", "Large (Avery 18262)"),
("thermal_sm", 'Thermal 3"x2"'),
("custom", "Custom"),
],
default="lg",
max_length=20,
verbose_name="Label size",
),
),
]
2 changes: 1 addition & 1 deletion auctions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ class PickupLocation(models.Model):
A given auction can have multiple pickup locations
"""

name = models.CharField(max_length=50, default="", blank=True, null=True)
name = models.CharField(max_length=70, default="", blank=True, null=True)
name.help_text = "Location name shown to users. e.x. University Mall in VT"
user = models.ForeignKey(User, null=True, blank=True, on_delete=models.SET_NULL)
auction = models.ForeignKey(Auction, null=True, blank=True, on_delete=models.CASCADE)
Expand Down
4 changes: 2 additions & 2 deletions auctions/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,14 @@ def render_auction(self, value, record):
auction = record
result = f"<a href='{auction.get_absolute_url()}'>{auction.title}</a><br class='d-md-none'>"
if auction.is_last_used:
result += " <span class='ms-1 badge bg-light text-black'>Your last auction</span>"
result += " <span class='ms-1 badge bg-success text-black'>Your last auction</span>"
if auction.is_online:
result += " <span class='badge bg-info'>Online</span>"
if not auction.promote_this_auction:
result += " <span class='badge bg-dark'>Not promoted</span>"
if auction.distance:
result += f" <span class='badge bg-primary'>{int(auction.distance)} miles from you</span>"
if auction.joined:
if auction.joined and not auction.is_last_used:
result += " <span class='badge bg-success text-black'>Joined</span>"
result += auction.template_lot_link_first_column + auction.template_promo_info
return mark_safe(result)
Expand Down
6 changes: 5 additions & 1 deletion auctions/templates/invoice.html
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ <h3>Lots purchased</h3>
{% if auction.multi_location %}
<th scope="col">Location</th>
{% endif %}
{% if is_admin %}
<th scope="col">Seller</th>
{% endif %}
<th scope="col">Price</th>
</tr>
</thead>
Expand Down Expand Up @@ -342,8 +344,9 @@ <h3>Lots purchased</h3>
{% if auction.multi_location %}
<td>{{ lot.location }}</td>
{% endif %}
{% if is_admin %}
<td>
{% if show_links and is_admin %}
{% if show_links %}
<a href="#" hx-get="/api/auctiontos/{{lot.auctiontos_seller.pk}}"
hx-target="#modals-here"
hx-trigger="click">
Expand All @@ -353,6 +356,7 @@ <h3>Lots purchased</h3>
{{ lot.seller_name }}
{% endif %}
</td>
{% endif %}
<td>
${{ lot.final_price|floatformat:2 }}
</td>
Expand Down
11 changes: 8 additions & 3 deletions auctions/templates/view_lot_images.html
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ <h3>{{ lot.lot_name }}</h3>
{% endif %}
{% endif %}
{% endif %}
{% if showExchangeInfo %}
{% if show_exchange_info %}
<a name="exchangeinfo"></a>
<h5>Exchange info</h5>
<table class="table">
Expand All @@ -399,8 +399,13 @@ <h5>Exchange info</h5>
hx-target="#modals-here" hx-trigger="click">{{ lot.seller_name }}</a> {% else %} {{ lot.seller_name }} {% endif %}({{ lot.seller_email | urlize }})<br> <small>{{ lot.location }}</small> <a href="{{ lot.seller_invoice_link }}">Seller's invoice</a></td>
</tr>
<tr>
<td><b>Winner:</b></td><td>{% if is_auction_admin %}<a href="#" hx-get="/api/auctiontos/{{lot.auctiontos_winner.pk}}"
hx-target="#modals-here" hx-trigger="click">{{ lot.winner_name }}</a> {% else %} {{ lot.winner_name }} {% endif %} ({{ lot.winner_email | urlize }})<br><small>{{ lot.winner_location }}</small> <a href="{{ lot.winner_invoice_link }}">Winner's invoice</a></td>
<td><b>Winner:</b></td><td>
{% if is_auction_admin %}<a href="#" hx-get="/api/auctiontos/{{lot.auctiontos_winner.pk}}"
hx-target="#modals-here" hx-trigger="click">{{ lot.winner_name }}</a>
{% else %}
{{ lot.winner_name }}
{% endif %}
{% if lot.winner_email and is_auction_admin %}({{ lot.winner_email | urlize }}){% endif %}<br><small>{{ lot.winner_location }}</small> {% if is_auction_admin %}<a href="{{ lot.winner_invoice_link }}">Winner's invoice</a>{% endif %}</td>
</tr>
</table>
{% endif %}
Expand Down
30 changes: 15 additions & 15 deletions auctions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2973,10 +2973,9 @@ def get_context_data(self, **kwargs):
context["distance"] = 0
# for lots that are part of an auction, it's very handy to show the exchange info right on the lot page
# this should be visible only to people running the auction or the seller
if lot.auction:
if lot.auction and lot.auction.is_online and lot.sold:
if context["is_auction_admin"] or self.request.user == lot.user:
if lot.sold:
context["showExchangeInfo"] = True
context["show_exchange_info"] = True
context["show_image_add_button"] = lot.image_permission_check(self.request.user)
# chat subscription stuff
if self.request.user.is_authenticated:
Expand All @@ -3003,7 +3002,7 @@ def get_context_data(self, **kwargs):
and self.request.user.is_authenticated
and self.request.user.email == lot.auctiontos_winner.email
) or (lot.winner and self.request.user.is_authenticated and self.request.user == lot.winner):
if lot.winner_feedback_rating == 0 and timezone.now() > lot.date_end + timedelta(days=2):
if lot.feedback_rating == 0 and timezone.now() > lot.date_end + timedelta(days=2):
context["show_feedback_dialog"] = True
return context

Expand Down Expand Up @@ -3835,6 +3834,7 @@ def form_valid(self, form, **kwargs):
"allow_deleting_bids",
"auto_add_images",
"message_users_when_lots_sell",
"label_print_fields",
]
for field in fields_to_clone:
setattr(auction, field, getattr(original_auction, field))
Expand Down Expand Up @@ -4161,17 +4161,17 @@ def tos_check(request, auction, routeByLastAuction):
# if not, check and see if the user has been participating in an auction
try:
auction = UserData.objects.get(user=request.user).last_auction_used
if timezone.now() > auction.date_end:
try:
invoice = Invoice.objects.get(auctiontos_user__user=request.user, auction=auction)
messages.info(
request,
f'{auction} has ended. <a href="/invoices/{invoice.pk}">View your invoice</a>, <a href="/feedback/">leave feedback</a> on lots you bought or sold, or <a href="/lots?auction={auction.slug}">view lots</a>',
)
return redirect("/lots/")
except:
pass
auction = None
invoice = (
Invoice.objects.filter(auctiontos_user__user=request.user, auctiontos_user__auction=auction)
.exclude(status="DRAFT")
.first()
)
if invoice:
messages.info(
request,
f'{auction} has ended. <a href="/invoices/{invoice.pk}">View your invoice</a> or <a href="/feedback/">leave feedback</a> on lots you bought or sold',
)
return redirect("/lots/")
else:
try:
# in progress online auctions get routed
Expand Down

0 comments on commit c1906e6

Please sign in to comment.