<s> class Diff : <EOL> def __init__ ( self ) : <EOL> self . user = None <EOL> self . date = None <EOL> self . note = None <EOL> self . fields = { } <EOL> def diff_historical_object ( original_historical_object , changed_historical_object ) : <EOL> """<STR_LIT>""" <EOL> diff = Diff ( ) <EOL> diff . date = changed_historical_object . history_date <EOL> diff . user = changed_historical_object . history_user <EOL> diff . note = changed_historical_object . history_note <EOL> for field in changed_historical_object . history_object . _meta . diff_fields : <EOL> value = getattr ( changed_historical_object , field ) <EOL> if value == "<STR_LIT>" : <EOL> value = None <EOL> original_value = getattr ( original_historical_object , field ) if original_historical_object else None <EOL> if original_value == "<STR_LIT>" : <EOL> original_value = None <EOL> if value != original_value : <EOL> diff . fields [ field ] = ( original_value , value ) <EOL> return diff <EOL> def diff_object_history ( obj ) : <EOL> """<STR_LIT>""" <EOL> diffs = [ ] <EOL> historical_objects = list ( obj . history . all ( ) ) <EOL> for i , historical_object in enumerate ( historical_objects ) : <EOL> diffs . append ( diff_historical_object ( historical_objects [ i + <NUM_LIT:1> ] if i < len ( historical_objects ) - <NUM_LIT:1> else None , <EOL> historical_object ) ) <EOL> return diffs </s>
