Help texts and dynamic label change for entering
security group rules. ICMP rules have different meanings for the from_port and to_port fields. Fixes bug 933636 Patch Set 3: fixed type cast in unit tests Change-Id: I745846a0fb054eb03efae102b40428889baed48f
This commit is contained in:
parent
2dcebb82ab
commit
404bda32b9
@ -53,12 +53,31 @@ class CreateGroup(forms.SelfHandlingForm):
|
|||||||
|
|
||||||
|
|
||||||
class AddRule(forms.SelfHandlingForm):
|
class AddRule(forms.SelfHandlingForm):
|
||||||
ip_protocol = forms.ChoiceField(choices=[('tcp', 'tcp'),
|
ip_protocol = forms.ChoiceField(label=_('IP protocol'),
|
||||||
|
choices=[('tcp', 'tcp'),
|
||||||
('udp', 'udp'),
|
('udp', 'udp'),
|
||||||
('icmp', 'icmp')])
|
('icmp', 'icmp')],
|
||||||
from_port = forms.CharField()
|
widget=forms.Select(attrs={'class':
|
||||||
to_port = forms.CharField()
|
'switchable'}))
|
||||||
cidr = forms.CharField()
|
from_port = forms.IntegerField(label=_("From port"),
|
||||||
|
help_text=_("TCP/UDP: Enter integer value "
|
||||||
|
"between 1 and 65535. ICMP: "
|
||||||
|
"enter a value for ICMP type "
|
||||||
|
"in the range (-1: 255)"),
|
||||||
|
widget=forms.TextInput(
|
||||||
|
attrs={'data': _('From port'),
|
||||||
|
'data-icmp': _('Type')}))
|
||||||
|
to_port = forms.IntegerField(label=_("To port"),
|
||||||
|
help_text=_("TCP/UDP: Enter integer value "
|
||||||
|
"between 1 and 65535. ICMP: "
|
||||||
|
"enter a value for ICMP code "
|
||||||
|
"in the range (-1: 255)"),
|
||||||
|
widget=forms.TextInput(
|
||||||
|
attrs={'data': _('To port'),
|
||||||
|
'data-icmp': _('Code')}))
|
||||||
|
cidr = forms.CharField(label=_("CIDR"),
|
||||||
|
help_text=_("Classless Inter-Domain Routing "
|
||||||
|
"(i.e. 192.168.0.0/24"))
|
||||||
# TODO (anthony) source group support
|
# TODO (anthony) source group support
|
||||||
# group_id = forms.CharField()
|
# group_id = forms.CharField()
|
||||||
|
|
||||||
|
@ -115,8 +115,8 @@ class SecurityGroupsViewTests(test.TestCase):
|
|||||||
api.security_group_rule_create(IsA(http.HttpRequest),
|
api.security_group_rule_create(IsA(http.HttpRequest),
|
||||||
sec_group.id,
|
sec_group.id,
|
||||||
rule.ip_protocol,
|
rule.ip_protocol,
|
||||||
rule.from_port,
|
int(rule.from_port),
|
||||||
rule.to_port,
|
int(rule.to_port),
|
||||||
rule.ip_range['cidr']).AndReturn(rule)
|
rule.ip_range['cidr']).AndReturn(rule)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
@ -139,8 +139,8 @@ class SecurityGroupsViewTests(test.TestCase):
|
|||||||
api.security_group_rule_create(IsA(http.HttpRequest),
|
api.security_group_rule_create(IsA(http.HttpRequest),
|
||||||
sec_group.id,
|
sec_group.id,
|
||||||
rule.ip_protocol,
|
rule.ip_protocol,
|
||||||
rule.from_port,
|
int(rule.from_port),
|
||||||
rule.to_port,
|
int(rule.to_port),
|
||||||
rule.ip_range['cidr']).AndRaise(exc)
|
rule.ip_range['cidr']).AndRaise(exc)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
|
@ -42,6 +42,20 @@ horizon.addInitFunction(function () {
|
|||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('select.switchable').live("change", (function(e){
|
||||||
|
var type = $(this).val();
|
||||||
|
$(this).closest('fieldset').find('input[type=text]').each(function(index, obj){
|
||||||
|
var label_val = "";
|
||||||
|
if ($(obj).attr("data-"+type)){
|
||||||
|
label_val = $(obj).attr("data-"+type);
|
||||||
|
} else if ($(obj).attr("data")){
|
||||||
|
label_val = $(obj).attr("data");
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
$('label[for='+ $(obj).attr('id') + ']').html(label_val);
|
||||||
|
});
|
||||||
|
})).change();
|
||||||
|
|
||||||
/* Twipsy tooltips */
|
/* Twipsy tooltips */
|
||||||
|
|
||||||
function getTwipsyTitle() {
|
function getTwipsyTitle() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user