Added config update view.
This commit is contained in:
parent
a604f36634
commit
6f02d769cc
@ -119,7 +119,7 @@ class ConfigViewSet(ViewSet):
|
|||||||
|
|
||||||
def retrieve(self, request, *args, **kwargs):
|
def retrieve(self, request, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Retrieves one config variable.
|
Retrieves one config variable. Everybody can see it.
|
||||||
"""
|
"""
|
||||||
# TODO: Check if we need permission check here.
|
# TODO: Check if we need permission check here.
|
||||||
key = kwargs['pk']
|
key = kwargs['pk']
|
||||||
@ -129,12 +129,17 @@ class ConfigViewSet(ViewSet):
|
|||||||
raise Http404
|
raise Http404
|
||||||
return Response(data)
|
return Response(data)
|
||||||
|
|
||||||
def update(self, request, pk=None):
|
def update(self, request, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
TODO
|
Updates one config variable. Only managers can do this.
|
||||||
"""
|
"""
|
||||||
if not request.user.has_perm('config.can_manage'):
|
if not request.user.has_perm('config.can_manage'):
|
||||||
self.permission_denied(request)
|
self.permission_denied(request)
|
||||||
else:
|
key = kwargs['pk']
|
||||||
# TODO: Implement update method
|
# Check if pk is a valid config variable key.
|
||||||
self.permission_denied(request)
|
if key not in config:
|
||||||
|
raise Http404
|
||||||
|
# Change value.
|
||||||
|
config[key] = request.data
|
||||||
|
# Return response.
|
||||||
|
return Response({'key': key, 'value': request.data})
|
||||||
|
Loading…
Reference in New Issue
Block a user