# Path: shopkit/discounts/settings.py
# COUPON_LENGTH = getattr(settings, 'SHOPKIT_COUPON_LENGTH', 20)
# 
# COUPON_CHARACTERS = getattr(settings, 'SHOPKIT_COUPON_CHARACTERS', '23456789QWERTASDFGZXCVBYUIPHJKLNM')
# 
# Path: shopkit/core/settings.py
# PRODUCT_MODEL = getattr(settings, 'SHOPKIT_PRODUCT_MODEL')
# 
# Path: shopkit/core/utils/fields.py
# class PercentageField(MinMaxDecimalField):
#     """
#     Subclass of `DecimalField` with sensible defaults for percentage
#     discounts:
# 
#     * `max_value=100`
#     * `min_value=0`
#     * `decimal_places=0`
#     * `max_digits=3`
# 
#     """
# 
# 
#     description = 'Subclass of DecimalField with sensible defaults for \
#                    percentage discounts.'
# 
#     def __init__(self, **kwargs):
#         kwargs['max_value'] = kwargs.get('max_value', Decimal('100'))
#         kwargs['min_value'] = kwargs.get('min_value', Decimal('0'))
#         kwargs['decimal_places'] = kwargs.get('decimal_places', 0)
#         kwargs['max_digits'] = kwargs.get('max_digits', 3)
# 
#         super(PercentageField, self).__init__(**kwargs)
# 
# Path: shopkit/currency/utils.py
# def get_currency_field():
#     """
#     Use this method to get a useable pricefield based on the
#     `SHOPKIT_PRICE_FIELD_NAME` setting::
# 
#         # Get the currently configured currency field, whatever it is
#         from shopkit.currency.utils import get_currency_field
#         PriceField = get_currency_field()
# 
#         class PricedModel(models.Model):
#             ...
#             price = PriceField()
# 
# """
#     from shopkit.currency.settings import PRICE_FIELD_NAME
# 
#     # If we're just documenting, return some bogus value here
#     if PRICE_FIELD_NAME == '#doc':
#         class Bogus(object):
#             def __init__(self, *args, **kwargs):
#                 pass
# 
#         return Bogus
# 
#     module_name, field_name = PRICE_FIELD_NAME.rsplit('.', 1)
# 
#     # Allright, this is ugly as a monkey right here
#     # Ref: http://stackoverflow.com/questions/2724260/why-does-pythons-import-require-fromlist
#     module = __import__(module_name, fromlist=(field_name, ))
#     price_field = getattr(module, field_name)
# 
#     return price_field


import logging
        import random
from decimal import Decimal
from django.db import models
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from shopkit.discounts.settings import \
    COUPON_LENGTH, COUPON_CHARACTERS
from datetime import datetime
from shopkit.core.settings import PRODUCT_MODEL
from shopkit.core.utils.fields import PercentageField
from shopkit.currency.utils import get_currency_field
    from shopkit.category.settings import CATEGORY_MODEL
# django-shopkit is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

"""
Model base and mixin classes for building discount model and logic.

.. todo::
    Provide a listing/overview of the types of DiscountMixin's available,
    how they should be used and... whether they have been tested or not.
"""

logger = logging.getLogger(__name__)






# Get the currently configured currency field, whatever it is

# Path: shopkit/discounts/settings.py
# COUPON_LENGTH = getattr(settings, 'SHOPKIT_COUPON_LENGTH', 20)
# 
# COUPON_CHARACTERS = getattr(settings, 'SHOPKIT_COUPON_CHARACTERS', '23456789QWERTASDFGZXCVBYUIPHJKLNM')
# 
# Path: shopkit/core/settings.py
# PRODUCT_MODEL = getattr(settings, 'SHOPKIT_PRODUCT_MODEL')
# 
# Path: shopkit/core/utils/fields.py
# class PercentageField(MinMaxDecimalField):
#     """
#     Subclass of `DecimalField` with sensible defaults for percentage
#     discounts:
# 
#     * `max_value=100`
#     * `min_value=0`
#     * `decimal_places=0`
#     * `max_digits=3`
# 
#     """
# 
# 
#     description = 'Subclass of DecimalField with sensible defaults for \
#                    percentage discounts.'
# 
#     def __init__(self, **kwargs):
#         kwargs['max_value'] = kwargs.get('max_value', Decimal('100'))
#         kwargs['min_value'] = kwargs.get('min_value', Decimal('0'))
#         kwargs['decimal_places'] = kwargs.get('decimal_places', 0)
#         kwargs['max_digits'] = kwargs.get('max_digits', 3)
# 
#         super(PercentageField, self).__init__(**kwargs)
# 
# Path: shopkit/currency/utils.py
# def get_currency_field():
#     """
#     Use this method to get a useable pricefield based on the
#     `SHOPKIT_PRICE_FIELD_NAME` setting::
# 
#         # Get the currently configured currency field, whatever it is
#         from shopkit.currency.utils import get_currency_field
#         PriceField = get_currency_field()
# 
#         class PricedModel(models.Model):
#             ...
#             price = PriceField()
# 
# """
#     from shopkit.currency.settings import PRICE_FIELD_NAME
# 
#     # If we're just documenting, return some bogus value here
#     if PRICE_FIELD_NAME == '#doc':
#         class Bogus(object):
#             def __init__(self, *args, **kwargs):
#                 pass
# 
#         return Bogus
# 
#     module_name, field_name = PRICE_FIELD_NAME.rsplit('.', 1)
# 
#     # Allright, this is ugly as a monkey right here
#     # Ref: http://stackoverflow.com/questions/2724260/why-does-pythons-import-require-fromlist
#     module = __import__(module_name, fromlist=(field_name, ))
#     price_field = getattr(module, field_name)
# 
#     return price_field


# Path: shopkit/discounts/advanced/models/discount_models.py
import logging
        import random
from decimal import Decimal
from django.db import models
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from shopkit.discounts.settings import \
    COUPON_LENGTH, COUPON_CHARACTERS
from datetime import datetime
from shopkit.core.settings import PRODUCT_MODEL
from shopkit.core.utils.fields import PercentageField
from shopkit.currency.utils import get_currency_field
    from shopkit.category.settings import CATEGORY_MODEL

# django-shopkit is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

"""
Model base and mixin classes for building discount model and logic.

.. todo::
    Provide a listing/overview of the types of DiscountMixin's available,
    how they should be used and... whether they have been tested or not.
"""

logger = logging.getLogger(__name__)






# Get the currently configured currency field, whatever it is

PriceField = get_currency_field()