# Path: registrasion/models/conditions.py
# class TimeOrStockLimitCondition(models.Model):
#     class Meta:
# class VoucherCondition(models.Model):
#     class Meta:
# class IncludedProductCondition(models.Model):
#     class Meta:
# class SpeakerCondition(models.Model):
#     class Meta:
# class GroupMemberCondition(models.Model):
#     class Meta:
# class DiscountBase(models.Model):
#     class Meta:
# class DiscountForProduct(models.Model):
#     class Meta:
# class DiscountForCategory(models.Model):
#     class Meta:
# class TimeOrStockLimitDiscount(TimeOrStockLimitCondition, DiscountBase):
#     class Meta:
# class VoucherDiscount(VoucherCondition, DiscountBase):
#     class Meta:
# class IncludedProductDiscount(IncludedProductCondition, DiscountBase):
#     class Meta:
# class SpeakerDiscount(SpeakerCondition, DiscountBase):
#     class Meta:
# class GroupMemberDiscount(GroupMemberCondition, DiscountBase):
#     class Meta:
# class FlagBase(models.Model):
# class TimeOrStockLimitFlag(TimeOrStockLimitCondition, FlagBase):
#     class Meta:
# class ProductFlag(IncludedProductCondition, FlagBase):
#     class Meta:
# class CategoryFlag(FlagBase):
#     class Meta:
# class VoucherFlag(VoucherCondition, FlagBase):
#     class Meta:
# class SpeakerFlag(SpeakerCondition, FlagBase):
#     class Meta:
# class GroupMemberFlag(GroupMemberCondition, FlagBase):
#     class Meta:
#     def __str__(self):
#     def effects(self):
#     def __str__(self):
#     def clean(self):
#     def __str__(self):
#     def clean(self):
#     def __str__(self):
#     def effects(self):
#     def is_disable_if_false(self):
#     def is_enable_if_true(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     DISABLE_IF_FALSE = 1
#     ENABLE_IF_TRUE = 2
# 
# Path: registrasion/models/inventory.py
# class Category(models.Model):
#     class Meta:
# class Product(models.Model):
#     class Meta:
# class Voucher(models.Model):
#     class Meta:
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def normalise_code(cls, code):
#     def save(self, *a, **k):
#     RENDER_TYPE_RADIO = 1
#     RENDER_TYPE_QUANTITY = 2
#     RENDER_TYPE_ITEM_QUANTITY = 3
#     RENDER_TYPE_CHECKBOX = 4
#     CATEGORY_RENDER_TYPES = [
#         (RENDER_TYPE_RADIO, _("Radio button")),
#         (RENDER_TYPE_QUANTITY, _("Quantity boxes")),
#         (RENDER_TYPE_ITEM_QUANTITY, _("Product selector and quantity box")),
#         (RENDER_TYPE_CHECKBOX, _("Checkbox button")),
#     ]
#     RESERVATION_DURATION = datetime.timedelta(hours=1)


from django.contrib import admin
from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import ugettext_lazy as _
from registrasion.models import conditions
from registrasion.models import inventory
import nested_admin

    # TODO work out why we're allowed to add more than one?
    max_num = 1
    extra = 1


@admin.register(inventory.Voucher)
class VoucherAdmin(nested_admin.NestedAdmin):

    def effects(self, obj):
        ''' List the effects of the voucher in the admin. '''
        out = []

        try:
            discount_effects = obj.voucherdiscount.effects()
        except ObjectDoesNotExist:
            discount_effects = None

        try:
            enabling_effects = obj.voucherflag.effects()
        except ObjectDoesNotExist:
            enabling_effects = None

        if discount_effects:
            out.append("Discounts: " + str(list(discount_effects)))
        if enabling_effects:
            out.append("Enables: " + str(list(enabling_effects)))

        return "\n".join(out)


# Path: registrasion/models/conditions.py
# class TimeOrStockLimitCondition(models.Model):
#     class Meta:
# class VoucherCondition(models.Model):
#     class Meta:
# class IncludedProductCondition(models.Model):
#     class Meta:
# class SpeakerCondition(models.Model):
#     class Meta:
# class GroupMemberCondition(models.Model):
#     class Meta:
# class DiscountBase(models.Model):
#     class Meta:
# class DiscountForProduct(models.Model):
#     class Meta:
# class DiscountForCategory(models.Model):
#     class Meta:
# class TimeOrStockLimitDiscount(TimeOrStockLimitCondition, DiscountBase):
#     class Meta:
# class VoucherDiscount(VoucherCondition, DiscountBase):
#     class Meta:
# class IncludedProductDiscount(IncludedProductCondition, DiscountBase):
#     class Meta:
# class SpeakerDiscount(SpeakerCondition, DiscountBase):
#     class Meta:
# class GroupMemberDiscount(GroupMemberCondition, DiscountBase):
#     class Meta:
# class FlagBase(models.Model):
# class TimeOrStockLimitFlag(TimeOrStockLimitCondition, FlagBase):
#     class Meta:
# class ProductFlag(IncludedProductCondition, FlagBase):
#     class Meta:
# class CategoryFlag(FlagBase):
#     class Meta:
# class VoucherFlag(VoucherCondition, FlagBase):
#     class Meta:
# class SpeakerFlag(SpeakerCondition, FlagBase):
#     class Meta:
# class GroupMemberFlag(GroupMemberCondition, FlagBase):
#     class Meta:
#     def __str__(self):
#     def effects(self):
#     def __str__(self):
#     def clean(self):
#     def __str__(self):
#     def clean(self):
#     def __str__(self):
#     def effects(self):
#     def is_disable_if_false(self):
#     def is_enable_if_true(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     DISABLE_IF_FALSE = 1
#     ENABLE_IF_TRUE = 2
# 
# Path: registrasion/models/inventory.py
# class Category(models.Model):
#     class Meta:
# class Product(models.Model):
#     class Meta:
# class Voucher(models.Model):
#     class Meta:
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def normalise_code(cls, code):
#     def save(self, *a, **k):
#     RENDER_TYPE_RADIO = 1
#     RENDER_TYPE_QUANTITY = 2
#     RENDER_TYPE_ITEM_QUANTITY = 3
#     RENDER_TYPE_CHECKBOX = 4
#     CATEGORY_RENDER_TYPES = [
#         (RENDER_TYPE_RADIO, _("Radio button")),
#         (RENDER_TYPE_QUANTITY, _("Quantity boxes")),
#         (RENDER_TYPE_ITEM_QUANTITY, _("Product selector and quantity box")),
#         (RENDER_TYPE_CHECKBOX, _("Checkbox button")),
#     ]
#     RESERVATION_DURATION = datetime.timedelta(hours=1)


# Path: registrasion/admin.py
from django.contrib import admin
from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import ugettext_lazy as _
from registrasion.models import conditions
from registrasion.models import inventory
import nested_admin


    # TODO work out why we're allowed to add more than one?
    max_num = 1
    extra = 1


@admin.register(inventory.Voucher)
class VoucherAdmin(nested_admin.NestedAdmin):

    def effects(self, obj):
        ''' List the effects of the voucher in the admin. '''
        out = []

        try:
            discount_effects = obj.voucherdiscount.effects()
        except ObjectDoesNotExist:
            discount_effects = None

        try:
            enabling_effects = obj.voucherflag.effects()
        except ObjectDoesNotExist:
            enabling_effects = None

        if discount_effects:
            out.append("Discounts: " + str(list(discount_effects)))
        if enabling_effects:
            out.append("Enables: " + str(list(enabling_effects)))

        return "\n".join(out)


    model = inventory.Voucher