#NEWLINE# def update_entity_translations_from_vcs( self , db_entity , locale_code , vcs_translation , user = None , db_translations = None , old_translations = None ) : #NEWLINE# #INDENT# if ( db_translations is None ) : #NEWLINE# #INDENT# db_translations = db_entity . translation_set . filter ( locale__code = locale_code ) #NEWLINE# #UNINDENT# approved_translations = [ ] #NEWLINE# fuzzy_translations = [ ] #NEWLINE# for ( plural_form , string ) in vcs_translation . strings . items ( ) : #NEWLINE# #INDENT# db_translation = match_attr ( db_translations , plural_form = plural_form , string = string ) #NEWLINE# if db_translation : #NEWLINE# #INDENT# if ( ( not db_translation . approved ) and ( not vcs_translation . fuzzy ) ) : #NEWLINE# #INDENT# db_translation . approved = True #NEWLINE# db_translation . approved_date = self . now #NEWLINE# db_translation . approved_user = user #NEWLINE# #UNINDENT# db_translation . fuzzy = vcs_translation . fuzzy #NEWLINE# db_translation . extra = vcs_translation . extra #NEWLINE# if db_translation . is_dirty ( ) : #NEWLINE# #INDENT# self . translations_to_update . append ( db_translation ) #NEWLINE# #UNINDENT# if ( not db_translation . fuzzy ) : #NEWLINE# #INDENT# approved_translations . append ( db_translation ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fuzzy_translations . append ( db_translation ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . translations_to_create . append ( Translation ( entity = db_entity , locale = self . locales [ locale_code ] , string = string , plural_form = plural_form , approved = ( not vcs_translation . fuzzy ) , approved_date = ( self . now if ( not vcs_translation . fuzzy ) else None ) , approved_user = user , user = user , fuzzy = vcs_translation . fuzzy , extra = vcs_translation . extra ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( old_translations is None ) : #NEWLINE# #INDENT# old_translations = db_translations . filter ( approved_date__lte = self . now ) #NEWLINE# #UNINDENT# for translation in old_translations : #NEWLINE# #INDENT# if ( translation not in approved_translations ) : #NEWLINE# #INDENT# translation . approved = False #NEWLINE# translation . approved_user = None #NEWLINE# translation . approved_date = None #NEWLINE# if translation . is_dirty ( ) : #NEWLINE# #INDENT# self . translations_to_update . append ( translation ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for translation in db_translations : #NEWLINE# #INDENT# if ( translation not in fuzzy_translations ) : #NEWLINE# #INDENT# translation . fuzzy = False #NEWLINE# if translation . is_dirty ( ) : #NEWLINE# #INDENT# self . translations_to_update . append ( translation )