Пример #1
0
 def patch(self, request, lib_key_str):
     """
     Update a content library
     """
     key = LibraryLocatorV2.from_string(lib_key_str)
     api.require_permission_for_library_key(key, request.user, permissions.CAN_EDIT_THIS_CONTENT_LIBRARY)
     serializer = ContentLibraryUpdateSerializer(data=request.data, partial=True)
     serializer.is_valid(raise_exception=True)
     api.update_library(key, **serializer.validated_data)
     result = api.get_library(key)
     return Response(ContentLibraryMetadataSerializer(result).data)
Пример #2
0
 def patch(self, request, lib_key_str):
     """
     Update a content library
     """
     key = LibraryLocatorV2.from_string(lib_key_str)
     api.require_permission_for_library_key(key, request.user, permissions.CAN_EDIT_THIS_CONTENT_LIBRARY)
     serializer = ContentLibraryUpdateSerializer(data=request.data, partial=True)
     serializer.is_valid(raise_exception=True)
     data = dict(serializer.validated_data)
     if 'type' in data:
         data['library_type'] = data.pop('type')
     try:
         api.update_library(key, **data)
     except api.IncompatibleTypesError as err:
         raise ValidationError({'type': str(err)})
     result = api.get_library(key)
     return Response(ContentLibraryMetadataSerializer(result).data)