Skip to content

Commit

Permalink
replaced loop by direct update
Browse files Browse the repository at this point in the history
  • Loading branch information
lamontfr committed Dec 12, 2017
1 parent bb5c3e2 commit 0c54266
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/order/management/commands/setordersdelivered.py
Expand Up @@ -19,12 +19,12 @@ def handle(self, *args, **options):
options['delivery_date'], '%Y-%m-%d'
).date()

orders = Order.objects.filter(
numorders = Order.objects.filter(
status=ORDER_STATUS_ORDERED,
delivery_date=delivery_date)
for order in orders:
order.status = ORDER_STATUS_DELIVERED
order.save()
delivery_date=delivery_date
).update(
status=ORDER_STATUS_DELIVERED
)

# Log the execution
LogEntry.objects.log_action(
Expand All @@ -35,4 +35,4 @@ def handle(self, *args, **options):
action_flag=ADDITION,
)
print("Status set to Delivered for {0} orders whose "
"delivery date is {1}.".format(len(orders), delivery_date))
"delivery date is {1}.".format(numorders, delivery_date))

0 comments on commit 0c54266

Please sign in to comment.