#NEWLINE# def validate( self , data ) : #NEWLINE# #INDENT# authed_user = getattr ( self . context . get ( 'request' ) , 'user' ) #NEWLINE# creator = data . get ( 'creator' ) #NEWLINE# if ( creator is None ) : #NEWLINE# #INDENT# data [ 'creator' ] = authed_user #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( creator != authed_user ) : #NEWLINE# #INDENT# raise serializers . ValidationError ( { #NEWLINE# #INDENT# 'creator' : "Can't register push notifications for another user." , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# return data