Allow deleting purchasesp
This commit is contained in:
parent
edc1d062bc
commit
0f080f5316
|
@ -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
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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>",
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue