from django.utils.translation import ugettext_lazy as _

from freenasUI.failover.models import Failover
from freenasUI.freeadmin.tree import TreeNode

NAME = _('Failover')
HIDE = True


class AddFailover(TreeNode):

    gname = 'Add'
    append_to = 'system.Failover'
    view = 'freeadmin_failover_failover_add'
    type = 'editobject'

    def pre_build_options(self):
        if Failover.objects.all().count() >= 1:
            raise ValueError

class ViewCARP(TreeNode):

    gname = 'View'
    append_to = 'network.CARP'
    type = 'opennetwork'


class ViewFailover(TreeNode):

    gname = 'View'
    append_to = 'system.Failover'
    type = 'opensystem'
