Chapter 10 - #35
Chapter 10#35sabderemane wants to merge 2 commits into
Conversation
sabderemane
commented
Jul 29, 2026
- Update to Django 6
- addition. of HTMX with template partials
| valid_to = models.DateTimeField() | ||
| discount = models.IntegerField( | ||
| validators=[MinValueValidator(0), MaxValueValidator(100)], | ||
| help_text='Percentage vaule (0 to 100)', |
There was a problem hiding this comment.
| help_text='Percentage vaule (0 to 100)', | |
| help_text='Percentage value (0 to 100)', |
| order = Order.objects.get(id=session.client_reference_id) | ||
| except Order.DoesNotExist: | ||
| return HttpResponse(status=404) | ||
| # mark order as paid |
There was a problem hiding this comment.
Stripe works on an "at-least-once" delivery so this could run multiple times (docs)
Fix: Add if order.paid: return HttpResponse(status=200) before processing.
| del self.cart[product_id] | ||
| self.save() | ||
|
|
||
| def clear(self): |
There was a problem hiding this comment.
Minor thing, but the coupon isn't cleared from the session so it's unlimited use?
| tmp_key, 0, -1, desc=True | ||
| )[:max_results] | ||
| # remove the temporary key | ||
| r.delete(tmp_key) |
There was a problem hiding this comment.
Maybe not a concern at this scale, but with concurrency of a proper application, multiple requests at the same time with the same products would generate the same key.
Append uuid.uuid4().hex to make the key unique per request.
|
I've also an issue caused by weasyprint it seems; I'm not sure if we can flag somewhere the need for system setup to allow this to work. |