From c9f566dde77a2b7fc922b1b3cceb7f3cde83fbcc Mon Sep 17 00:00:00 2001 From: Tihomir Trifonov Date: Sun, 11 Mar 2012 17:11:53 +0200 Subject: [PATCH] Changed CharField to IntegerField in forms where the actual value is expected to be integer. Fixes bug 950550 Change-Id: I8a78284ae8513c3a607b2ecad1ea36db2c247c56 --- .../nova/images_and_snapshots/images/forms.py | 5 ++--- horizon/dashboards/syspanel/flavors/forms.py | 18 ++++++++--------- horizon/dashboards/syspanel/projects/forms.py | 20 +++++++++---------- horizon/dashboards/syspanel/projects/tests.py | 16 +++++++-------- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/horizon/dashboards/nova/images_and_snapshots/images/forms.py b/horizon/dashboards/nova/images_and_snapshots/images/forms.py index 2e6d84ae133..39b5d1c33f8 100644 --- a/horizon/dashboards/nova/images_and_snapshots/images/forms.py +++ b/horizon/dashboards/nova/images_and_snapshots/images/forms.py @@ -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"), @@ -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: diff --git a/horizon/dashboards/syspanel/flavors/forms.py b/horizon/dashboards/syspanel/flavors/forms.py index cb940e07c3b..80953520766 100644 --- a/horizon/dashboards/syspanel/flavors/forms.py +++ b/horizon/dashboards/syspanel/flavors/forms.py @@ -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) diff --git a/horizon/dashboards/syspanel/projects/forms.py b/horizon/dashboards/syspanel/projects/forms.py index 59086a8561c..340dc28de0c 100644 --- a/horizon/dashboards/syspanel/projects/forms.py +++ b/horizon/dashboards/syspanel/projects/forms.py @@ -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: @@ -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'], diff --git a/horizon/dashboards/syspanel/projects/tests.py b/horizon/dashboards/syspanel/projects/tests.py index 4e3db2f3406..30d45579fdb 100644 --- a/horizon/dashboards/syspanel/projects/tests.py +++ b/horizon/dashboards/syspanel/projects/tests.py @@ -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')