Use integer instead of string for form max_length
This is a follow-up patch of a comment in https://review.openstack.org/#/c/119134/ Change-Id: I87f0a5698e5ccde251eb9cd9c1280291f5d746e0
This commit is contained in:
parent
874af9b63c
commit
62a0ec2659
@ -66,7 +66,7 @@ class FormMixinTests(test.TestCase):
|
||||
|
||||
class TestForm(forms.SelfHandlingForm):
|
||||
|
||||
name = forms.CharField(max_length="255")
|
||||
name = forms.CharField(max_length=255)
|
||||
|
||||
def handle(self, request, data):
|
||||
return True
|
||||
|
@ -36,7 +36,7 @@ class CreateExtraSpec(forms.SelfHandlingForm):
|
||||
'class': 'switchable',
|
||||
'data-slug': 'keys'}))
|
||||
key = forms.RegexField(
|
||||
max_length="255",
|
||||
max_length=255,
|
||||
label=_("Key"),
|
||||
required=False,
|
||||
regex=_extraspec_name_regex,
|
||||
@ -47,7 +47,7 @@ class CreateExtraSpec(forms.SelfHandlingForm):
|
||||
'class': 'switched',
|
||||
'data-switch-on': 'keys',
|
||||
'data-keys-custom': _('Key')}))
|
||||
value = forms.CharField(max_length="255", label=_("Value"))
|
||||
value = forms.CharField(max_length=255, label=_("Value"))
|
||||
flavor_id = forms.CharField(widget=forms.widgets.HiddenInput)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -82,7 +82,7 @@ class CreateExtraSpec(forms.SelfHandlingForm):
|
||||
|
||||
class EditExtraSpec(forms.SelfHandlingForm):
|
||||
key = forms.CharField(widget=forms.widgets.HiddenInput)
|
||||
value = forms.CharField(max_length="255", label=_("Value"))
|
||||
value = forms.CharField(max_length=255, label=_("Value"))
|
||||
flavor_id = forms.CharField(widget=forms.widgets.HiddenInput)
|
||||
|
||||
def handle(self, request, data):
|
||||
|
@ -53,7 +53,7 @@ class CreateNetwork(forms.SelfHandlingForm):
|
||||
'data-slug': 'network_type'
|
||||
}))
|
||||
physical_network = forms.CharField(
|
||||
max_length="255",
|
||||
max_length=255,
|
||||
label=_("Physical Network"),
|
||||
help_text=_("The name of the physical network over which the "
|
||||
"virtual network is implemented."),
|
||||
|
@ -20,8 +20,8 @@ from horizon import messages
|
||||
|
||||
|
||||
class CreateExtraSpec(forms.SelfHandlingForm):
|
||||
key = forms.CharField(max_length="255", label=_("Key"))
|
||||
value = forms.CharField(max_length="255", label=_("Value"))
|
||||
key = forms.CharField(max_length=255, label=_("Key"))
|
||||
value = forms.CharField(max_length=255, label=_("Value"))
|
||||
|
||||
def handle(self, request, data):
|
||||
type_id = self.initial['type_id']
|
||||
@ -38,7 +38,7 @@ class CreateExtraSpec(forms.SelfHandlingForm):
|
||||
|
||||
|
||||
class EditExtraSpec(forms.SelfHandlingForm):
|
||||
value = forms.CharField(max_length="255", label=_("Value"))
|
||||
value = forms.CharField(max_length=255, label=_("Value"))
|
||||
|
||||
def handle(self, request, data):
|
||||
key = self.initial['key']
|
||||
|
@ -37,7 +37,7 @@ KEYPAIR_ERROR_MESSAGES = {'invalid': _('Key pair name may '
|
||||
|
||||
|
||||
class CreateKeypair(forms.SelfHandlingForm):
|
||||
name = forms.RegexField(max_length="255",
|
||||
name = forms.RegexField(max_length=255,
|
||||
label=_("Key Pair Name"),
|
||||
regex=KEYPAIR_NAME_REGEX,
|
||||
error_messages=KEYPAIR_ERROR_MESSAGES)
|
||||
@ -47,7 +47,7 @@ class CreateKeypair(forms.SelfHandlingForm):
|
||||
|
||||
|
||||
class ImportKeypair(forms.SelfHandlingForm):
|
||||
name = forms.RegexField(max_length="255",
|
||||
name = forms.RegexField(max_length=255,
|
||||
label=_("Key Pair Name"),
|
||||
regex=KEYPAIR_NAME_REGEX,
|
||||
error_messages=KEYPAIR_ERROR_MESSAGES)
|
||||
|
@ -37,7 +37,7 @@ IMAGE_FORMAT_CHOICES = IMAGE_BACKEND_SETTINGS.get('image_formats', [])
|
||||
|
||||
|
||||
class CreateImageForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length="255", label=_("Name"))
|
||||
name = forms.CharField(max_length=255, label=_("Name"))
|
||||
description = forms.CharField(widget=forms.widgets.Textarea(
|
||||
attrs={'class': 'modal-body-fixed-width', 'rows': 4}),
|
||||
label=_("Description"),
|
||||
@ -52,7 +52,7 @@ class CreateImageForm(forms.SelfHandlingForm):
|
||||
'class': 'switchable',
|
||||
'data-slug': 'source'}))
|
||||
|
||||
copy_from = forms.CharField(max_length="255",
|
||||
copy_from = forms.CharField(max_length=255,
|
||||
label=_("Image Location"),
|
||||
help_text=_("An external (HTTP) URL to load "
|
||||
"the image from."),
|
||||
@ -80,7 +80,7 @@ class CreateImageForm(forms.SelfHandlingForm):
|
||||
widget=forms.Select(attrs={
|
||||
'class': 'switchable',
|
||||
'ng-model': 'diskFormat'}))
|
||||
architecture = forms.CharField(max_length="255", label=_("Architecture"),
|
||||
architecture = forms.CharField(max_length=255, label=_("Architecture"),
|
||||
required=False)
|
||||
minimum_disk = forms.IntegerField(label=_("Minimum Disk (GB)"),
|
||||
min_value=0,
|
||||
@ -192,20 +192,20 @@ class CreateImageForm(forms.SelfHandlingForm):
|
||||
|
||||
class UpdateImageForm(forms.SelfHandlingForm):
|
||||
image_id = forms.CharField(widget=forms.HiddenInput())
|
||||
name = forms.CharField(max_length="255", label=_("Name"))
|
||||
name = forms.CharField(max_length=255, label=_("Name"))
|
||||
description = forms.CharField(
|
||||
widget=forms.widgets.Textarea(),
|
||||
label=_("Description"),
|
||||
required=False,
|
||||
)
|
||||
kernel = forms.CharField(
|
||||
max_length="36",
|
||||
max_length=36,
|
||||
label=_("Kernel ID"),
|
||||
required=False,
|
||||
widget=forms.TextInput(attrs={'readonly': 'readonly'}),
|
||||
)
|
||||
ramdisk = forms.CharField(
|
||||
max_length="36",
|
||||
max_length=36,
|
||||
label=_("Ramdisk ID"),
|
||||
required=False,
|
||||
widget=forms.TextInput(attrs={'readonly': 'readonly'}),
|
||||
|
@ -30,7 +30,7 @@ class CreateSnapshot(forms.SelfHandlingForm):
|
||||
instance_id = forms.CharField(label=_("Instance ID"),
|
||||
widget=forms.HiddenInput(),
|
||||
required=False)
|
||||
name = forms.CharField(max_length="255", label=_("Snapshot Name"))
|
||||
name = forms.CharField(max_length=255, label=_("Snapshot Name"))
|
||||
|
||||
def handle(self, request, data):
|
||||
try:
|
||||
|
@ -32,7 +32,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CreateForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length="255", label=_("Router Name"))
|
||||
name = forms.CharField(max_length=255, label=_("Router Name"))
|
||||
mode = forms.ChoiceField(label=_("Router Type"))
|
||||
failure_url = 'horizon:project:routers:index'
|
||||
|
||||
|
@ -250,7 +250,7 @@ class CreateStackForm(forms.SelfHandlingForm):
|
||||
parameters = forms.CharField(
|
||||
widget=forms.widgets.HiddenInput)
|
||||
stack_name = forms.RegexField(
|
||||
max_length='255',
|
||||
max_length=255,
|
||||
label=_('Stack Name'),
|
||||
help_text=_('Name of the stack to create.'),
|
||||
regex=r"^[a-zA-Z][a-zA-Z0-9_.-]*$",
|
||||
|
@ -30,12 +30,12 @@ from openstack_dashboard.dashboards.project.containers \
|
||||
|
||||
|
||||
class CreateBackupForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length="255", label=_("Backup Name"))
|
||||
name = forms.CharField(max_length=255, label=_("Backup Name"))
|
||||
description = forms.CharField(widget=forms.Textarea,
|
||||
label=_("Description"),
|
||||
required=False)
|
||||
container_name = forms.CharField(
|
||||
max_length="255",
|
||||
max_length=255,
|
||||
label=_("Container Name"),
|
||||
validators=[containers_forms.no_slash_validator],
|
||||
required=False)
|
||||
|
@ -22,7 +22,7 @@ from openstack_dashboard.api import cinder
|
||||
|
||||
|
||||
class UpdateForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length="255", label=_("Snapshot Name"))
|
||||
name = forms.CharField(max_length=255, label=_("Snapshot Name"))
|
||||
description = forms.CharField(widget=forms.Textarea,
|
||||
label=_("Description"), required=False)
|
||||
|
||||
|
@ -43,7 +43,7 @@ DEFAULT_CONTAINER_FORMAT = 'bare'
|
||||
|
||||
|
||||
class CreateForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length="255", label=_("Volume Name"))
|
||||
name = forms.CharField(max_length=255, label=_("Volume Name"))
|
||||
description = forms.CharField(widget=forms.Textarea(
|
||||
attrs={'class': 'modal-body-fixed-width'}),
|
||||
label=_("Description"), required=False)
|
||||
@ -462,7 +462,7 @@ class AttachForm(forms.SelfHandlingForm):
|
||||
|
||||
|
||||
class CreateSnapshotForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length="255", label=_("Snapshot Name"))
|
||||
name = forms.CharField(max_length=255, label=_("Snapshot Name"))
|
||||
description = forms.CharField(widget=forms.Textarea,
|
||||
label=_("Description"), required=False)
|
||||
|
||||
@ -500,7 +500,7 @@ class CreateSnapshotForm(forms.SelfHandlingForm):
|
||||
|
||||
|
||||
class UpdateForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(max_length="255", label=_("Volume Name"))
|
||||
name = forms.CharField(max_length=255, label=_("Volume Name"))
|
||||
description = forms.CharField(widget=forms.Textarea,
|
||||
label=_("Description"), required=False)
|
||||
|
||||
@ -524,7 +524,7 @@ class UploadToImageForm(forms.SelfHandlingForm):
|
||||
name = forms.CharField(label=_('Volume Name'),
|
||||
widget=forms.TextInput(
|
||||
attrs={'readonly': 'readonly'}))
|
||||
image_name = forms.CharField(max_length="255", label=_('Image Name'))
|
||||
image_name = forms.CharField(max_length=255, label=_('Image Name'))
|
||||
disk_format = forms.ChoiceField(label=_('Disk Format'),
|
||||
widget=forms.Select(),
|
||||
required=False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user