Merge pull request #1845 from normanjaeckel/ConfigFix
Fixed server error in config update view. Fixed #1828.
This commit is contained in:
commit
82f5239b8c
@ -475,7 +475,9 @@ class ConfigViewSet(ViewSet):
|
||||
Example: {"value": 42}
|
||||
"""
|
||||
key = kwargs['pk']
|
||||
value = request.data['value']
|
||||
value = request.data.get('value')
|
||||
if value is None:
|
||||
raise ValidationError({'detail': 'Invalid input. Config value is missing.'})
|
||||
|
||||
# Validate and change value.
|
||||
try:
|
||||
|
@ -154,6 +154,14 @@ class ConfigViewSet(TestCase):
|
||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||
self.assertEqual(response.data, {'detail': 'Invalid input.'})
|
||||
|
||||
def test_update_only_with_key(self):
|
||||
self.client = APIClient()
|
||||
self.client.login(username='admin', password='admin')
|
||||
response = self.client.put(
|
||||
reverse('config-detail', args=['test_var_Xeiizi7ooH8Thuk5aida']))
|
||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||
self.assertEqual(response.data, {'detail': 'Invalid input. Config value is missing.'})
|
||||
|
||||
|
||||
def validator_for_testing(value):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user