13
13
# limitations under the License.
14
14
from crispy_forms .bootstrap import AppendedText
15
15
from crispy_forms .helper import FormHelper
16
- from crispy_forms .layout import Layout , Field , Column , Row , Div
16
+ from crispy_forms .layout import Layout , Field , HTML , Column , Row , Div
17
17
from django import forms
18
18
from django .forms import modelformset_factory
19
19
from django .core .exceptions import ValidationError
@@ -46,8 +46,21 @@ def _crispy_helper(instance):
46
46
),
47
47
Div (
48
48
Row (
49
- Column ('public_ip' , css_class = 'col-md-5' ),
50
- Column ('provide_vpn' , css_class = 'col-md-5' ),
49
+ Column ('public_ip' , css_class = 'col-md-6' ),
50
+ Column ('provide_vpn' , css_class = 'col-md-4' ),
51
+ ),
52
+ Row (
53
+ HTML ("""<button type="button" class="btn btn-link bind-row-collapser collapsed"
54
+ aria-expanded="false" aria-controls="bind-row">
55
+ Show binding options for NAT
56
+ <i class="fa fa-plus-circle"></i>
57
+ <i class="fa fa-minus-circle"></i>
58
+ </button>""" )
59
+ ),
60
+ Row (
61
+ Column (AppendedText ('bind_ip' , '<span class="fa fa-external-link-square"/>' ),
62
+ css_class = 'col-md-6' ),
63
+ css_class = "bind-row"
51
64
),
52
65
css_class = "card-body" , css_id = "user-ap-card-body" ,
53
66
),
@@ -104,6 +117,12 @@ class UserASForm(forms.Form):
104
117
label = "Public IP" ,
105
118
help_text = "Public IP Address to be used for connections to child ASes"
106
119
)
120
+ bind_ip = forms .GenericIPAddressField (
121
+ required = False ,
122
+ label = "Bind IP address" ,
123
+ help_text = "(Optional) Specify the local IP "
124
+ "if your border router is behind a NAT/firewall etc." ,
125
+ )
107
126
provide_vpn = forms .BooleanField (
108
127
required = False ,
109
128
label = "Provide VPN" ,
@@ -144,6 +163,7 @@ def __init__(self, data=None, *args, **kwargs):
144
163
'label' : self .instance .label ,
145
164
'installation_type' : self .instance .installation_type ,
146
165
'public_ip' : host .public_ip ,
166
+ 'bind_ip' : host .bind_ip ,
147
167
'become_user_ap' : is_ap ,
148
168
'provide_vpn' : has_vpn
149
169
})
@@ -193,6 +213,7 @@ def save(self, commit=True):
193
213
installation_type = self .cleaned_data ['installation_type' ],
194
214
label = self .cleaned_data ['label' ],
195
215
public_ip = self .cleaned_data ['public_ip' ],
216
+ bind_ip = self .cleaned_data ['bind_ip' ],
196
217
wants_user_ap = self .cleaned_data ['become_user_ap' ],
197
218
wants_vpn = self .cleaned_data ['provide_vpn' ],
198
219
)
@@ -203,6 +224,7 @@ def save(self, commit=True):
203
224
installation_type = self .cleaned_data ['installation_type' ],
204
225
label = self .cleaned_data ['label' ],
205
226
public_ip = self .cleaned_data ['public_ip' ],
227
+ bind_ip = self .cleaned_data ['bind_ip' ],
206
228
wants_user_ap = self .cleaned_data ['become_user_ap' ],
207
229
wants_vpn = self .cleaned_data ['provide_vpn' ],
208
230
)
0 commit comments