Skip to content

Commit

Permalink
feat: tell user that the invoice has been paid
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Nov 20, 2024
1 parent 3edab69 commit 685711e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions weblate_web/invoices/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

from typing import TYPE_CHECKING

from django.contrib import messages
from django.contrib.auth.decorators import login_required, user_passes_test
from django.db import transaction
from django.http import FileResponse, Http404
from django.shortcuts import get_object_or_404, redirect
from django.utils.translation import gettext

from .models import Invoice, InvoiceKind

Expand All @@ -32,6 +34,15 @@ def pay_invoice(request: AuthenticatedHttpRequest, pk: str):
Invoice, pk=pk, kind=InvoiceKind.INVOICE, paid_payment_set=None
)
if not invoice.can_be_paid():
if invoice.paid_payment_set.exists():
messages.info(
request,
gettext(
"This invoice has already been paid. Please sign in to view details."
),
)
return redirect("home")

raise Http404("Cannot be paid")
if invoice.draft_payment_set.exists():
payment = invoice.draft_payment_set.all()[0]
Expand Down

0 comments on commit 685711e

Please sign in to comment.