Adds initial credit note display view

This commit is contained in:
Christopher Neugebauer 2016-04-11 12:11:14 +10:00
parent 2c94e7538a
commit 680ce689f6
2 changed files with 22 additions and 0 deletions

View file

@ -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$",

View file

@ -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)