def __init__(self, url, asset, *args, **kwargs): super(AddPortForm, self).__init__(*args, **kwargs) self.asset = asset peer = parse_as_field(args, kwargs, 'peer', Port) self.fields['as_peer'] = forms.CharField(widget=AutoSuggestInput( model=peer, source=url, options={ 'minChars': 3, 'selectedValuesProp': "id", 'searchObjProps': "", 'extraParams': '&nowrap=1', 'selectionLimit': 1, 'asHtmlName': 'peer', 'selectedItemProp': "display_name" } ), required=False, label="Peer", help_text="Type a substring of 3 or more characters of the peer's asset name or address. To narrow down the results to the ports containing a specific substring type space and the port name. (e.g. .58.130 mgmt)" ) if asset.type == const.TYPE_F5: for choice in self.fields['type'].choices: if choice[0] == const.PORT_NETWORK: self.fields['type'].choices.remove(choice)
def __init__(self, url, *args, **kwargs): ''' @param url: The URL for the 'user' AutoSuggest field. ''' super(AssignAssetForm, self).__init__(*args, **kwargs) user = parse_as_field(args, kwargs, 'user', User) self.fields['as_user'] = forms.CharField(widget=AutoSuggestInput( model=user, source=url, options={ 'minChars': 2, 'selectedItemProp': "display_name", 'selectedValuesProp': "id", 'searchObjProps': "first_name,last_name,username", 'asHtmlName': 'user', 'selectionLimit': 1 } ), required=False, label="Assigned to" )
def __init__(self, url, *args, **kwargs): super(ConnectPortForm, self).__init__(*args, **kwargs) peer = parse_as_field(args, kwargs, 'peer', Port) # Reflesh the as_peer port with a real AutoSuggest field instance. self.fields['as_peer'] = forms.CharField(widget=AutoSuggestInput( model=peer, source=url, options={ 'minChars': 3, 'selectedValuesProp': "id", 'searchObjProps': "", 'extraParams': '&nowrap=1', 'selectionLimit': 1, 'asHtmlName': 'peer', 'selectedItemProp': "display_name" } ), required=False, label="Peer", help_text="Type a substring of 3 or more characters of the peer's asset name or address. To narrow down the results to the ports containing a specific substring type space and the port name. (e.g. .58.130 mgmt)" )
def __init__(self, url, *args, **kwargs): ''' @param url: The URL for the 'owner' AutoSuggest field. ''' super(ChangeOwnershipForm, self).__init__(*args, **kwargs) user = parse_as_field(args, kwargs, 'owner', User) self.fields['as_owner'] = forms.CharField(widget=AutoSuggestInput( model=user, source=url, options={ 'minChars': 2, 'selectedItemProp': "display_name", 'selectedValuesProp': "id", 'searchObjProps': "first_name,last_name,username", 'asHtmlName': 'owner', 'selectionLimit': 1 } ), required=False, label="Owner", help_text="<b>NB</b> that once you give up the ownership of your assets you won't be able to get it back unless you ask the new owner or an administrator." )
def __init__(self, url, *args, **kwargs): ''' @param url: The URL for the 'owner' AutoSuggest field. ''' super(AddAssetForm, self).__init__(*args, **kwargs) user = parse_as_field(args, kwargs, 'owner', User) self.fields['as_owner'] = forms.CharField(widget=AutoSuggestInput( model=user, source=url, autofocus=False, options={ 'minChars': 2, 'selectedItemProp': "display_name", 'selectedValuesProp': "id", 'searchObjProps': "first_name,last_name,username", 'asHtmlName': 'owner', 'selectionLimit': 1 } ), required=False, label="Owner", help_text="If not specified, you will be the default owner for this asset." )