Changeset - cbecbf9a4102
[Not reviewed]
0 3 0
Christopher Neugebauer - 8 years ago 2016-04-25 08:50:09
chrisjrn@gmail.com
Tidies up some docs
3 files changed with 6 insertions and 2 deletions:
0 comments (0 inline, 0 general)
docs/integration.rst
Show inline comments
 
Integrating Registrasion
 
========================
 

	
 
Registrasion is a Django app. It does not provide any templates -- you'll need to develop these yourself. You can use the ``registrasion-demo`` project as a starting point.
 
Registrasion is a Django app. It does not provide any templates -- you'll need to develop these yourself. You can use the `registrasion-demo <https://github.com/chrisjrn/registrasion-demo>`_ project as a starting point.
 

	
 
To use Registrasion for your own conference, you'll need to do a small amount of development work, usually in your own Django App.
 

	
 
The first is to define a model and form for your attendee profile, and the second is to implement a payment app.
 

	
 

	
 
Attendee profile
 
----------------
 

	
 
.. automodule:: registrasion.models.people
 

	
 
Attendee profiles are where you ask for information such as what your attendee wants on their badge, and what the attendee's dietary and accessibility requirements are.
 

	
 
Because every conference is different, Registrasion lets you define your own attendee profile model, and your own form for requesting this information. The only requirement is that you derive your model from ``AttendeeProfileBase``.
 

	
 
.. autoclass :: AttendeeProfileBase
 
    :members: name_field, invoice_recipient
 

	
 
Once you've subclassed ``AttendeeProfileBase``, you'll need to implement a form that lets attendees fill out their profile.
 

	
 
You specify how to find that form in your Django ``settings.py`` file::
 

	
 
    ATTENDEE_PROFILE_FORM = "democon.forms.AttendeeProfileForm"
 

	
 
The only contract is that this form creates an instance of ``AttendeeProfileBase`` when saved, and that it can take an instance of your subclass on creation (so that your attendees can edit their profile).
 

	
 

	
 
Payments
 
--------
 

	
 
Registrasion does not implement its own credit card processing. You'll need to do that yourself. Registrasion *does* provide a mechanism for recording cheques and direct deposits, if you do end up taking registrations that way.
 

	
 
See :ref:`payments_and_refunds` for a guide on how to correctly implement payments.
docs/inventory.rst
Show inline comments
 

	
 
Inventory Management
 
====================
 

	
 
Registrasion uses an inventory model to keep track of tickets, and the other various products that attendees of your conference might want to have, such as t-shirts and dinner tickets.
 

	
 
All of the classes described herein are available through the Django Admin interface.
 

	
 
Overview
 
--------
 

	
 
The inventory model is split up into Categories and Products. Categories are used to group Products.
 

	
 
Registrasion uses conditionals to build up complex tickets, or enable/disable specific items to specific users:
 

	
 
Often, you will want to offer free items, such as t-shirts or dinner tickets to your attendees. Registrasion has a Discounts facility that lets you automatically offer free items to your attendees as part of their tickets. You can also automatically offer promotional discounts, such as Early Bird discounts.
 

	
 
Sometimes, you may want to restrict parts of the conference to specific attendees, for example, you might have a Speakers Dinner to only speakers. Or you might want to restrict certain Products to attendees who have purchased other items, for example, you might want to sell Comfy Chairs to people who've bought VIP tickets. You can control showing and hiding specific products using Flags.
 

	
 

	
 
.. automodule:: registrasion.models.inventory
 

	
 
Categories
 
----------
 

	
 
Categories are logical groups of Products. Generally, you should keep like products in the same category, and use as many categories as you need.
 

	
 
You will need at least one Category to be able to sell tickets to your attendees.
 

	
 
Each category has the following attributes:
 

	
 
.. autoclass :: Category
 

	
 

	
 
Products
 
--------
 

	
 
Products represent the different items that comprise a user's conference ticket.
 

	
 
Each product has the following attributes:
 

	
 
.. autoclass :: Product
 

	
 

	
 
Vouchers
 
--------
 

	
 
Vouchers are used to enable Discounts or Flags for people who enter a voucher
 
code.
 

	
 
.. autoclass :: Voucher
 

	
 
If an attendee enters a voucher code, they have at least an hour to finalise
 
their registration before the voucher becomes unreserved. Only as many people
 
as allowed by ``limit`` are allowed to have a voucher reserved.
 

	
 

	
 
.. automodule:: registrasion.models.conditions
 

	
registrasion/controllers/cart.py
Show inline comments
...
 
@@ -233,97 +233,96 @@ class CartController(object):
 
            user=self.cart.user,
 
        )
 

	
 
        if user_carts_with_voucher.count() > 0:
 
            raise ValidationError("You have already entered this voucher.")
 

	
 
    def _test_vouchers(self, vouchers):
 
        ''' Tests each of the vouchers against self._test_voucher() and raises
 
        the collective ValidationError.
 
        Future work will refactor _test_voucher in terms of this, and save some
 
        queries. '''
 
        errors = []
 
        for voucher in vouchers:
 
            try:
 
                self._test_voucher(voucher)
 
            except ValidationError as ve:
 
                errors.append(ve)
 

	
 
        if errors:
 
            raise(ValidationError(ve))
 

	
 
    def _test_required_categories(self):
 
        ''' Makes sure that the owner of this cart has satisfied all of the
 
        required category constraints in the inventory (be it in this cart
 
        or others). '''
 

	
 
        required = set(inventory.Category.objects.filter(required=True))
 

	
 
        items = commerce.ProductItem.objects.filter(
 
            product__category__required=True,
 
            cart__user=self.cart.user,
 
        ).exclude(
 
            cart__status=commerce.Cart.STATUS_RELEASED,
 
        )
 

	
 
        for item in items:
 
            required.remove(item.product.category)
 

	
 
        errors = []
 
        for category in required:
 
            msg = "You must have at least one item from: %s" % category
 
            errors.append((None, msg))
 

	
 
        if errors:
 
            raise ValidationError(errors)
 

	
 
    def _append_errors(self, errors, ve):
 
        for error in ve.error_list:
 
            print error.message
 
            errors.append(error.message[1])
 

	
 
    def validate_cart(self):
 
        ''' Determines whether the status of the current cart is valid;
 
        this is normally called before generating or paying an invoice '''
 

	
 
        cart = self.cart
 
        user = self.cart.user
 
        errors = []
 

	
 
        try:
 
            self._test_vouchers(self.cart.vouchers.all())
 
        except ValidationError as ve:
 
            errors.append(ve)
 

	
 
        items = commerce.ProductItem.objects.filter(cart=cart)
 

	
 
        product_quantities = list((i.product, i.quantity) for i in items)
 
        try:
 
            self._test_limits(product_quantities)
 
        except ValidationError as ve:
 
            self._append_errors(errors, ve)
 

	
 
        try:
 
            self._test_required_categories()
 
        except ValidationError as ve:
 
            self._append_errors(errors, ve)
 

	
 
        # Validate the discounts
 
        discount_items = commerce.DiscountItem.objects.filter(cart=cart)
 
        seen_discounts = set()
 

	
 
        for discount_item in discount_items:
 
            discount = discount_item.discount
 
            if discount in seen_discounts:
 
                continue
 
            seen_discounts.add(discount)
 
            real_discount = conditions.DiscountBase.objects.get_subclass(
 
                pk=discount.pk)
 
            cond = ConditionController.for_condition(real_discount)
 

	
 
            if not cond.is_met(user):
 
                errors.append(
 
                    ValidationError("Discounts are no longer available")
 
                )
 

	
 
        if errors:
 
            raise ValidationError(errors)
0 comments (0 inline, 0 general)