from __future__ import unicode_literals

from django.utils.translation import pgettext
from satchless import cart
from satchless.item import ItemList, ClassifyingPartitioner

from ..product.models import DigitalShip


class ShippedGroup(ItemList):
    '''
    Group for shippable products.
    '''
    pass


class DigitalGroup(ItemList):
    '''
    Group for digital products.
    '''
    pass


class CartPartitioner(ClassifyingPartitioner):
    '''
    Dividing cart into groups.
    '''
    def classify(self, item):
        if isinstance(item.product, DigitalShip):
            return 'digital'
        return 'shippable'

    def get_partition(self, classifier, items):
        if classifier == 'digital':
            return DigitalGroup(items)
        return ShippedGroup(items)


class Cart(cart.Cart):
    '''
    Contains cart items. Serialized instance of cart is saved into django
    session.
    '''
    timestamp = None
    billing_address = None

    def __unicode__(self):
        return pgettext(
            'Shopping cart',
            'Your cart (%(cart_count)s)') % {'cart_count': self.count()}

    def clear(self):
        self._state = []

from __future__ import unicode_literals

from django.utils.translation import pgettext
from satchless import cart
from satchless.item import ItemList, ClassifyingPartitioner

from ..product.models import DigitalShip


class ShippedGroup(ItemList):
    '''
    Group for shippable products.
    '''
    pass


class DigitalGroup(ItemList):
    '''
    Group for digital products.
    '''
    pass


class CartPartitioner(ClassifyingPartitioner):
    '''
    Dividing cart into groups.
    '''
    def classify(self, item):
        if isinstance(item.product, DigitalShip):
            return 'digital'
        return 'shippable'

    def get_partition(self, classifier, items):
        if classifier == 'digital':
            return DigitalGroup(items)
        return ShippedGroup(items)


class Cart(cart.Cart):
    '''
    Contains cart items. Serialized instance of cart is saved into django
    session.
    '''
    timestamp = None
    billing_address = None

    def __unicode__(self):
        return pgettext(
            'Shopping cart',
            'Your cart (%(cart_count)s)') % {'cart_count': self.count()}

Use clear cart method from satchless
Use clear cart method from satchless

https://github.com/mirumee/satchless/commit/3acaa8f6a27d9ab259a2d66fc3f7416a18fab1ad

This reverts commit 2ad16c44adb20e9ba023e873149d67068504c34c.
