#NEWLINE# @ detail_route ( methods = [ 'POST' ] , permission_classes = [ permissions . IsAuthenticated ] ) #NEWLINE# def helpful( self , request , pk = None ) : #NEWLINE# #INDENT# question = self . get_object ( ) #NEWLINE# if ( not question . editable ) : #NEWLINE# #INDENT# raise GenericAPIException ( 403 , 'Question not editable' ) #NEWLINE# #UNINDENT# if question . has_voted ( request ) : #NEWLINE# #INDENT# raise GenericAPIException ( 409 , 'Cannot vote twice' ) #NEWLINE# #UNINDENT# QuestionVote ( question = question , creator = request . user ) . save ( ) #NEWLINE# num_votes = QuestionVote . objects . filter ( question = question ) . count ( ) #NEWLINE# return Response ( { #NEWLINE# #INDENT# 'num_votes' : num_votes , #NEWLINE# #UNINDENT# } )