Beispiel #1
0
 def process_one(self, request, order=None):
     if order is not None:
         if all_in_stock(order) and create_picklist(order):
             self.message_user(request, 'One order was processed!')
         else:
             self.message_user(request, 'No orders were processed!')
     else:
         return None
Beispiel #2
0
 def process_one(self, request, order=None):
     if order is not None:
         if all_in_stock(order) and create_picklist(order):
             self.message_user(request, 'One order was processed!')
         else:
             self.message_user(request, 'No orders were processed!')
     else:
         return None
Beispiel #3
0
 def test_create_picklist(self):
     # confirm both jars are marked active and available
     sip1a = Product.active.get(slug="sip-1-a")
     self.assertEqual(sip1a.jar_set.filter(is_active=True).count(), 14)
     self.assertEqual(sip1a.jar_set.filter(is_available=True).count(), 14)
     # generate valid picklist from order #1
     picklist = create_picklist(self.order)
     self.assertEqual(sip1a.jar_set.filter(is_available=True).count(), 12)
     self.assertEqual(picklist.status, PickList.SUBMITTED)
     self.assertEqual(self.order.status, Order.PROCESSED)
     # try to generate another picklist from order #1
     # (should fail as status should have changed)
     picklist_again = create_picklist(self.order)
     self.assertEqual(picklist_again, None)
     # try to generate picklist from order #2
     # (should fail as no product exists)
     order2 = Order.objects.all()[1]
     picklist2 = create_picklist(order2)
     self.assertEqual(picklist2, None)
Beispiel #4
0
 def test_create_picklist(self):
     # confirm both jars are marked active and available
     sip1a = Product.active.get(slug='sip-1-a')
     self.assertEqual(sip1a.jar_set.filter(is_active=True).count(), 14)
     self.assertEqual(sip1a.jar_set.filter(is_available=True).count(), 14)
     # generate valid picklist from order #1
     picklist = create_picklist(self.order)
     self.assertEqual(sip1a.jar_set.filter(is_available=True).count(), 12)
     self.assertEqual(picklist.status, PickList.SUBMITTED)
     self.assertEqual(self.order.status, Order.PROCESSED)
     # try to generate another picklist from order #1
     # (should fail as status should have changed)
     picklist_again = create_picklist(self.order)
     self.assertEqual(picklist_again, None)
     # try to generate picklist from order #2
     # (should fail as no product exists)
     order2 = Order.objects.all()[1]
     picklist2 = create_picklist(order2)
     self.assertEqual(picklist2, None)
Beispiel #5
0
 def make_processed(self, request, queryset):
     orders_processed = 0
     for order in queryset:
         # do not create picklists unless all products are in stock
         if (all_in_stock(order) and create_picklist(order)):
             orders_processed += 1
     if orders_processed == 0:
         self.message_user(request, 'No orders were processed!')
     else:
         if orders_processed == 1:
             self.message_user(request, 'One order was processed!')
         else:
             self.message_user(request, '%d orders were processed!' % orders_processed)
Beispiel #6
0
 def make_processed(self, request, queryset):
     orders_processed = 0
     for order in queryset:
         # do not create picklists unless all products are in stock
         if (all_in_stock(order) and create_picklist(order)):
             orders_processed += 1
     if orders_processed == 0:
         self.message_user(request, 'No orders were processed!')
     else:
         if orders_processed == 1:
             self.message_user(request, 'One order was processed!')
         else:
             self.message_user(request, '%d orders were processed!' % orders_processed)
Beispiel #7
0
 def test_cancel_picklist(self):
     # confirm both jars are marked available and active
     sip1a = Product.active.get(slug="sip-1-a")
     self.assertEqual(sip1a.jar_set.filter(is_active=True).count(), 14)
     self.assertEqual(sip1a.jar_set.filter(is_available=True).count(), 14)
     # generate valid picklist from order #1
     picklist = create_picklist(self.order)
     # confirm jars are unavailable
     self.assertEqual(sip1a.jar_set.filter(is_available=True).count(), 12)
     retval = cancel_picklist(picklist)
     self.assertEqual(retval, True)
     # check that jars are available again
     self.assertEqual(sip1a.jar_set.filter(is_available=True).count(), 14)
     # check status of picklist
     self.assertEqual(picklist.status, PickList.CANCELLED)
     # check status of order
     self.assertEqual(self.order.status, Order.SUBMITTED)
Beispiel #8
0
 def test_cancel_picklist(self):
     # confirm both jars are marked available and active
     sip1a = Product.active.get(slug='sip-1-a')
     self.assertEqual(sip1a.jar_set.filter(is_active=True).count(), 14)
     self.assertEqual(sip1a.jar_set.filter(is_available=True).count(), 14)
     # generate valid picklist from order #1
     picklist = create_picklist(self.order)
     # confirm jars are unavailable
     self.assertEqual(sip1a.jar_set.filter(is_available=True).count(), 12)
     retval = cancel_picklist(picklist)
     self.assertEqual(retval, True)
     # check that jars are available again
     self.assertEqual(sip1a.jar_set.filter(is_available=True).count(), 14)
     # check status of picklist
     self.assertEqual(picklist.status, PickList.CANCELLED)
     # check status of order
     self.assertEqual(self.order.status, Order.SUBMITTED)
Beispiel #9
0
 def test_process_picklist(self):
     # confirm both jars are marked available and active
     sip1a = Product.active.get(slug="sip-1-a")
     self.assertEqual(sip1a.jar_set.filter(is_active=True).count(), 14)
     self.assertEqual(sip1a.jar_set.filter(is_available=True).count(), 14)
     # generate valid picklist from order #1
     picklist = create_picklist(self.order)
     retval = process_picklist(picklist)
     self.assertEqual(retval, True)
     # check that jars are no longer active
     self.assertEqual(sip1a.jar_set.filter(is_active=True).count(), 12)
     # check status of picklist
     self.assertEqual(picklist.status, PickList.PROCESSED)
     # check status of order
     self.assertEqual(self.order.status, Order.DELIVERED)
     # process it again
     # (should fail as status should have changed)
     retval2 = process_picklist(picklist)
     self.assertEqual(retval2, False)
Beispiel #10
0
 def test_process_picklist(self):
     # confirm both jars are marked available and active
     sip1a = Product.active.get(slug='sip-1-a')
     self.assertEqual(sip1a.jar_set.filter(is_active=True).count(), 14)
     self.assertEqual(sip1a.jar_set.filter(is_available=True).count(), 14)
     # generate valid picklist from order #1
     picklist = create_picklist(self.order)
     retval = process_picklist(picklist)
     self.assertEqual(retval, True)
     # check that jars are no longer active
     self.assertEqual(sip1a.jar_set.filter(is_active=True).count(), 12)
     # check status of picklist
     self.assertEqual(picklist.status, PickList.PROCESSED)
     # check status of order
     self.assertEqual(self.order.status, Order.DELIVERED)
     # process it again
     # (should fail as status should have changed)
     retval2 = process_picklist(picklist)
     self.assertEqual(retval2, False)