#NEWLINE# def handle_POST( self , request , context ) : #NEWLINE# #INDENT# form = context [ 'form' ] #NEWLINE# post = request . POST . copy ( ) #NEWLINE# if ( 'vote_up.x' in post ) : #NEWLINE# #INDENT# post [ 'vote_up' ] = post [ 'vote_up.x' ] #NEWLINE# #UNINDENT# if ( 'vote_down.x' in post ) : #NEWLINE# #INDENT# post [ 'vote_down' ] = post [ 'vote_down.x' ] #NEWLINE# #UNINDENT# if ( ( 'vote_up' in post ) or ( 'vote_down' in post ) ) : #NEWLINE# #INDENT# feature = get_object_or_404 ( Feature , id = post . get ( 'id' , 0 ) ) #NEWLINE# previous_vote = request . session [ 'feature_vote:votes' ] . get ( feature . id , 0 ) #NEWLINE# vote = ( previous_vote + ( 1 if ( 'vote_up' in post ) else ( - 1 ) ) ) #NEWLINE# vote = min ( max ( ( - 1 ) , vote ) , 1 ) #NEWLINE# request . session [ 'feature_vote:votes' ] [ feature . id ] = vote #NEWLINE# request . session . modified = True #NEWLINE# feature . down_vote += self . vote_transitions [ ( previous_vote , vote ) ] [ 0 ] #NEWLINE# feature . up_vote += self . vote_transitions [ ( previous_vote , vote ) ] [ 1 ] #NEWLINE# feature . save ( ) #NEWLINE# if request . POST . get ( 'return_url' , '' ) . startswith ( '/' ) : #NEWLINE# #INDENT# return self . redirect ( request . POST [ 'return_url' ] , request , 'seeother' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return self . redirect ( reverse ( 'feature_vote:index' ) , request , 'seeother' ) #NEWLINE# #UNINDENT# #UNINDENT# if form . is_valid ( ) : #NEWLINE# #INDENT# form . save ( ) #NEWLINE# send_email ( request , { #NEWLINE# #INDENT# 'name' : form . cleaned_data [ 'user_name' ] , #NEWLINE# 'email' : form . cleaned_data [ 'user_email' ] , #NEWLINE# 'title' : form . cleaned_data [ 'title' ] , #NEWLINE# 'description' : form . cleaned_data [ 'description' ] , #NEWLINE# 'feature' : form . instance , #NEWLINE# #UNINDENT# } , 'feature_vote/feature_create.eml' , self ) #NEWLINE# return self . redirect ( ( reverse ( 'feature_vote:index' ) + '?submitted=true' ) , request , 'seeother' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return self . handle_GET ( request , context )