Example #1
0
    def __init__(self, *args, **kwargs):
        self._fserrors = {}
        self._api = kwargs.pop('api_validation', False)
        super(ModelForm, self).__init__(*args, **kwargs)

        if self.instance and self.instance.pk:
            """
            Only show fields that are node specific in passive node
            e.g. hostname
            """
            table = self.instance._meta.db_table
            nosync = NO_SYNC_MAP.get(table)
            if nosync and 'fields' in nosync:
                from freenasUI.middleware.notifier import notifier
                if (
                    hasattr(notifier, 'failover_status') and
                    notifier().failover_status() == 'BACKUP'
                ):
                    for fname in list(self.fields.keys()):
                        if fname not in nosync['fields']:
                            del self.fields[fname]

        fname = str(type(self).__name__)
        appPool.hook_form_init(fname, self, *args, **kwargs)
        for name, field in list(self.fields.items()):
            if hasattr(field, "_reroll"):
                field._reroll()
Example #2
0
    def __init__(self, *args, **kwargs):
        self._fserrors = {}
        self._api = kwargs.pop('api_validation', False)
        super(ModelForm, self).__init__(*args, **kwargs)

        if self.instance and self.instance.pk:
            """
            Only show fields that are node specific in passive node
            e.g. hostname
            """
            table = self.instance._meta.db_table
            nosync = NO_SYNC_MAP.get(table)
            if nosync and 'fields' in nosync:
                from freenasUI.middleware.notifier import notifier
                if (hasattr(notifier, 'failover_status')
                        and notifier().failover_status() == 'BACKUP'):
                    for fname in list(self.fields.keys()):
                        if fname not in nosync['fields']:
                            del self.fields[fname]

        fname = str(type(self).__name__)
        appPool.hook_form_init(fname, self, *args, **kwargs)
        for name, field in list(self.fields.items()):
            if hasattr(field, "_reroll"):
                field._reroll()
Example #3
0
 def __init__(self, *args, **kwargs):
     self._api = kwargs.pop('api_validation', False)
     super(Form, self).__init__(*args, **kwargs)
     fname = str(type(self).__name__)
     appPool.hook_form_init(fname, self, *args, **kwargs)
     for name, field in self.fields.items():
         if hasattr(field, "_reroll"):
             field._reroll()
Example #4
0
 def __init__(self, *args, **kwargs):
     self._api = kwargs.pop('api_validation', False)
     super(Form, self).__init__(*args, **kwargs)
     fname = str(type(self).__name__)
     appPool.hook_form_init(fname, self, *args, **kwargs)
     for name, field in list(self.fields.items()):
         if hasattr(field, "_reroll"):
             field._reroll()