From d2d2a1b0ecddfeb59c62e64610449031aa81e4fd Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Fri, 1 Apr 2016 16:17:46 +1100 Subject: [PATCH] Work for making invoices contain complete profile information --- registrasion/models.py | 5 +++++ registrasion/views.py | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/registrasion/models.py b/registrasion/models.py index c841ffae..d9ddfc1e 100644 --- a/registrasion/models.py +++ b/registrasion/models.py @@ -57,6 +57,11 @@ class BadgeAndProfile(models.Model): except ObjectDoesNotExist: return None + def save(self): + if not self.name_per_invoice: + self.name_per_invoice = self.name + super(BadgeAndProfile, self).save() + attendee = models.OneToOneField(Attendee, on_delete=models.CASCADE) # Things that appear on badge diff --git a/registrasion/views.py b/registrasion/views.py index 1d6eb260..230227c7 100644 --- a/registrasion/views.py +++ b/registrasion/views.py @@ -12,6 +12,7 @@ from django.contrib import messages from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ValidationError from django.db import transaction +from django.http import Http404 from django.shortcuts import redirect from django.shortcuts import render @@ -335,6 +336,10 @@ def invoice(request, invoice_id): invoice_id = int(invoice_id) inv = rego.Invoice.objects.get(pk=invoice_id) + + if request.user != inv.cart.user and not request.user.is_staff: + raise Http404() + current_invoice = InvoiceController(inv) data = { @@ -350,11 +355,10 @@ def pay_invoice(request, invoice_id): WORK IN PROGRESS FUNCTION. Must be replaced with real payment workflow. ''' - invoice_id = int(invoice_id) inv = rego.Invoice.objects.get(pk=invoice_id) current_invoice = InvoiceController(inv) - if not inv.paid and current_invoice.is_valid(): + if not current_invoice.invoice.paid and not current_invoice.invoice.void: current_invoice.pay("Demo invoice payment", inv.value) return redirect("invoice", current_invoice.invoice.id)