#NEWLINE# def get_object( self , vote_event ) : #NEWLINE# #INDENT# spec = { #NEWLINE# #INDENT# 'legislative_session_id' : vote_event [ 'legislative_session_id' ] , #NEWLINE# #UNINDENT# } #NEWLINE# if ( ( not self [ 'identifier' ] ) and ( not vote_event [ 'bill_id' ] ) ) : #NEWLINE# #INDENT# raise InvalidVoteEventError ( 'attempt to save a VoteEvent without an "identifier" or "bill_id"' ) #NEWLINE# #UNINDENT# if vote_event [ 'bill_id' ] : #NEWLINE# #INDENT# if ( vote_event [ 'bill_id' ] not in self . seen_bill_ids ) : #NEWLINE# #INDENT# self . seen_bill_ids . add ( vote_event [ 'bill_id' ] ) #NEWLINE# self . vote_events_to_delete . update ( self . model_class . objects . filter ( bill_id = vote_event [ 'bill_id' ] ) . values_list ( 'id' , flat = True ) ) #NEWLINE# #UNINDENT# spec [ 'bill_id' ] = vote_event [ 'bill_id' ] #NEWLINE# #UNINDENT# if vote_event [ 'identifier' ] : #NEWLINE# #INDENT# spec [ 'identifier' ] = vote_event [ 'identifier' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# spec . update ( { #NEWLINE# #INDENT# 'motion_text' : vote_event [ 'motion_text' ] , #NEWLINE# 'start_date' : vote_event [ 'start_date' ] , #NEWLINE# 'organization_id' : vote_event [ 'organization_id' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return self . model_class . objects . prefetch_related ( 'votes__voter' ) . get ( ** spec )