MCPcopy
hub / github.com/retspen/webvirtcloud / ComputeAddSocketForm

Class ComputeAddSocketForm

computes/forms.py:149–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147
148
149class ComputeAddSocketForm(forms.Form):
150 name = forms.CharField(error_messages={'required': _('No hostname has been entered')},
151 max_length=20)
152
153 def clean_name(self):
154 name = self.cleaned_data['name']
155 have_symbol = re.match('[^a-zA-Z0-9._-]+', name)
156 if have_symbol:
157 raise forms.ValidationError(_('The host name must not contain any special characters'))
158 elif len(name) > 20:
159 raise forms.ValidationError(_('The host name must not exceed 20 characters'))
160 try:
161 Compute.objects.get(name=name)
162 except Compute.DoesNotExist:
163 return name
164 raise forms.ValidationError(_('This host is already connected'))

Callers 1

computesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected