Fix #180 -- Hide add to cart button if no products active or no quantity left (#200)

* Hide add to cart button if no products active or no quantity left(#180)

* Fix PEP errors and improve logic

* Fix tests for add to cart change

* Fix the logic for toggling the visibility of Add to Cart button
This commit is contained in:
Vishal Sodani
2016-08-29 23:00:08 +05:30
committed by Raphael Michel
parent 6108aa880a
commit 5346473f75
3 changed files with 9 additions and 4 deletions

View File

@@ -55,6 +55,7 @@ class ItemDisplayTest(EventTestMixin, SoupTest):
q.items.add(item)
html = self.client.get('/%s/%s/' % (self.orga.slug, self.event.slug))
self.assertNotIn("Early-bird", html)
self.assertNotIn('checkout-button-row', html)
def test_without_category(self):
q = Quota.objects.create(event=self.event, name='Quota', size=2)
@@ -62,6 +63,7 @@ class ItemDisplayTest(EventTestMixin, SoupTest):
q.items.add(item)
doc = self.get_doc('/%s/%s/' % (self.orga.slug, self.event.slug))
self.assertIn("Early-bird", doc.select("section .product-row")[0].text)
self.assertIn("Add to cart", doc.select("div button")[0].text)
def test_timely_available(self):
q = Quota.objects.create(event=self.event, name='Quota', size=2)
@@ -217,7 +219,7 @@ class DeadlineTest(EventTestMixin, TestCase):
)
self.assertEqual(response.status_code, 200)
self.assertNotIn('alert-info', response.rendered_content)
self.assertIn('checkout-button-row', response.rendered_content)
self.assertNotIn('checkout-button-row', response.rendered_content)
response = self.client.post(
'/%s/%s/cart/add' % (self.orga.slug, self.event.slug),
{
@@ -235,7 +237,7 @@ class DeadlineTest(EventTestMixin, TestCase):
)
self.assertEqual(response.status_code, 200)
self.assertNotIn('alert-info', response.rendered_content)
self.assertIn('checkout-button-row', response.rendered_content)
self.assertNotIn('checkout-button-row', response.rendered_content)
response = self.client.post(
'/%s/%s/cart/add' % (self.orga.slug, self.event.slug),
{