Changeset - 67b047e7b30e
[Not reviewed]
0 1 0
Christopher Neugebauer - 8 years ago 2016-04-24 21:20:41
chrisjrn@gmail.com
Simplifies invoice-getting documentation.
1 file changed with 1 insertions and 4 deletions:
0 comments (0 inline, 0 general)
docs/payments.rst
Show inline comments
...
 
@@ -29,16 +29,13 @@ If the pre-payment check fails, ``InvoiceController`` will raise a Django ``Vali
 

	
 
Our the ``demopay`` view from the ``registrasion-demo`` project implements pre-validation like so::
 

	
 
    from registrasion.controllers.invoice import InvoiceController
 
    from django.core.exceptions import ValidationError
 

	
 
    # Get the Registrasion Invoice model
 
    inv = get_object_or_404(rego.Invoice.objects, pk=invoice_id)
 

	
 
    invoice = InvoiceController(inv)
 
    invoice = InvoiceController.for_id_or_404(invoice.id)
 

	
 
    try:
 
        invoice.validate_allowed_to_pay()  # Verify that we're allowed to do this.
 
    except ValidationError as ve:
 
        messages.error(request, ve.message)
 
        return REDIRECT_TO_INVOICE  # And display the validation message.
0 comments (0 inline, 0 general)