Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated method argument #844

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/order/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/order/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/order/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down