Always abandon refunded games
This commit is contained in:
@@ -7,12 +7,9 @@
|
|||||||
</p>
|
</p>
|
||||||
<form class="" hx-post="{% url 'games:refund_purchase' purchase_id %}" hx-target="#purchase-row-{{ purchase_id }}" hx-swap="outerHTML">
|
<form class="" hx-post="{% url 'games:refund_purchase' purchase_id %}" hx-target="#purchase-row-{{ purchase_id }}" hx-swap="outerHTML">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="mt-5 text-center">
|
<p class="dark:text-white text-center mt-3 text-sm">
|
||||||
<label class="flex flex-row items-center justify-center align-baseline gap-5">
|
Games will be marked as abandoned.
|
||||||
<input type="checkbox" name="set_abandoned" class="form-checkbox h-5 w-5 text-blue-600">
|
</p>
|
||||||
<span class="text-gray-700 dark:text-gray-500 underline decoration-dotted" title="Set the status of all games associated with this purchase to 'Abandoned'">Set status to 'Abandoned'</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="items-center mt-5">
|
<div class="items-center mt-5">
|
||||||
<c-button color="blue" size="lg" type="submit" class="w-full">Refund</c-button>
|
<c-button color="blue" size="lg" type="submit" class="w-full">Refund</c-button>
|
||||||
<c-button color="gray" size="base" class="mt-0 w-full" onclick="this.closest('#refund-confirmation-modal').remove()">Cancel</c-button>
|
<c-button color="gray" size="base" class="mt-0 w-full" onclick="this.closest('#refund-confirmation-modal').remove()">Cancel</c-button>
|
||||||
|
|||||||
@@ -212,10 +212,9 @@ def refund_purchase_confirmation(
|
|||||||
def refund_purchase(request: HttpRequest, purchase_id: int) -> HttpResponse:
|
def refund_purchase(request: HttpRequest, purchase_id: int) -> HttpResponse:
|
||||||
purchase = get_object_or_404(Purchase, id=purchase_id)
|
purchase = get_object_or_404(Purchase, id=purchase_id)
|
||||||
|
|
||||||
if request.POST.get("set_abandoned"):
|
for game in purchase.games.all():
|
||||||
for game in purchase.games.all():
|
game.status = Game.Status.ABANDONED
|
||||||
game.status = Game.Status.ABANDONED
|
game.save()
|
||||||
game.save()
|
|
||||||
|
|
||||||
purchase.refund()
|
purchase.refund()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user