User-facing views¶
View functions¶
Here’s all of the views that Registrasion exposes to the public.
-
class
registrasion.views.
GuidedRegistrationSection
¶ Represents a section of a guided registration page.
-
title
¶ str
The title of the section.
-
discounts
¶ [registrasion.contollers.discount.DiscountAndQuantity, ...]
A list of discount objects that are available in the section. You can display
.clause
to show what the discount applies to, and.quantity
to display the number of times that discount can be applied.
-
description
¶ str
A description of the section.
-
form
¶ forms.Form
A form to display.
-
-
registrasion.views.
checkout
(request, *args, **kwargs)¶ Runs the checkout process for the current cart.
If the query string contains
fix_errors=true
, Registrasion will attempt to fix errors preventing the system from checking out, including by cancelling expired discounts and vouchers, and removing any unavailable products.Returns: If the invoice is generated successfully, or there’s already a valid invoice for the current cart, redirect to invoice
. If there are errors when generating the invoice, renderregistrasion/checkout_errors.html
with the following data:{ "error_list", [str, ...] # The errors to display. }
Return type: render or redirect
-
registrasion.views.
credit_note
(request, *args, **kwargs)¶ Displays a credit note.
If
request
is aPOST
request, forms for applying or refunding a credit note will be processed.This view requires a login, and the logged in user must be staff.
Parameters: note_id (castable to int) – The ID of the credit note to view. Returns: If the “apply to invoice” form is correctly processed, redirect to that invoice, otherwise, render registration/credit_note.html
with the following data:{ "credit_note": models.commerce.CreditNote(), "apply_form": form, # A form for applying credit note # to an invoice. "refund_form": form, # A form for applying a *manual* # refund of the credit note. }
Return type: render or redirect
-
registrasion.views.
edit_profile
(request, *args, **kwargs)¶ View for editing an attendee’s profile
The user must be logged in to edit their profile.
Returns: In the case of a POST
request, it’ll redirect todashboard
, or otherwise, it will renderregistrasion/profile_form.html
with data:{ "form": form, # Instance of ATTENDEE_PROFILE_FORM. }
Return type: redirect or render
-
registrasion.views.
guided_registration
(request, *args, **kwargs)¶ Goes through the registration process in order, making sure user sees all valid categories.
The user must be logged in to see this view.
Returns: Renders registrasion/guided_registration.html
, with the following data:{ "current_step": int(), # The current step in the # registration "sections": sections, # A list of # GuidedRegistrationSections "title": str(), # The title of the page "total_steps": int(), # The total number of steps }
Return type: render
-
registrasion.views.
invoice
(request, invoice_id, access_code=None)¶ Displays an invoice.
This view is not authenticated, but it will only allow access to either: the user the invoice belongs to; staff; or a request made with the correct access code.
Parameters: - invoice_id (castable to int) – The invoice_id for the invoice you want to view.
- access_code (Optional[str]) – The access code for the user who owns this invoice.
Returns: Renders
registrasion/invoice.html
, with the following data:{ "invoice": models.commerce.Invoice(), }
Return type: render
Raises: Http404
– if the current user cannot view this invoice and the correct access_code is not provided.
-
registrasion.views.
invoice_access
(request, access_code)¶ Redirects to an invoice for the attendee that matches the given access code, if any.
If the attendee has multiple invoices, we use the following tie-break:
- If there’s an unpaid invoice, show that, otherwise
- If there’s a paid invoice, show the most recent one, otherwise
- Show the most recent invoid of all
Parameters: access_code (castable to int) – The access code for the user whose invoice you want to see. Returns: Redirect to the selected invoice for that user. Return type: redirect Raises: Http404
– If the user has no invoices.
-
registrasion.views.
manual_payment
(request, *args, **kwargs)¶ Allows staff to make manual payments or refunds on an invoice.
This form requires a login, and the logged in user needs to be staff.
Parameters: invoice_id (castable to int) – The invoice ID to be paid Returns: Renders registrasion/manual_payment.html
with the following data:{ "invoice": models.commerce.Invoice(), "form": form, # A form that saves a ``ManualPayment`` # object. }
Return type: render
-
registrasion.views.
product_category
(request, *args, **kwargs)¶ Form for selecting products from an individual product category.
Parameters: category_id (castable to int) – The id of the category to display. Returns: If the form has been sucessfully submitted, redirect to dashboard
. Otherwise, renderregistrasion/product_category.html
with data:{ "category": category, # An inventory.Category for # category_id "discounts": discounts, # A list of # DiscountAndQuantity "form": products_form, # A form for selecting # products "voucher_form": voucher_form, # A form for entering a # voucher code }
Return type: redirect or render
-
registrasion.views.
refund
(request, *args, **kwargs)¶ Marks an invoice as refunded and requests a credit note for the full amount paid against the invoice.
This view requires a login, and the logged in user must be staff.
Parameters: invoice_id (castable to int) – The ID of the invoice to refund. Returns: Redirects to invoice
.Return type: redirect
Data types¶
-
class
registrasion.controllers.discount.
DiscountAndQuantity
(discount, clause, quantity)¶ Represents a discount that can be applied to a product or category for a given user.
-
discount
¶ conditions.DiscountBase
The discount object that the clause arises from. A given DiscountBase can apply to multiple clauses.
-
clause
¶ conditions.DiscountForProduct|conditions.DiscountForCategory
A clause describing which product or category this discount item applies to. This casts to
str()
to produce a human-readable version of the clause.
-
quantity
¶ int
The number of times this discount item can be applied for the given user.
-
Template tags¶
Registrasion makes template tags available:
Class that holds a product and a quantity.
models.inventory.Product
int
Gets all of the currently available products.
Returns: A list of all of the categories that have Products that the current user can reserve. Return type: [models.inventory.Category, ...]
Calculates the sum of unclaimed credit from this user’s credit notes.
Returns: the sum of the values of unclaimed credit notes for the current user. Return type: Decimal
Returns: All of the current user’s invoices. Return type: [models.commerce.Invoice, ...]
Gets all of the items that the user has reserved, but has not yet paid for.
Returns: A list of product-quantity pairs for the items that the user has not yet paid for. Return type: [ProductAndQuantity, ...]
Aggregates the items that this user has purchased.
Parameters: category (Optional[models.inventory.Category]) – the category of items to restrict to. Returns: A list of product-quantity pairs, aggregating like products from across multiple invoices. Return type: [ProductAndQuantity, ...]
Multiplies value by arg.
This is useful when displaying invoices, as it lets you multiply the quantity by the unit value.
Parameters: - value (number) –
- arg (number) –
Returns: value * arg
Return type: number
Rendering invoices¶
You’ll need to render the following Django models in order to view invoices.
-
class
registrasion.models.commerce.
Invoice
(*args, **kwargs)¶ An invoice. Invoices can be automatically generated when checking out a Cart, in which case, it is attached to a given revision of a Cart.
-
user
¶ User
The owner of this invoice.
-
cart
¶ commerce.Cart
The cart that was used to generate this invoice.
-
cart_revision
¶ int
The value of
cart.revision
at the time of this invoice’s creation. If a change is made to the underlying cart, this invoice is automatically void – this change is detected whencart.revision != cart_revision
.
-
status
¶ int
One of
STATUS_UNPAID
,STATUS_PAID
,STATUS_REFUNDED
, ORSTATUS_VOID
. Callget_status_display
for a human-readable representation.
-
recipient
¶ str
A rendered representation of the invoice’s recipient.
-
issue_time
¶ datetime
When the invoice was issued.
-
due_time
¶ datetime
When the invoice is due.
-
value
¶ Decimal
The total value of the line items attached to the invoice.
-
lineitem_set
¶ Queryset[LineItem]
The set of line items that comprise this invoice.
-
paymentbase_set
¶ Queryset[PaymentBase]
The set of PaymentBase objects that have been applied to this invoice.
-
-
class
registrasion.models.commerce.
LineItem
(*args, **kwargs)¶ Line items for an invoice. These are denormalised from the ProductItems and DiscountItems that belong to a cart (for consistency), but also allow for arbitrary line items when required.
-
invoice
¶ commerce.Invoice
The invoice to which this LineItem is attached.
-
description
¶ str
A human-readable description of the line item.
-
quantity
¶ int
The quantity of items represented by this line.
-
price
¶ Decimal
The per-unit price for this line item.
-
product
¶ Optional[inventory.Product]
The product that this LineItem applies to. This allows you to do reports on sales and applied discounts to individual products.
-
See also: PaymentBase