diff --git a/games/templates/cotton/icon/refund.html b/games/templates/cotton/icon/refund.html
new file mode 100644
index 0000000..4ff150c
--- /dev/null
+++ b/games/templates/cotton/icon/refund.html
@@ -0,0 +1,8 @@
+
diff --git a/games/urls.py b/games/urls.py
index fab22c6..99c0367 100644
--- a/games/urls.py
+++ b/games/urls.py
@@ -59,6 +59,11 @@ urlpatterns = [
purchase.list_purchases,
name="list_purchases",
),
+ path(
+ "purchase//refund",
+ purchase.refund_purchase,
+ name="refund_purchase",
+ ),
path(
"purchase/related-purchase-by-edition",
purchase.related_purchase_by_edition,
diff --git a/games/views/purchase.py b/games/views/purchase.py
index 7209d79..0d1e467 100644
--- a/games/views/purchase.py
+++ b/games/views/purchase.py
@@ -112,6 +112,15 @@ def list_purchases(request: HttpRequest) -> HttpResponse:
}
if not purchase.date_dropped
else {},
+ {
+ "href": reverse(
+ "refund_purchase", args=[purchase.pk]
+ ),
+ "slot": Icon("refund"),
+ "title": "Mark as refunded",
+ }
+ if not purchase.date_refunded
+ else {},
{
"href": reverse(
"edit_purchase", args=[purchase.pk]
@@ -206,6 +215,14 @@ def drop_purchase(request: HttpRequest, purchase_id: int) -> HttpResponse:
return redirect("list_sessions")
+@login_required
+def refund_purchase(request: HttpRequest, purchase_id: int) -> HttpResponse:
+ purchase = get_object_or_404(Purchase, id=purchase_id)
+ purchase.date_refunded = timezone.now()
+ purchase.save()
+ return redirect("list_sessions")
+
+
def related_purchase_by_edition(request: HttpRequest) -> HttpResponse:
edition_id = request.GET.get("edition")
if not edition_id: