Skip to content

Commit

Permalink
Changed CharField to IntegerField in forms
Browse files Browse the repository at this point in the history
where the actual value is expected to be integer.

Fixes bug 950550

Change-Id: I8a78284ae8513c3a607b2ecad1ea36db2c247c56
  • Loading branch information
ttrifonov committed Mar 11, 2012
1 parent 24f6bc5 commit c9f566d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 30 deletions.
5 changes: 2 additions & 3 deletions horizon/dashboards/nova/images_and_snapshots/images/forms.py
Expand Up @@ -99,10 +99,9 @@ class LaunchForm(forms.SelfHandlingForm):
required=False,
help_text=_("Which keypair to use for "
"authentication."))
count = forms.CharField(label=_("Instance Count"),
count = forms.IntegerField(label=_("Instance Count"),
required=True,
initial=1,
widget=forms.TextInput(),
help_text=_("Number of instances to launch."))
security_groups = forms.MultipleChoiceField(
label=_("Security Groups"),
Expand Down Expand Up @@ -156,7 +155,7 @@ def handle(self, request, data):
normalize_newlines(data.get('user_data')),
data.get('security_groups'),
dev_mapping,
instance_count=int(data.get('count')))
instance_count=data.get('count'))
messages.success(request,
_('Instance "%s" launched.') % data["name"])
except:
Expand Down
18 changes: 9 additions & 9 deletions horizon/dashboards/syspanel/flavors/forms.py
Expand Up @@ -35,19 +35,19 @@ class CreateFlavor(forms.SelfHandlingForm):
# flavorid is required in novaclient
flavor_id = forms.IntegerField(label=_("Flavor ID"))
name = forms.CharField(max_length="25", label=_("Name"))
vcpus = forms.CharField(max_length="5", label=_("VCPUs"))
memory_mb = forms.CharField(max_length="5", label=_("Memory MB"))
disk_gb = forms.CharField(max_length="5", label=_("Root Disk GB"))
eph_gb = forms.CharField(max_length="5", label=_("Ephemeral Disk GB"))
vcpus = forms.IntegerField(label=_("VCPUs"))
memory_mb = forms.IntegerField(label=_("Memory MB"))
disk_gb = forms.IntegerField(label=_("Root Disk GB"))
eph_gb = forms.IntegerField(label=_("Ephemeral Disk GB"))

def handle(self, request, data):
api.flavor_create(request,
data['name'],
int(data['memory_mb']),
int(data['vcpus']),
int(data['disk_gb']),
int(data['flavor_id']),
ephemeral=int(data['eph_gb']))
data['memory_mb'],
data['vcpus'],
data['disk_gb'],
data['flavor_id'],
ephemeral=data['eph_gb'])
msg = _('%s was successfully added to flavors.') % data['name']
LOG.info(msg)
messages.success(request, msg)
Expand Down
20 changes: 10 additions & 10 deletions horizon/dashboards/syspanel/projects/forms.py
Expand Up @@ -107,16 +107,16 @@ def handle(self, request, data):
class UpdateQuotas(forms.SelfHandlingForm):
tenant_id = forms.CharField(label=_("ID (name)"),
widget=forms.TextInput(attrs={'readonly': 'readonly'}))
metadata_items = forms.CharField(label=_("Metadata Items"))
injected_files = forms.CharField(label=_("Injected Files"))
injected_file_content_bytes = forms.CharField(label=_("Injected File "
metadata_items = forms.IntegerField(label=_("Metadata Items"))
injected_files = forms.IntegerField(label=_("Injected Files"))
injected_file_content_bytes = forms.IntegerField(label=_("Injected File "
"Content Bytes"))
cores = forms.CharField(label=_("VCPUs"))
instances = forms.CharField(label=_("Instances"))
volumes = forms.CharField(label=_("Volumes"))
gigabytes = forms.CharField(label=_("Gigabytes"))
ram = forms.CharField(label=_("RAM (in MB)"))
floating_ips = forms.CharField(label=_("Floating IPs"))
cores = forms.IntegerField(label=_("VCPUs"))
instances = forms.IntegerField(label=_("Instances"))
volumes = forms.IntegerField(label=_("Volumes"))
gigabytes = forms.IntegerField(label=_("Gigabytes"))
ram = forms.IntegerField(label=_("RAM (in MB)"))
floating_ips = forms.IntegerField(label=_("Floating IPs"))

def handle(self, request, data):
try:
Expand All @@ -126,7 +126,7 @@ def handle(self, request, data):
injected_file_content_bytes=data['injected_file_content_bytes'],
volumes=data['volumes'],
gigabytes=data['gigabytes'],
ram=int(data['ram']),
ram=data['ram'],
floating_ips=data['floating_ips'],
instances=data['instances'],
injected_files=data['injected_files'],
Expand Down
16 changes: 8 additions & 8 deletions horizon/dashboards/syspanel/projects/tests.py
Expand Up @@ -39,15 +39,15 @@ def test_index(self):
def test_modify_quota(self):
tenant = self.tenants.first()
quota = self.quotas.first()
quota_data = {"metadata_items": '1',
"injected_files": '1',
"injected_file_content_bytes": '1',
"cores": '1',
"instances": '1',
"volumes": '1',
"gigabytes": '1',
quota_data = {"metadata_items": 1,
"injected_files": 1,
"injected_file_content_bytes": 1,
"cores": 1,
"instances": 1,
"volumes": 1,
"gigabytes": 1,
"ram": 1,
"floating_ips": '1'}
"floating_ips": 1}
self.mox.StubOutWithMock(api.keystone, 'tenant_get')
self.mox.StubOutWithMock(api.nova, 'tenant_quota_get')
self.mox.StubOutWithMock(api.nova, 'tenant_quota_update')
Expand Down

0 comments on commit c9f566d

Please sign in to comment.