#NEWLINE# def create( self , request , * args , **kwargs ) : #NEWLINE# #INDENT# username = self . kwargs . get ( 'username' ) #NEWLINE# if self . request . user . is_anonymous ( ) : #NEWLINE# #INDENT# if ( username is None ) : #NEWLINE# #INDENT# self . permission_denied ( self . request ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# user = get_object_or_404 ( User , username = username . lower ( ) ) #NEWLINE# ( profile , created ) = UserProfile . objects . get_or_create ( user = user ) #NEWLINE# if profile . require_auth : #NEWLINE# #INDENT# self . permission_denied ( self . request ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not username ) : #NEWLINE# #INDENT# username = ( request . user and request . user . username ) #NEWLINE# #UNINDENT# #UNINDENT# if ( request . method . upper ( ) == 'HEAD' ) : #NEWLINE# #INDENT# return Response ( status = status . HTTP_204_NO_CONTENT , headers = self . get_openrosa_headers ( request ) , template_name = self . template_name ) #NEWLINE# #UNINDENT# is_json_request = is_json ( request ) #NEWLINE# ( error , instance ) = ( create_instance_from_json if is_json_request else create_instance_from_xml ) ( username , request ) #NEWLINE# if ( error or ( not instance ) ) : #NEWLINE# #INDENT# return self . error_response ( error , is_json_request , request ) #NEWLINE# #UNINDENT# context = self . get_serializer_context ( ) #NEWLINE# serializer = SubmissionSerializer ( instance , context = context ) #NEWLINE# return Response ( serializer . data , headers = self . get_openrosa_headers ( request ) , status = status . HTTP_201_CREATED , template_name = self . template_name )