Exemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     super(DeviceInfoForm, self).__init__(*args, **kwargs)
     if self.data:
         self.data = self.data.copy()
         self.data['model_name'] = self.initial['model_name']
         self.data['rack_name'] = self.initial['rack_name']
         self.data['dc_name'] = self.initial['dc_name']
     self.fields['venture'].choices = all_ventures()
     self.fields['venture_role'].choices = all_roles()
     if not self.instance:
         return
     rack = self.instance.find_rack()
     if rack:
         rack_networks = sorted(
             rack.network_set.all(),
             key=lambda net: net.get_netmask(),
             reverse=True,
         )
         for network in rack_networks:
             if not network.environment:
                 continue
             next_hostname = get_next_free_hostname(network.environment)
             if next_hostname:
                 help_text = 'Next available hostname in this DC: %s' % (
                     next_hostname
                 )
                 self.fields['name'].help_text = help_text
                 break
Exemplo n.º 2
0
 def __init__(self, *args, **kwargs):
     super(DeviceCreateForm, self).__init__(*args, **kwargs)
     self.fields['venture'].choices = all_ventures()
     self.fields['venture_role'].choices = all_roles()
     self.fields['venture'].required = True
     self.fields['model'].required = True
     del self.fields['save_comment']
Exemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     super(DeviceInfoForm, self).__init__(*args, **kwargs)
     if self.data:
         self.data = self.data.copy()
         self.data['model_name'] = self.initial['model_name']
         self.data['rack_name'] = self.initial['rack_name']
         self.data['dc_name'] = self.initial['dc_name']
     self.fields['venture'].choices = all_ventures()
     self.fields['venture_role'].choices = all_roles()
     if not self.instance:
         return
     rack = self.instance.find_rack()
     if rack:
         rack_networks = sorted(
             rack.network_set.all(),
             key=lambda net: net.get_netmask(),
             reverse=True,
         )
         for network in rack_networks:
             if not network.environment:
                 continue
             next_hostname = get_next_free_hostname(network.environment)
             if next_hostname:
                 help_text = 'Next available hostname in this DC: %s' % (
                     next_hostname)
                 self.fields['name'].help_text = help_text
                 break
Exemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     super(DeviceCreateForm, self).__init__(*args, **kwargs)
     self.fields['venture'].choices = all_ventures()
     self.fields['venture_role'].choices = all_roles()
     self.fields['venture'].required = True
     self.fields['model'].required = True
     if 'ralph_assets' in settings.INSTALLED_APPS:
         self.fields['asset'] = AutoCompleteSelectField(
             ('ralph_assets.api_ralph', 'AssetLookup'),
             required=False,
         )
         self.fields['asset'].widget.help_text = (
             'Enter asset sn, barcode or model')
     del self.fields['save_comment']
Exemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     super(DeviceCreateForm, self).__init__(*args, **kwargs)
     self.fields['venture'].choices = all_ventures()
     self.fields['venture_role'].choices = all_roles()
     self.fields['venture'].required = True
     self.fields['model'].required = True
     if 'ralph_assets' in settings.INSTALLED_APPS:
         self.fields['asset'] = AutoCompleteSelectField(
             ('ralph_assets.api_ralph', 'AssetLookup'),
             required=False,
         )
         self.fields['asset'].widget.help_text = (
             'Enter asset sn, barcode or model'
         )
     del self.fields['save_comment']
Exemplo n.º 6
0
 def __init__(self, *args, **kwargs):
     super(DeviceCreateForm, self).__init__(*args, **kwargs)
     self.fields['venture'].choices = all_ventures()
     self.fields['venture_role'].choices = all_roles()
     self.fields['venture'].required = True
     self.fields['model'].required = True
     self.fields['asset'] = AutoCompleteSelectField(
         ('ralph_assets.api_ralph', 'AssetLookup'),
         required=False,
     )
     self.fields['asset'].widget.help_text = (
         'Enter asset sn, barcode or model')
     del self.fields['save_comment']
     if 'data' in kwargs and kwargs['data'].get('asset'):
         if Asset.objects.filter(pk=kwargs['data']['asset']).exists():
             self.fields['chassis_position'].widget = ReadOnlyWidget()
             self.fields['position'].widget = ReadOnlyWidget()
Exemplo n.º 7
0
 def __init__(self, *args, **kwargs):
     super(DeviceCreateForm, self).__init__(*args, **kwargs)
     self.fields['venture'].choices = all_ventures()
     self.fields['venture_role'].choices = all_roles()
     self.fields['venture'].required = True
     self.fields['model'].required = True
     self.fields['asset'] = AutoCompleteSelectField(
         ('ralph_assets.api_ralph', 'AssetLookup'),
         required=False,
     )
     self.fields['asset'].widget.help_text = (
         'Enter asset sn, barcode or model'
     )
     del self.fields['save_comment']
     if 'data' in kwargs and kwargs['data'].get('asset'):
         if Asset.objects.filter(pk=kwargs['data']['asset']).exists():
             self.fields['chassis_position'].widget = ReadOnlyWidget()
             self.fields['position'].widget = ReadOnlyWidget()
Exemplo n.º 8
0
 def __init__(self, *args, **kwargs):
     super(DeviceInfoForm, self).__init__(*args, **kwargs)
     if self.data:
         self.data = self.data.copy()
         self.data['model_name'] = self.initial['model_name']
         self.data['rack_name'] = self.initial['rack_name']
         self.data['dc_name'] = self.initial['dc_name']
     self.fields['venture'].choices = all_ventures()
     self.fields['venture_role'].choices = all_roles()
     if not self.instance:
         return
     rack = self.instance.find_rack()
     if rack:
         for network in rack.network_set.order_by('name'):
             next_hostname = get_next_free_hostname(network.data_center)
             if next_hostname:
                 help_text = 'Next available hostname in this DC: %s' % (
                     next_hostname
                 )
                 self.fields['name'].help_text = help_text
                 break
Exemplo n.º 9
0
 def __init__(self, *args, **kwargs):
     super(DeviceBulkForm, self).__init__(*args, **kwargs)
     self.fields['venture'].choices = all_ventures()
     self.fields['venture_role'].choices = all_roles()
Exemplo n.º 10
0
 def __init__(self, *args, **kwargs):
     super(DeviceBulkForm, self).__init__(*args, **kwargs)
     self.fields['venture'].choices = all_ventures()
     self.fields['venture_role'].choices = all_roles()