Skip to content

Commit

Permalink
[chores] Miscellaneous uppdates
Browse files Browse the repository at this point in the history
  • Loading branch information
pandafy committed Aug 1, 2024
1 parent f9ee37d commit f26be19
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions openwisp_controller/config/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,11 +749,11 @@ def _change_device_status(self, request, queryset, method):
)
self._message_user_device_status(request, error_devices, method, messages.ERROR)

@admin.actions(description=_('Deactivate selected devices'), permissions=['change'])
@admin.action(description=_('Deactivate selected devices'), permissions=['change'])
def deactivate_device(self, request, queryset):
self._change_device_status(request, queryset, 'deactivate')

@admin.actions(description=_('Activate selected devices'), permissions=['change'])
@admin.action(description=_('Activate selected devices'), permissions=['change'])
def activate_device(self, request, queryset):
self._change_device_status(request, queryset, 'activate')

Expand Down
5 changes: 2 additions & 3 deletions openwisp_controller/config/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2041,7 +2041,6 @@ def test_device_changelist_activate_deactivate_admin_action_security(
class TestTransactionAdmin(
CreateConfigTemplateMixin,
TestAdminMixin,
TestOrganizationMixin,
TransactionTestCase,
):
app_label = 'config'
Expand Down Expand Up @@ -2115,7 +2114,7 @@ def test_device_with_config_change_deactivate_deactivate(self):
self.assertNotContains(response, self._deactivate_btn_html)
self.assertContains(response, self._activate_btn_html)
# Verify adding a new DeviceLocation and DeviceConnection is not allowed
self.assertContains(response, '-TOTAL_FORMS" value="0"', count=3)
self.assertContains(response, '-TOTAL_FORMS" value="0"', count=2)
# Verify deleting existing Inline objects is not allowed
self.assertNotContains(response, '<span class="delete"><input type="checkbox" ')

Expand Down Expand Up @@ -2153,7 +2152,7 @@ def test_device_without_config_change_activate_deactivate(self):
self.assertNotContains(response, self._save_btn_html)
self.assertNotContains(response, self._deactivate_btn_html)
# Verify adding a new inline objects is not allowed
self.assertContains(response, '-TOTAL_FORMS" value="0"', count=4)
self.assertContains(response, '-TOTAL_FORMS" value="0"', count=3)

def _test_device_changelist_activate_deactivate_admin_action(
self, method='activate', is_initially_deactivated=True
Expand Down
1 change: 0 additions & 1 deletion openwisp_controller/config/tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,6 @@ def test_create_default_config_existing(self):

class TestTransactionDevice(
CreateConfigTemplateMixin,
TestOrganizationMixin,
AssertNumQueriesSubTestMixin,
CreateDeviceGroupMixin,
TransactionTestCase,
Expand Down
2 changes: 1 addition & 1 deletion openwisp_controller/connection/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def has_change_permission(self, request, obj):
return False


class CommandWritableInline(admin.StackedInline):
class CommandWritableInline(DeactivatedDeviceReadOnlyMixin, admin.StackedInline):
model = Command
extra = 1
form = CommandForm
Expand Down

0 comments on commit f26be19

Please sign in to comment.