Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openwisp_controller/config/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def update(self, instance, validated_data):
instance.config.vpnclient_set.exclude(vpn__in=vpn_list).delete()
instance.config.templates.clear()
instance.config.templates.add(*[])
instance.config.save()

elif hasattr(instance, 'config') and validated_data.get('organization'):
if instance.organization != validated_data.get('organization'):
Expand Down
7 changes: 6 additions & 1 deletion openwisp_controller/config/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def test_device_put_api(self):
'organization': org.pk,
'mac_address': d1.mac_address,
'config': {
'backend': 'netjsonconfig.OpenWrt',
'backend': 'netjsonconfig.OpenWisp',
'status': 'modified',
'templates': [],
'context': '{}',
Expand All @@ -212,6 +212,11 @@ def test_device_put_api(self):
self.assertEqual(r.status_code, 200)
self.assertEqual(r.data['name'], 'change-test-device')
self.assertEqual(r.data['organization'], org.pk)
self.assertEqual(r.data['config']['backend'], 'netjsonconfig.OpenWisp')
d1.refresh_from_db()
self.assertEqual(d1.name, 'change-test-device')
self.assertEqual(d1.organization, org)
self.assertEqual(d1.config.backend, 'netjsonconfig.OpenWisp')

# test device with VPN-client type template assigned to it
def test_device_with_vpn_client_template_assigned(self):
Expand Down