File diff 53413388e016 → dba37736362d
registrasion/models.py
Show inline comments
...
 
@@ -96,12 +96,13 @@ class Category(models.Model):
 
        blank=True,
 
        help_text=_("If enabled, a user must select an "
 
                    "item from this category."),
 
    )
 
    order = models.PositiveIntegerField(
 
        verbose_name=("Display order"),
 
        db_index=True,
 
    )
 
    render_type = models.IntegerField(
 
        choices=CATEGORY_RENDER_TYPES,
 
        verbose_name=_("Render type"),
 
        help_text=_("The registration form will render this category in this "
 
                    "style."),
...
 
@@ -144,12 +145,13 @@ class Product(models.Model):
 
        verbose_name=_("Reservation duration"),
 
        help_text=_("The length of time this product will be reserved before "
 
                    "it is released for someone else to purchase."),
 
    )
 
    order = models.PositiveIntegerField(
 
        verbose_name=("Display order"),
 
        db_index=True,
 
    )
 

	
 

	
 
@python_2_unicode_compatible
 
class Voucher(models.Model):
 
    ''' Registration vouchers '''
...
 
@@ -310,12 +312,13 @@ class VoucherDiscount(DiscountBase):
 
    cart. '''
 

	
 
    voucher = models.OneToOneField(
 
        Voucher,
 
        on_delete=models.CASCADE,
 
        verbose_name=_("Voucher"),
 
        db_index=True,
 
    )
 

	
 

	
 
class IncludedProductDiscount(DiscountBase):
 
    ''' Discounts that are enabled because another product has been purchased.
 
    e.g. A conference ticket includes a free t-shirt. '''
...
 
@@ -455,23 +458,39 @@ class RoleEnablingCondition(object):
 

	
 
@python_2_unicode_compatible
 
class Cart(models.Model):
 
    ''' Represents a set of product items that have been purchased, or are
 
    pending purchase. '''
 

	
 
    class Meta:
 
        index_together = [
 
            ("active", "time_last_updated"),
 
            ("active", "released"),
 
            ("active", "user"),
 
            ("released", "user"),
 
        ]
 

	
 
    def __str__(self):
 
        return "%d rev #%d" % (self.id, self.revision)
 

	
 
    user = models.ForeignKey(User)
 
    # ProductItems (foreign key)
 
    vouchers = models.ManyToManyField(Voucher, blank=True)
 
    time_last_updated = models.DateTimeField()
 
    time_last_updated = models.DateTimeField(
 
        db_index=True,
 
    )
 
    reservation_duration = models.DurationField()
 
    revision = models.PositiveIntegerField(default=1)
 
    active = models.BooleanField(default=True)
 
    released = models.BooleanField(default=False)  # Refunds etc
 
    active = models.BooleanField(
 
        default=True,
 
        db_index=True,
 
    )
 
    released = models.BooleanField(
 
        default=False,
 
        db_index=True
 
    )  # Refunds etc
 

	
 
    @classmethod
 
    def reserved_carts(cls):
 
        ''' Gets all carts that are 'reserved' '''
 
        return Cart.objects.filter(
 
            (Q(active=True) &
...
 
@@ -489,13 +508,13 @@ class ProductItem(models.Model):
 
    def __str__(self):
 
        return "product: %s * %d in Cart: %s" % (
 
            self.product, self.quantity, self.cart)
 

	
 
    cart = models.ForeignKey(Cart)
 
    product = models.ForeignKey(Product)
 
    quantity = models.PositiveIntegerField()
 
    quantity = models.PositiveIntegerField(db_index=True)
 

	
 

	
 
@python_2_unicode_compatible
 
class DiscountItem(models.Model):
 
    ''' Represents a discount-product-quantity relation in a Cart. '''