From dc64f4f956d6b32b5aded7be5bc0f889e8358c03 Mon Sep 17 00:00:00 2001 From: Emmanuel Milou Date: Thu, 4 Apr 2019 14:20:27 -0400 Subject: [PATCH] Remove deprecated method arg --- src/order/models.py | 20 +++++++++++++++----- src/order/tests.py | 4 ++-- src/order/views.py | 3 +-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/order/models.py b/src/order/models.py index ddf93f40..bdc3bd0b 100644 --- a/src/order/models.py +++ b/src/order/models.py @@ -203,7 +203,20 @@ def auto_create_orders(self, delivery_date, clients): return created_orders def create_batch_orders(self, delivery_dates, client, items, - override_dates=[], return_created_orders=False): + override_dates=[]): + """ + Create orders for one or multiple days, for a given client. + Order items will be created based on client's meals schedule. + + Parameters: + delivery_dates : dates on which orders are to be created + client : a client object + items: the order items + override_dates: dates on which existing orders can be overriden + + Returns: + An array of created orders. + """ created_orders = [] messages = [] @@ -238,10 +251,7 @@ def create_batch_orders(self, delivery_dates, client, items, ) created_orders.append(order) - if not return_created_orders: - return len(created_orders) # LXYANG: TO BE DEPRECATED - else: - return created_orders + return created_orders @transaction.atomic def create_order(self, delivery_date, client, items, prices): diff --git a/src/order/tests.py b/src/order/tests.py index 880da6e7..6e177321 100644 --- a/src/order/tests.py +++ b/src/order/tests.py @@ -614,9 +614,9 @@ def test_create_batch_orders(self): Provide a client, 4 delivery dates. """ client = self.episodic_client[0] - counter = Order.objects.create_batch_orders( + created_orders = Order.objects.create_batch_orders( self.delivery_dates, self.episodic_client[0], self.orditems) - self.assertEqual(counter, 4) + self.assertEqual(len(created_orders), 4) # check items # 2016-12-12 diff --git a/src/order/views.py b/src/order/views.py index 6175f9ac..649d2ded 100644 --- a/src/order/views.py +++ b/src/order/views.py @@ -249,8 +249,7 @@ def form_valid(self, form): # Place orders using posted datas created_orders = Order.objects.create_batch_orders( - del_dates, client, items, override_dates=ovr_dates, - return_created_orders=True + del_dates, client, items, override_dates=ovr_dates ) # check created and uncreated dates