Skip to content

Commit

Permalink
Merge pull request santropolroulant#109 from guillaumep/fix_orders
Browse files Browse the repository at this point in the history
Fix routing generation when generating in advance
  • Loading branch information
guillaumep authored Feb 24, 2024
2 parents 7986a79 + 961d9eb commit f73572c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

setuptools.setup(
name="souschef",
version="1.3.8dev2",
version="1.3.8dev3",
license="AGPL-3.0",
author="Santropol Roulant and Savoir Faire Linux",
author_email="[email protected]",
description="Webapp used to manage orders for meals-on-wheel delivery",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/pypa/sous-chef",
url="https://github.com/santropolroulant/sous-chef",
packages=setuptools.find_packages(),
include_package_data=True,
classifiers=[
Expand Down
4 changes: 2 additions & 2 deletions souschef/delivery/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def get(self, request, *args, **kwargs):
all_configured = True
for route in routes:
clients = Order.objects.get_shippable_orders_by_route(
route.id, exclude_non_geolocalized=True
route.id, delivery_date, exclude_non_geolocalized=True
).values_list("client__pk", flat=True)
order_count = len(clients)
try:
Expand Down Expand Up @@ -470,7 +470,7 @@ def post(self, request, pk, *args, **kwargs):
delivery_date = date.fromisoformat(request.POST["delivery_date"])
route = get_object_or_404(Route, pk=pk)
if not Order.objects.get_shippable_orders_by_route(
route.id, exclude_non_geolocalized=True
route.id, delivery_date, exclude_non_geolocalized=True
).exists():
# No clients on this route.
raise Http404
Expand Down
10 changes: 3 additions & 7 deletions souschef/member/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ def dispatch(self, request, *args, **kwargs):
non_i18n_step = i18n_step
finally:
kwargs["step"] = non_i18n_step
return super().dispatch(
request, *args, **kwargs
)
return super().dispatch(request, *args, **kwargs)

def get_step_url(self, step):
"""
Expand Down Expand Up @@ -952,9 +950,7 @@ class ClientUpdateRelationshipsInformation(ClientUpdateInformation):
prefix = "relationships"

def get_context_data(self, **kwargs):
context = super().get_context_data(
**kwargs
)
context = super().get_context_data(**kwargs)
context.update({"current_step": "relationships"})
context.update({"pk": self.kwargs["pk"]})
context["step_template"] = "client/partials/forms/" "relationships.html"
Expand Down Expand Up @@ -1355,7 +1351,7 @@ def get_clients_on_delivery_history(delivery_history, func_add_warning_message=N
"""
orders = Order.objects.get_shippable_orders_by_route(
delivery_history.route.pk,
delivery_date=delivery_history.date,
delivery_history.date,
exclude_non_geolocalized=True,
).select_related("client", "client__member", "client__member__address")
clients = []
Expand Down
2 changes: 1 addition & 1 deletion souschef/order/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def get_shippable_orders(self, delivery_date=None, exclude_non_geolocalized=Fals
)

def get_shippable_orders_by_route(
self, route_id, delivery_date=None, exclude_non_geolocalized=False
self, route_id, delivery_date, exclude_non_geolocalized=False
):
"""
Return the orders ready to be delivered for a given route.
Expand Down
4 changes: 3 additions & 1 deletion souschef/order/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def test_get_shippable_orders_by_route(self):
A shippable order must be created in the database, and its ORDER_STATUS
must be 'O' (Ordered).
"""
orders = Order.objects.get_shippable_orders_by_route(self.route.id)
orders = Order.objects.get_shippable_orders_by_route(
self.route.id, date.today()
)
self.assertEqual(
len(orders),
len(self.orders) + len(self.paused_orders),
Expand Down

0 comments on commit f73572c

Please sign in to comment.