Compare commits

..

2 commits

Author SHA1 Message Date
selfhoster1312 ACAB
af08684e35 Merge branch 'feat-distribution-place' into 'develop'
Draft: feature: Add placekey relationship for distribution spots

See merge request la-chariotte/la-chariotte!129
2025-03-04 21:25:12 +00:00
selfhoster1312
96a0404d80 feature: Add place relationship for distribution spots 2025-03-04 22:25:07 +01:00
3 changed files with 14 additions and 47 deletions

View file

@ -26,7 +26,7 @@
{% for place in context.places %} {% for place in context.places %}
<tr> <tr>
<td> <td>
<a title="Détail du lieu de distribution" href="{% url 'order:place_overview' place.code %}">{{ place }}</a> (<a href="{% url 'order:place_update' place.code %}">modifier</a>) <a title="Détail du lieu de distribution" href="{% url 'order:place_update' place.code %}">{{ place }}</a>
</td> </td>
<td> <td>
{% if place.code in context.orders.keys %} {% if place.code in context.orders.keys %}

View file

@ -35,11 +35,13 @@
<i class="fa fa-calendar" aria-hidden="true"></i>&nbsp;&nbsp;<i>Fin des commandes</i> le {{ order.deadline }} <i class="fa fa-calendar" aria-hidden="true"></i>&nbsp;&nbsp;<i>Fin des commandes</i> le {{ order.deadline }}
<br><i class="fa fa-truck" aria-hidden="true"></i>&nbsp;&nbsp;<i>Livraison</i> le {{ order.delivery_date }} <br><i class="fa fa-truck" aria-hidden="true"></i>&nbsp;&nbsp;<i>Livraison</i> le {{ order.delivery_date }}
{% if order.places.all|length > 1 %} {% if order.places.all|length > 1 %}
{#{% counter = order.places.all|length - 1 %}#}
<br><i class="fa fa-building" aria-hidden="true"></i>&nbsp;&nbsp;<i>Autres lieux de livraison:</i> <br><i class="fa fa-building" aria-hidden="true"></i>&nbsp;&nbsp;<i>Autres lieux de livraison:</i>
{% for other_place in order.places.all %} {% for other_place in order.places.all %}
{#{% set counter = counter - 1 %}#}
{% if other_place.code != place.code %} {% if other_place.code != place.code %}
<a href="{% url 'order:place_overview' other_place.code %}">{{ other_place.name }}</a> <a href="{% url 'order:place_overview' other_place.code %}">{{ other_place.name }}</a>
{% if forloop.counter0|add:"2" < order.places.all|length %}, {% endif %} {% if counter > 0 %}, {% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}

View file

@ -294,19 +294,6 @@ class TestPlaceIndexView:
body = response.content.decode() body = response.content.decode()
place1_overview_view_url = reverse(
"order:place_overview",
kwargs={
"code": place1.code,
},
)
place2_overview_view_url = reverse(
"order:place_overview",
kwargs={
"code": place2.code,
},
)
place1_update_view_url = reverse( place1_update_view_url = reverse(
"order:place_update", "order:place_update",
kwargs={ kwargs={
@ -321,12 +308,12 @@ class TestPlaceIndexView:
) )
place1_body_expected = ( place1_body_expected = (
'<a title="Détail du lieu de distribution" href="%s">%s</a> (<a href="%s">modifier</a>)' '<a title="Détail du lieu de distribution" href="%s">%s</a>'
% (place1_overview_view_url, place1.name, place1_update_view_url) % (place1_update_view_url, place1.name)
) )
place2_body_expected = ( place2_body_expected = (
'<a title="Détail du lieu de distribution" href="%s">%s</a> (<a href="%s">modifier</a>)' '<a title="Détail du lieu de distribution" href="%s">%s</a>'
% (place2_overview_view_url, place2.name, place2_update_view_url) % (place2_update_view_url, place2.name)
) )
assert place1_body_expected in body assert place1_body_expected in body
assert place2_body_expected in body assert place2_body_expected in body
@ -361,19 +348,6 @@ class TestPlaceIndexView:
# Strip whitespace so we can examine the HTML without parsing it # Strip whitespace so we can examine the HTML without parsing it
stripped_body = re.sub(r"\s\s+", " ", response.content.decode()) stripped_body = re.sub(r"\s\s+", " ", response.content.decode())
place1_overview_view_url = reverse(
"order:place_overview",
kwargs={
"code": place1.code,
},
)
place2_overview_view_url = reverse(
"order:place_overview",
kwargs={
"code": place2.code,
},
)
place1_update_view_url = reverse( place1_update_view_url = reverse(
"order:place_update", "order:place_update",
kwargs={ kwargs={
@ -401,18 +375,17 @@ class TestPlaceIndexView:
) )
place1_body_expected = ( place1_body_expected = (
'<td> <a title="Détail du lieu de distribution" href="%s">%s</a> (<a href="%s">modifier</a>) </td> <td> <a href="%s">%s</a><br> </td>' '<td> <a title="Détail du lieu de distribution" href="%s">%s</a> </td> <td> <a href="%s">%s</a><br> </td>'
% ( % (
place1_overview_view_url,
place1.name,
place1_update_view_url, place1_update_view_url,
place1.name,
grouped_order1_detail_view_url, grouped_order1_detail_view_url,
grouped_order1.name, grouped_order1.name,
) )
) )
place2_body_expected = ( place2_body_expected = (
'<td> <a title="Détail du lieu de distribution" href="%s">%s</a> (<a href="%s">modifier</a>) </td> <td> Aucune </td> ' '<td> <a title="Détail du lieu de distribution" href="%s">%s</a> </td> <td> Aucune </td> '
% (place2_overview_view_url, place2.name, place2_update_view_url) % (place2_update_view_url, place2.name)
) )
assert place1_body_expected in stripped_body assert place1_body_expected in stripped_body
assert place2_body_expected in stripped_body assert place2_body_expected in stripped_body
@ -453,13 +426,6 @@ class TestPlaceIndexView:
}, },
) )
place_overview_view_url = reverse(
"order:place_overview",
kwargs={
"code": place.code,
},
)
grouped_order1_detail_view_url = reverse( grouped_order1_detail_view_url = reverse(
"order:grouped_order_detail", "order:grouped_order_detail",
kwargs={ kwargs={
@ -474,11 +440,10 @@ class TestPlaceIndexView:
) )
place_body_expected = ( place_body_expected = (
'<td> <a title="Détail du lieu de distribution" href="%s">%s</a> (<a href="%s">modifier</a>) </td> <td> <a href="%s">%s</a><br> <a href="%s">%s</a><br> </td>' '<td> <a title="Détail du lieu de distribution" href="%s">%s</a> </td> <td> <a href="%s">%s</a><br> <a href="%s">%s</a><br> </td>'
% ( % (
place_overview_view_url,
place.name,
place_update_view_url, place_update_view_url,
place.name,
grouped_order2_detail_view_url, grouped_order2_detail_view_url,
grouped_order2.name, grouped_order2.name,
grouped_order1_detail_view_url, grouped_order1_detail_view_url,