forked from CGM_Public/pretix_original
Fixed bug when modifying an expired cart including a voucher
This commit is contained in:
@@ -61,7 +61,7 @@ def _re_add_expired_positions(items: List[dict], event: Event, cart_id: str, now
|
|||||||
'count': 1,
|
'count': 1,
|
||||||
'price': cp.price,
|
'price': cp.price,
|
||||||
'cp': cp,
|
'cp': cp,
|
||||||
'voucher': cp.voucher
|
'voucher': cp.voucher.code
|
||||||
})
|
})
|
||||||
positions.add(cp)
|
positions.add(cp)
|
||||||
return positions
|
return positions
|
||||||
|
|||||||
@@ -450,6 +450,18 @@ class CartTest(CartTestMixin, TestCase):
|
|||||||
self.assertIsNone(objs[0].variation)
|
self.assertIsNone(objs[0].variation)
|
||||||
self.assertEqual(objs[0].price, 23)
|
self.assertEqual(objs[0].price, 23)
|
||||||
|
|
||||||
|
def test_voucher_expired_readd(self):
|
||||||
|
v = Voucher.objects.create(item=self.ticket, event=self.event, block_quota=True)
|
||||||
|
cp1 = CartPosition.objects.create(
|
||||||
|
event=self.event, cart_id=self.session_key, item=self.ticket,
|
||||||
|
price=23, expires=now() - timedelta(minutes=10), voucher=v
|
||||||
|
)
|
||||||
|
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||||
|
'variation_%d_%d' % (self.shirt.id, self.shirt_red.id): '1'
|
||||||
|
}, follow=True)
|
||||||
|
obj = CartPosition.objects.get(id=cp1.id)
|
||||||
|
self.assertGreater(obj.expires, now())
|
||||||
|
|
||||||
def test_voucher_variation(self):
|
def test_voucher_variation(self):
|
||||||
v = Voucher.objects.create(item=self.shirt, variation=self.shirt_red, event=self.event)
|
v = Voucher.objects.create(item=self.shirt, variation=self.shirt_red, event=self.event)
|
||||||
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
|
||||||
|
|||||||
Reference in New Issue
Block a user