diff --git a/registrasion/urls.py b/registrasion/urls.py index b927edbf..7b28693e 100644 --- a/registrasion/urls.py +++ b/registrasion/urls.py @@ -6,6 +6,7 @@ urlpatterns = patterns( "registrasion.views", url(r"^category/([0-9]+)$", "product_category", name="product_category"), url(r"^checkout$", "checkout", name="checkout"), + url(r"^credit_note/([0-9]+)$", views.credit_note, name="credit_note"), url(r"^invoice/([0-9]+)$", "invoice", name="invoice"), url(r"^invoice/([0-9]+)/([A-Z0-9]+)$", views.invoice, name="invoice"), url(r"^invoice/([0-9]+)/manual_payment$", diff --git a/registrasion/views.py b/registrasion/views.py index 509473aa..13f1b857 100644 --- a/registrasion/views.py +++ b/registrasion/views.py @@ -4,6 +4,7 @@ from registrasion import forms from registrasion import models as rego from registrasion.controllers import discount from registrasion.controllers.cart import CartController +from registrasion.controllers.credit_note import CreditNoteController from registrasion.controllers.invoice import InvoiceController from registrasion.controllers.product import ProductController from registrasion.exceptions import CartValidationError @@ -545,3 +546,23 @@ def refund(request, invoice_id): messages.error(request, ve) return redirect("invoice", invoice_id) + + +def credit_note(request, note_id, access_code=None): + ''' Displays an credit note for a given id. + This view can only be seen by staff. + ''' + + if not request.user.is_staff: + raise Http404() + + note_id = int(note_id) + note = rego.CreditNote.objects.get(pk=note_id) + + current_note = CreditNoteController(note) + + data = { + "credit_note": current_note.credit_note, + } + + return render(request, "registrasion/credit_note.html", data)