Files @ 2465f2645e2e
Branch filter:

Location: symposion_app/pinaxcon/registrasion/views.py

James Polley
urlize abstracts

I've looked through the database and I can't find any accepted
proposals that actually contain anything to linkify - but I've had
several requests from people that I think are reasonable, things like
being able to link to their project (we ask them to provide a project
url but we don't use that link)

This seems like a reasonably fast way to let those people add a
link. We still have to manually accept changes to their proposal so we
have a chance to look at the content of the url if we want.

The urlize filter adds rel=nofollow to the link automatically.
from django.contrib import messages
from django.core.exceptions import ValidationError
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.shortcuts import redirect

from registrasion import models as rego
from registrasion.controllers.invoice import InvoiceController

from pinaxcon.registrasion import models


def demopay(request, invoice_id, access_code):
    ''' Marks the invoice with the given invoice id as paid.
    '''
    invoice_id = int(invoice_id)
    inv = get_object_or_404(rego.Invoice.objects, pk=invoice_id)

    invoice = InvoiceController(inv)

    if not invoice.can_view(user=request.user, access_code=access_code):
        raise Http404()

    to_invoice = redirect("invoice", invoice.invoice.id, access_code)

    try:
        invoice.validate_allowed_to_pay()  # Verify that we're allowed to do this.
    except ValidationError as ve:
        messages.error(request, ve.message)
        return to_invoice

    # Create the payment object
    models.DemoPayment.objects.create(
        invoice=invoice.invoice,
        reference="Demo payment by user: " + request.user.username,
        amount=invoice.invoice.value,
    )

    invoice.update_status()

    messages.success(request, "This invoice was successfully paid.")

    return to_invoice