diff --git a/games/templates/cotton/icon/checkmark.html b/games/templates/cotton/icon/checkmark.html
new file mode 100644
index 0000000..5dc1e9c
--- /dev/null
+++ b/games/templates/cotton/icon/checkmark.html
@@ -0,0 +1,8 @@
+
diff --git a/games/urls.py b/games/urls.py
index 99c0367..edd5def 100644
--- a/games/urls.py
+++ b/games/urls.py
@@ -54,6 +54,11 @@ urlpatterns = [
purchase.delete_purchase,
name="delete_purchase",
),
+ path(
+ "purchase//finish",
+ purchase.finish_purchase,
+ name="finish_purchase",
+ ),
path(
"purchase/list",
purchase.list_purchases,
diff --git a/games/views/purchase.py b/games/views/purchase.py
index 0ebddf3..d7c06d7 100644
--- a/games/views/purchase.py
+++ b/games/views/purchase.py
@@ -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: