limitmonitor.py 1.05 KB
Newer Older
1 2 3 4 5
from collections import OrderedDict

from django.utils.translation import ugettext_lazy as _


6
class Container:
7 8 9
    UNDEFINED = 0

    MAP = OrderedDict([
10
        (UNDEFINED, _("Undefined"))
11 12 13 14 15 16 17 18 19 20 21 22 23
    ])

    @classmethod
    def choices(cls):
        choices = []
        for code, name in cls.MAP.items():
            choices.append((code, name))

        return choices

    @classmethod
    def get_name_by_code(cls, code):
        return cls.MAP.get(code, cls.MAP.get(cls.UNDEFINED))
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51


class ServicesContainer(Container):
    # CONSTANTS
    UNDEFINED = 0
    TUNNEL = 1
    COMMUNICATION = 2

    # MAPPING
    MAP = OrderedDict([
        (UNDEFINED, _("Undefined")),
        (TUNNEL, _("Tunnel")),
        (COMMUNICATION, _("Communication")),
    ])


class ParserContainer(Container):
    # CONSTANTS
    UNDEFINED = 0
    WOO_PRODUCT_V1 = 1
    WOO_SUBSCRIPTION_V1 = 2

    # MAPPING
    MAP = OrderedDict([
        (UNDEFINED, _("Undefined")),
        (WOO_PRODUCT_V1, _("WooCommerce Product v1")),
        (WOO_SUBSCRIPTION_V1, _("WooCommerce Subscription v1")),
    ])