User-facing views

View functions

Here’s all of the views that Registrasion exposes to the public.

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:

registrasion.templatetags.registrasion_tags.available_categories(context)

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, ...]
registrasion.templatetags.registrasion_tags.available_credit(context)

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
registrasion.templatetags.registrasion_tags.invoices(context)
Returns:All of the current user’s invoices.
Return type:[models.commerce.Invoice, ...]
registrasion.templatetags.registrasion_tags.items_pending(context)

Gets all of the items that the user from this context has reserved.

registrasion.templatetags.registrasion_tags.items_purchased(context, category=None)

Returns the items purchased for this user.

registrasion.templatetags.registrasion_tags.multiply(value, arg)

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 when cart.revision != cart_revision.

status

int

One of STATUS_UNPAID, STATUS_PAID, STATUS_REFUNDED, OR STATUS_VOID. Call get_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