feat(device): Prevent devices from being set global

!5
This commit is contained in:
2024-05-17 22:20:30 +09:30
parent 0e69a0accc
commit aade1e80d7
3 changed files with 21 additions and 2 deletions

View File

@ -20,3 +20,11 @@ def test_device_software_action(user):
"""Ensure only software that is from the same organization or is global can be added to the device
"""
pass
@pytest.mark.skip(reason="to be written")
def test_device_not_global(user):
"""Devices are not global items.
Ensure that a device can't be set to be global.
"""
pass

View File

@ -20,3 +20,12 @@ def test_software_update_is_global_no_change(user):
"""
pass
@pytest.mark.skip(reason="to be written")
def test_software_prevent_delete_if_used(user):
"""Any software in use by a device must not be deleted.
i.e. A device has an action set for the software.
"""
pass

View File

@ -45,7 +45,6 @@ class View(OrganizationPermission, generic.UpdateView):
'serial_number',
'uuid',
'device_type',
'is_global'
]
context_object_name = "device"
@ -110,9 +109,12 @@ class Add(PermissionRequiredMixin, OrganizationPermission, generic.CreateView):
'uuid',
'device_type',
'organization',
'is_global'
]
def form_valid(self, form):
form.instance.is_global = False
return super().form_valid(form)
def get_success_url(self, **kwargs):