Example #1
0
class Orientation(Choices):
    _ = Choices.Choice

    DEPTH = Choices.Group(0)
    front = _("front")
    back = _("back")
    middle = _("middle")

    WIDTH = Choices.Group(100)
    left = _("left")
    right = _("right")

    @classmethod
    def is_width(cls, orientation):
        is_width = orientation in set(
            [choice.id for choice in cls.WIDTH.choices]
        )
        return is_width

    @classmethod
    def is_depth(cls, orientation):
        is_depth = orientation in set(
            [choice.id for choice in cls.DEPTH.choices]
        )
        return is_depth
Example #2
0
        class Colors(Choices):
            _ = Choices.Choice

            NICE = Choices.Group(0).extra(comment='Nice!')
            blue = _("Blue")
            green = _("Green").extra(comment='This is it.')
            brown = _("Brown")

            UGLY = Choices.Group(10).extra(comment='Ugly!')
            pink = _("Pink")
            red = _("Red")
            toxic_waste_green = _("Toxic waste green").extra(comment='Yuk!')
Example #3
0
class FileType(Choices):
    _ = Choices.Choice

    LINUX = Choices.Group(0)
    kernel = _("kernel")
    initrd = _("initrd")

    CONFIGURATION = Choices.Group(40)
    boot_ipxe = _("boot_ipxe")
    kickstart = _("kickstart")

    OTHER = Choices.Group(100)
    other = _("other")
Example #4
0
    class choices(Choices):
        _ = Choices.Choice

        CHANGES = Choices.Group(0)
        change = _('change')

        INCIDENTS = Choices.Group(100)
        incident = _('incident')

        PROBLEMS = Choices.Group(200)
        problem = _('problem')

        FAILURES = Choices.Group(300)
        failure = _('failure')
        hardware_failure = _('hardware failure')
Example #5
0
class PrebootItemType(Choices):
    _ = Choices.Choice

    LINUX = Choices.Group(0)
    kernel = _('kernel')
    initrd = _('initrd')
    netboot = _('netboot')

    CONFIGURATION = Choices.Group(40)
    ipxe = _('iPXE')
    kickstart = _('kickstart')
    preseed = _('preseed')
    script = _('script')

    OTHER = Choices.Group(100)
    other = _('other')
Example #6
0
class Sports(Choices):
    _ = Choices.Choice

    TEAM_SPORTS = Choices.Group(0, 'Team Sports')
    soccer = _("Soccer")
    basketball = _("Basketball")
    baseball = _("Baseball")

    INDIVIDUAL = Choices.Group(100, 'Individual Sports')
    swimming = _("Swimming")
    mountaineering = _("Mountaineering")
    bicycling = _("Bicycling")

    NOT_REALLY = Choices.Group(200, 'Fake Sports')
    chess = _("Chess")
    bridge = _("Bridge")
    poker = _("Poker")
Example #7
0
        class Groupies(Choices):
            _ = Choices.Choice

            GROUP1 = Choices.Group(0)
            entry1 = _("entry1")
            entry2 = _("entry2")
            entry3 = _("entry3")

            GROUP2 = Choices.Group(10)
            entry4 = _("entry4")
            entry5 = _("entry5")
            entry6 = _("entry6")

            GROUP3 = Choices.Group(20)
            entry7 = _("entry7")
            entry8 = _("entry8")
            entry9 = _("entry9")
Example #8
0
class FibreChannelCardSpeed(Choices):
    _ = Choices.Choice

    s1gbit = _('1 Gbit')
    s2gbit = _('2 Gbit')
    s4gbit = _('4 Gbit')
    s8gbit = _('8 Gbit')
    s16gbit = _('16 Gbit')
    s32gbit = _('32 Gbit')

    UNKNOWN_GROUP = Choices.Group(10)
    unknown = _('unknown speed')
Example #9
0
class EthernetSpeed(Choices):
    _ = Choices.Choice

    s10mbit = _('10 Mbps')
    s100mbit = _('100 Mbps')
    s1gbit = _('1 Gbps')
    s10gbit = _('10 Gbps')
    s40gbit = _('40 Gbps')
    s100gbit = _('100 Gbps')

    UNKNOWN_GROUP = Choices.Group(10)
    unknown = _('unknown speed')
Example #10
0
class Perm(Choices):
    _ = Choices.Choice

    GLOBAL = Choices.Group(0).extra(per_venture=False)
    read_dc_structure = _("read data center structure")
    edit_ventures_roles = _("edit ventures and roles")
    create_devices = _("create devices")
    delete_devices = _("delete devices")
    edit_device_info_generic = _("edit generic device info")
    edit_device_info_financial = _("edit financial device info")
    edit_device_info_support = _("edit device purchase info")
    run_discovery = _("run discovery")
    read_device_info_management = _("read device management_info")
    read_network_structure = _("read network structure")
    create_configuration_item = _("create configuration items")
    edit_configuration_item_info_generic = _("edit configuration items")
    edit_configuration_item_relations = _("edit configuration item relations")
    read_configuration_item_info_generic = _(
        "read configuration item info generic")
    read_configuration_item_info_puppet = _(
        "read configuration item info Puppet reports")
    read_configuration_item_info_git = _("read configuration item info GIT ")
    read_configuration_item_info_jira = _("read configuration item info jira")
    bulk_edit = _("edit all device info in bulk")
    edit_domain_name = _("edit domain name entries")
    read_domain_name = _("read domain name entries")
    create_device = _("create new devices manually")
    read_deployment = _("read deployment")

    PER_VENTURE = Choices.Group(100) << {'per_venture': True}
    list_devices_generic = _("list venture devices")
    list_devices_financial = _("list venture devices financial info")
    read_device_info_generic = _("read generic device info")
    read_device_info_financial = _("read financial device info")
    read_device_info_support = _("read device purchase info")
    read_device_info_history = _("read device history info")
    read_device_info_reports = _("read device reports")
    has_assets_access = _("has_assets_access")
    has_core_access = _("has_core_access")
    has_scrooge_access = _("has_scrooge_access")
Example #11
0
class SupportStatus(Choices):
    _ = Choices.Choice

    SUPPORT = Choices.Group(0)
    new = _("new")
Example #12
0
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models.fields.related import add_lazy_relation
from django.utils.text import capfirst, slugify
from django.utils.translation import ugettext_lazy as _

from ralph.lib.mixins.models import AdminAbsoluteUrlMixin, TimeStampMixin
from .fields import (CustomFieldsWithInheritanceRelation,
                     CustomFieldValueQuerySet)

logger = logging.getLogger(__name__)

CUSTOM_FIELD_VALUE_MAX_LENGTH = 1000

STRING_CHOICE = Choices.Choice('string').extra(form_field=forms.CharField, )
INTEGER_CHOICE = Choices.Choice('integer').extra(
    form_field=forms.IntegerField, )
DATE_CHOICE = Choices.Choice('date').extra(form_field=forms.DateField, )
URL_CHOICE = Choices.Choice('url').extra(form_field=forms.URLField, )
CHOICE_CHOICE = Choices.Choice('choice list').extra(
    form_field=forms.ChoiceField, )


class CustomFieldTypes(Choices):
    _ = Choices.Choice

    STRING = STRING_CHOICE
    INTEGER = INTEGER_CHOICE
    DATE = DATE_CHOICE
    URL = URL_CHOICE