Merge "Changed CharField to IntegerField in forms where the actual value is expected to be integer."

This commit is contained in:
Jenkins 2012-03-12 02:15:53 +00:00 committed by Gerrit Code Review
commit bf217e8381
4 changed files with 29 additions and 30 deletions

View File

@ -99,10 +99,9 @@ class LaunchForm(forms.SelfHandlingForm):
required=False, required=False,
help_text=_("Which keypair to use for " help_text=_("Which keypair to use for "
"authentication.")) "authentication."))
count = forms.CharField(label=_("Instance Count"), count = forms.IntegerField(label=_("Instance Count"),
required=True, required=True,
initial=1, initial=1,
widget=forms.TextInput(),
help_text=_("Number of instances to launch.")) help_text=_("Number of instances to launch."))
security_groups = forms.MultipleChoiceField( security_groups = forms.MultipleChoiceField(
label=_("Security Groups"), label=_("Security Groups"),
@ -156,7 +155,7 @@ class LaunchForm(forms.SelfHandlingForm):
normalize_newlines(data.get('user_data')), normalize_newlines(data.get('user_data')),
data.get('security_groups'), data.get('security_groups'),
dev_mapping, dev_mapping,
instance_count=int(data.get('count'))) instance_count=data.get('count'))
messages.success(request, messages.success(request,
_('Instance "%s" launched.') % data["name"]) _('Instance "%s" launched.') % data["name"])
except: except:

View File

@ -35,19 +35,19 @@ class CreateFlavor(forms.SelfHandlingForm):
# flavorid is required in novaclient # flavorid is required in novaclient
flavor_id = forms.IntegerField(label=_("Flavor ID")) flavor_id = forms.IntegerField(label=_("Flavor ID"))
name = forms.CharField(max_length="25", label=_("Name")) name = forms.CharField(max_length="25", label=_("Name"))
vcpus = forms.CharField(max_length="5", label=_("VCPUs")) vcpus = forms.IntegerField(label=_("VCPUs"))
memory_mb = forms.CharField(max_length="5", label=_("Memory MB")) memory_mb = forms.IntegerField(label=_("Memory MB"))
disk_gb = forms.CharField(max_length="5", label=_("Root Disk GB")) disk_gb = forms.IntegerField(label=_("Root Disk GB"))
eph_gb = forms.CharField(max_length="5", label=_("Ephemeral Disk GB")) eph_gb = forms.IntegerField(label=_("Ephemeral Disk GB"))
def handle(self, request, data): def handle(self, request, data):
api.flavor_create(request, api.flavor_create(request,
data['name'], data['name'],
int(data['memory_mb']), data['memory_mb'],
int(data['vcpus']), data['vcpus'],
int(data['disk_gb']), data['disk_gb'],
int(data['flavor_id']), data['flavor_id'],
ephemeral=int(data['eph_gb'])) ephemeral=data['eph_gb'])
msg = _('%s was successfully added to flavors.') % data['name'] msg = _('%s was successfully added to flavors.') % data['name']
LOG.info(msg) LOG.info(msg)
messages.success(request, msg) messages.success(request, msg)

View File

@ -107,16 +107,16 @@ class UpdateTenant(forms.SelfHandlingForm):
class UpdateQuotas(forms.SelfHandlingForm): class UpdateQuotas(forms.SelfHandlingForm):
tenant_id = forms.CharField(label=_("ID (name)"), tenant_id = forms.CharField(label=_("ID (name)"),
widget=forms.TextInput(attrs={'readonly': 'readonly'})) widget=forms.TextInput(attrs={'readonly': 'readonly'}))
metadata_items = forms.CharField(label=_("Metadata Items")) metadata_items = forms.IntegerField(label=_("Metadata Items"))
injected_files = forms.CharField(label=_("Injected Files")) injected_files = forms.IntegerField(label=_("Injected Files"))
injected_file_content_bytes = forms.CharField(label=_("Injected File " injected_file_content_bytes = forms.IntegerField(label=_("Injected File "
"Content Bytes")) "Content Bytes"))
cores = forms.CharField(label=_("VCPUs")) cores = forms.IntegerField(label=_("VCPUs"))
instances = forms.CharField(label=_("Instances")) instances = forms.IntegerField(label=_("Instances"))
volumes = forms.CharField(label=_("Volumes")) volumes = forms.IntegerField(label=_("Volumes"))
gigabytes = forms.CharField(label=_("Gigabytes")) gigabytes = forms.IntegerField(label=_("Gigabytes"))
ram = forms.CharField(label=_("RAM (in MB)")) ram = forms.IntegerField(label=_("RAM (in MB)"))
floating_ips = forms.CharField(label=_("Floating IPs")) floating_ips = forms.IntegerField(label=_("Floating IPs"))
def handle(self, request, data): def handle(self, request, data):
try: try:
@ -126,7 +126,7 @@ class UpdateQuotas(forms.SelfHandlingForm):
injected_file_content_bytes=data['injected_file_content_bytes'], injected_file_content_bytes=data['injected_file_content_bytes'],
volumes=data['volumes'], volumes=data['volumes'],
gigabytes=data['gigabytes'], gigabytes=data['gigabytes'],
ram=int(data['ram']), ram=data['ram'],
floating_ips=data['floating_ips'], floating_ips=data['floating_ips'],
instances=data['instances'], instances=data['instances'],
injected_files=data['injected_files'], injected_files=data['injected_files'],

View File

@ -39,15 +39,15 @@ class TenantsViewTests(test.BaseAdminViewTests):
def test_modify_quota(self): def test_modify_quota(self):
tenant = self.tenants.first() tenant = self.tenants.first()
quota = self.quotas.first() quota = self.quotas.first()
quota_data = {"metadata_items": '1', quota_data = {"metadata_items": 1,
"injected_files": '1', "injected_files": 1,
"injected_file_content_bytes": '1', "injected_file_content_bytes": 1,
"cores": '1', "cores": 1,
"instances": '1', "instances": 1,
"volumes": '1', "volumes": 1,
"gigabytes": '1', "gigabytes": 1,
"ram": 1, "ram": 1,
"floating_ips": '1'} "floating_ips": 1}
self.mox.StubOutWithMock(api.keystone, 'tenant_get') self.mox.StubOutWithMock(api.keystone, 'tenant_get')
self.mox.StubOutWithMock(api.nova, 'tenant_quota_get') self.mox.StubOutWithMock(api.nova, 'tenant_quota_get')
self.mox.StubOutWithMock(api.nova, 'tenant_quota_update') self.mox.StubOutWithMock(api.nova, 'tenant_quota_update')