Permalink
Browse files

replaced loop by direct update

  • Loading branch information...
lamontfr committed Dec 12, 2017
1 parent bb5c3e2 commit 0c54266d0d1a4d4558baf1354f30007928739ff9
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/order/management/commands/setordersdelivered.py
@@ -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(
@@ -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.