Fixes #1579: Devices already assigned to a cluster cannot be added to a different cluster

This commit is contained in:
Jeremy Stretch
2017-10-17 09:59:35 -04:00
parent 6f2f8697ae
commit 34f1a9ebfb
2 changed files with 7 additions and 2 deletions

View File

@@ -210,7 +210,7 @@ class ClusterAddDevicesForm(BootstrapMixin, ChainedFieldsMixin, forms.Form):
# If the Cluster is assigned to a Site, all Devices must be assigned to that Site.
if self.cluster.site is not None:
for device in self.cleaned_data.get('devices'):
for device in self.cleaned_data.get('devices', []):
if device.site != self.cluster.site:
raise ValidationError({
'devices': "{} belongs to a different site ({}) than the cluster ({})".format(