summaryrefslogtreecommitdiff
path: root/saleor/product/__init__.py
blob: c2bab0d6509e09ee6f1ca85647dbb4b0b1525dbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from django.utils.translation import pgettext_lazy


class ProductAvailabilityStatus(object):
    NOT_PUBLISHED = 'not-published'
    VARIANTS_MISSSING = 'variants-missing'
    NOT_CARRIED = 'not-carried'
    OUT_OF_STOCK = 'out-of-stock'
    LOW_STOCK = 'low-stock'
    NOT_YET_AVAILABLE = 'not-yet-available'
    READY_FOR_PURCHASE = 'ready-for-purchase'

    @staticmethod
    def get_display(status):
        if status == ProductAvailabilityStatus.NOT_PUBLISHED:
            return pgettext_lazy('Product status', 'not published')
        elif status == ProductAvailabilityStatus.VARIANTS_MISSSING:
            return pgettext_lazy('Product status', 'variants missing')
        elif status == ProductAvailabilityStatus.NOT_CARRIED:
            return pgettext_lazy('Product status', 'not carried')
        elif status == ProductAvailabilityStatus.OUT_OF_STOCK:
            return pgettext_lazy('Product status', 'out of stock')
        elif status == ProductAvailabilityStatus.LOW_STOCK:
            return pgettext_lazy('Product status', 'stock running low')
        elif status == ProductAvailabilityStatus.NOT_YET_AVAILABLE:
            return pgettext_lazy('Product status', 'not yet available')
        elif status == ProductAvailabilityStatus.READY_FOR_PURCHASE:
            return pgettext_lazy('Product status', 'ready for purchase')
        else:
            raise NotImplementedError('Unknown status: %s' % status)


class VariantAvailabilityStatus(object):
    AVAILABLE = 'available'
    NOT_CARRIED = 'not-carried'
    OUT_OF_STOCK = 'out-of-stock'

    @staticmethod
    def get_display(status):
        if status == VariantAvailabilityStatus.AVAILABLE:
            return pgettext_lazy('Variant status', 'available')
        elif status == VariantAvailabilityStatus.NOT_CARRIED:
            return pgettext_lazy('Variant status', 'not carried')
        elif status == VariantAvailabilityStatus.OUT_OF_STOCK:
            return pgettext_lazy('Variant status', 'out of stock')
        else:
            raise NotImplementedError('Unknown status: %s' % status)