#NEWLINE# def create( self , validated_data ) : #NEWLINE# #INDENT# request = self . context [ 'request' ] #NEWLINE# user = request . user #NEWLINE# auth = Auth ( user ) #NEWLINE# node = self . context [ 'view' ] . get_node ( ) #NEWLINE# target_node_id = validated_data [ '_id' ] #NEWLINE# pointer_node = Node . load ( target_node_id ) #NEWLINE# if ( ( not pointer_node ) or pointer_node . is_collection ) : #NEWLINE# #INDENT# raise InvalidModelValueError ( source = { #NEWLINE# #INDENT# 'pointer' : '/data/relationships/node_links/data/id' , #NEWLINE# #UNINDENT# } , detail = "Target Node '{}' not found." . format ( target_node_id ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# pointer = node . add_pointer ( pointer_node , auth , save = True ) #NEWLINE# return pointer #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# raise InvalidModelValueError ( source = { #NEWLINE# #INDENT# 'pointer' : '/data/relationships/node_links/data/id' , #NEWLINE# #UNINDENT# } , detail = "Target Node '{}' already pointed to by '{}'." . format ( target_node_id , node . _id ) )