#NEWLINE# def send_response( method , serializer ) : #NEWLINE# #INDENT# if ( method == 'GET' ) : #NEWLINE# #INDENT# return Response ( serializer . data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( method == 'POST' ) : #NEWLINE# #INDENT# if serializer . is_valid ( ) : #NEWLINE# #INDENT# return Response ( serializer . data , status = status . HTTP_201_CREATED ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return Response ( serializer . errors , status = status . HTTP_400_BAD_REQUEST ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( method == 'PUT' ) : #NEWLINE# #INDENT# if serializer . is_valid ( ) : #NEWLINE# #INDENT# return Response ( serializer . data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return Response ( serializer . errors , status = status . HTTP_400_BAD_REQUEST ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( method == 'DELETE' ) : #NEWLINE# #INDENT# return Response ( status = status . HTTP_204_NO_CONTENT )