# Path: shopkit/core/settings.py
# PRODUCT_MODEL = getattr(settings, 'SHOPKIT_PRODUCT_MODEL')
# 
# Path: shopkit/core/basemodels.py
# class OrderedInlineItemBase(models.Model):
#     """
#     This base class does what, actually, order_with_respect_to should do
#     but (for now) doesn't implement very well: ordering of objects with
#     a fk-relation to some class.
# 
#     As we do not know what the class with the respective relation is, it
#     is important to note that something like the following is added::
# 
#         class MyOrderedInline(OrderedInlineItemBase):
# 
#             <related> = models.ForeignKey(RelatedModel)
# 
#             class Meta(OrderedInlineItemBase.Meta):
#                 unique_together = ('sort_order', '<related>')
# 
#             def get_related_ordering(self):
#                 return self.__class__.objects.filter(<related>=self.<related>)
# 
# 
# 
#         ... Or we could simply wait for the Django developers to fix
#         `order_with_respect_to` once and for all. (Work in progress...
#         See `Ticket #13 <http://code.djangoproject.com/ticket/13>`.)
# 
# 
#     """
# 
#     class Meta:
#         abstract = True
#         ordering = ('sort_order', )
# 
#     def get_related_ordering(self):
#         """
#         Get a :class:`QuerySet <django.db.models.QuerySet.QuerySet`
#         with related items to be considered for calculating the next
#         `sort_order`.
# 
#         As we do not know in this base class what the related field(s)
#         are, this raises a NotImplementedError. It should be subclassed
#         with something like::
# 
#             return self.objects.filter(<related>=self.<related>)
# 
#         """
#         raise NotImplementedError
# 
#     @staticmethod
#     def get_next_ordering(related):
#         """
#         Get the next ordering based upon the :class:`QuerySet <django.db.models.QuerySet.QuerySet`
#         with related items.
#         """
#         return get_next_ordering(related)
# 
#     def save(self):
#         """
#         If no `sort_order` has been specified, make sure we calculate the
#         it based on the highest available current `sort_order`.
#         """
# 
#         if not self.sort_order:
#             related = self.get_related_ordering()
#             self.sort_order = self.get_next_ordering(related)
# 
#             logger.debug(
#                 u'Generated sort_order %d for object %s',
#                 self.sort_order, self
#             )
# 
#         super(OrderedInlineItemBase, self).save()
# 
#     sort_order = models.PositiveSmallIntegerField(
#         verbose_name=('sort order'),
#         blank=True, db_index=True,
#         help_text=_(
#             'Change this to alter the order in which items are displayed.'
#         )
#     )


import logging
from django.db import models
from django.utils.translation import ugettext_lazy as _
    from sorl.thumbnail import ImageField
from shopkit.core.settings import PRODUCT_MODEL
from shopkit.core.basemodels import OrderedInlineItemBase
#
# 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.

logger = logging.getLogger(__name__)


try:
    logger.debug(u'Sorl-thumbnail found: using it.')

except ImportError:
    ImageField = models.ImageField
    logger.debug(u'Sorl-thumbnail not found. Skipping.')



class ProductImageBase(models.Model):
    """ Base class for image relating to a product. """

    class Meta:
        abstract = True
        verbose_name = _('image')
        verbose_name_plural = _('images')

    product = models.ForeignKey(PRODUCT_MODEL)
    image = ImageField(verbose_name=_('image'),
                       upload_to='product_images')



# Path: shopkit/core/settings.py
# PRODUCT_MODEL = getattr(settings, 'SHOPKIT_PRODUCT_MODEL')
# 
# Path: shopkit/core/basemodels.py
# class OrderedInlineItemBase(models.Model):
#     """
#     This base class does what, actually, order_with_respect_to should do
#     but (for now) doesn't implement very well: ordering of objects with
#     a fk-relation to some class.
# 
#     As we do not know what the class with the respective relation is, it
#     is important to note that something like the following is added::
# 
#         class MyOrderedInline(OrderedInlineItemBase):
# 
#             <related> = models.ForeignKey(RelatedModel)
# 
#             class Meta(OrderedInlineItemBase.Meta):
#                 unique_together = ('sort_order', '<related>')
# 
#             def get_related_ordering(self):
#                 return self.__class__.objects.filter(<related>=self.<related>)
# 
# 
# 
#         ... Or we could simply wait for the Django developers to fix
#         `order_with_respect_to` once and for all. (Work in progress...
#         See `Ticket #13 <http://code.djangoproject.com/ticket/13>`.)
# 
# 
#     """
# 
#     class Meta:
#         abstract = True
#         ordering = ('sort_order', )
# 
#     def get_related_ordering(self):
#         """
#         Get a :class:`QuerySet <django.db.models.QuerySet.QuerySet`
#         with related items to be considered for calculating the next
#         `sort_order`.
# 
#         As we do not know in this base class what the related field(s)
#         are, this raises a NotImplementedError. It should be subclassed
#         with something like::
# 
#             return self.objects.filter(<related>=self.<related>)
# 
#         """
#         raise NotImplementedError
# 
#     @staticmethod
#     def get_next_ordering(related):
#         """
#         Get the next ordering based upon the :class:`QuerySet <django.db.models.QuerySet.QuerySet`
#         with related items.
#         """
#         return get_next_ordering(related)
# 
#     def save(self):
#         """
#         If no `sort_order` has been specified, make sure we calculate the
#         it based on the highest available current `sort_order`.
#         """
# 
#         if not self.sort_order:
#             related = self.get_related_ordering()
#             self.sort_order = self.get_next_ordering(related)
# 
#             logger.debug(
#                 u'Generated sort_order %d for object %s',
#                 self.sort_order, self
#             )
# 
#         super(OrderedInlineItemBase, self).save()
# 
#     sort_order = models.PositiveSmallIntegerField(
#         verbose_name=('sort order'),
#         blank=True, db_index=True,
#         help_text=_(
#             'Change this to alter the order in which items are displayed.'
#         )
#     )


# Path: shopkit/images/models.py
import logging
from django.db import models
from django.utils.translation import ugettext_lazy as _
    from sorl.thumbnail import ImageField
from shopkit.core.settings import PRODUCT_MODEL
from shopkit.core.basemodels import OrderedInlineItemBase

#
# 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.

logger = logging.getLogger(__name__)


try:
    logger.debug(u'Sorl-thumbnail found: using it.')

except ImportError:
    ImageField = models.ImageField
    logger.debug(u'Sorl-thumbnail not found. Skipping.')



class ProductImageBase(models.Model):
    """ Base class for image relating to a product. """

    class Meta:
        abstract = True
        verbose_name = _('image')
        verbose_name_plural = _('images')

    product = models.ForeignKey(PRODUCT_MODEL)
    image = ImageField(verbose_name=_('image'),
                       upload_to='product_images')



class OrderedProductImageBase(ProductImageBase, OrderedInlineItemBase):