finish purchase from list
All checks were successful
Django CI/CD / test (push) Successful in 1m23s
Django CI/CD / build-and-push (push) Successful in 2m4s

This commit is contained in:
2024-09-10 15:04:18 +02:00
parent 37169c4f9b
commit 6f1886bca2
3 changed files with 30 additions and 0 deletions

View File

@ -103,6 +103,15 @@ def list_purchases(request: HttpRequest) -> HttpResponse:
"cotton/button_group.html",
{
"buttons": [
{
"href": reverse(
"finish_purchase", args=[purchase.pk]
),
"slot": Icon("checkmark"),
"title": "Mark as finished",
}
if not purchase.date_finished
else {},
{
"href": reverse(
"drop_purchase", args=[purchase.pk]
@ -223,6 +232,14 @@ def refund_purchase(request: HttpRequest, purchase_id: int) -> HttpResponse:
return redirect("list_purchases")
@login_required
def finish_purchase(request: HttpRequest, purchase_id: int) -> HttpResponse:
purchase = get_object_or_404(Purchase, id=purchase_id)
purchase.date_finished = timezone.now()
purchase.save()
return redirect("list_purchases")
def related_purchase_by_edition(request: HttpRequest) -> HttpResponse:
edition_id = request.GET.get("edition")
if not edition_id: