Allow deleting purchasesp
Django CI/CD / test (push) Successful in 57s Details
Django CI/CD / build-and-push (push) Successful in 2m14s Details

This commit is contained in:
Lukáš Kucharczyk 2024-04-29 16:20:44 +02:00
parent edc1d062bc
commit 0f080f5316
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
4 changed files with 18 additions and 0 deletions

View File

@ -4,6 +4,7 @@
* Render notes as Markdown
* Require login by default
* Add stats for dropped purchases, monthly playtimes
* Allow deleting purchases
## Improved
* mark refunded purchases red on game overview

View File

@ -22,6 +22,12 @@
value="Submit & Create Session" />
</td>
</tr>
<tr>
<td></td>
<td>
<a href="{% url 'delete_purchase' purchase_id %}" class="text-red-600" onclick="return confirm('Are you sure you want to delete this purchase?');">Delete</a>
</td>
</tr>
</table>
</form>
{% endblock content %}

View File

@ -47,6 +47,11 @@ urlpatterns = [
# views.delete_session,
# name="delete_session",
# ),
path(
"purchase/<int:purchase_id>/delete",
views.delete_purchase,
name="delete_purchase",
),
path("add-purchase/", views.add_purchase, name="add_purchase"),
path(
"add-purchase-for-edition/<int:edition_id>",

View File

@ -129,6 +129,7 @@ def edit_purchase(request, purchase_id=None):
return redirect("list_sessions")
context["title"] = "Edit Purchase"
context["form"] = form
context["purchase_id"] = purchase_id
context["script_name"] = "add_purchase.js"
return render(request, "add_purchase.html", context)
@ -590,6 +591,11 @@ def stats(request, year: int = 0):
request.session["return_path"] = request.path
return render(request, "stats.html", context)
@login_required
def delete_purchase(request, purchase_id=None):
purchase = get_object_or_404(Purchase, id=purchase_id)
purchase.delete()
return redirect("list_sessions")
@login_required
def add_purchase(request, edition_id=None):