Show proper warning message if security group rule is incomplete

* fixes bug 944472

Change-Id: I1a275385547f09dc317ba213767f80036b3bca7c
This commit is contained in:
Andy Chong 2012-03-04 12:19:10 +08:00
parent a6c39e5ba6
commit a23434dae4
3 changed files with 13 additions and 7 deletions

View File

@ -92,18 +92,25 @@ class AddRule(forms.SelfHandlingForm):
def clean(self):
cleaned_data = super(AddRule, self).clean()
to_port = cleaned_data.get("to_port", None)
from_port = cleaned_data.get("from_port", None)
if to_port == None:
msg = _('The "to" port number must not be empty.')
raise ValidationError(msg)
to_port = cleaned_data.get("to_port", None)
cidr = cleaned_data.get("cidr", None)
if from_port == None:
msg = _('The "from" port number must not be empty.')
msg = _('The "from" port number is invalid.')
raise ValidationError(msg)
if to_port == None:
msg = _('The "to" port number is invalid.')
raise ValidationError(msg)
if to_port < from_port:
msg = _('The "to" port number must be greater than or equal to '
'the "from" port number.')
raise ValidationError(msg)
if cidr == None:
msg = _('The "CIDR" is invalid')
raise ValidationError(msg)
return cleaned_data
def handle(self, request, data):

View File

@ -30,4 +30,4 @@ validate_ipv4_cidr = validators.RegexValidator(ipv4_cidr_re)
def validate_port_range(port):
if port not in range(-1, 65535):
raise ValidationError(u'%d is not a valid port number' % port)
raise ValidationError("Not a valid port number")

View File

@ -817,7 +817,6 @@ tr.terminated {
form div.clearfix.error {
width: 330px;
padding: 10px 10px;
}
/* Region selector in header */