#NEWLINE# def create_addon_file( name , version_str , addon_status , file_status , platform = amo . PLATFORM_ALL , application = amo . FIREFOX , admin_review = False , addon_type = amo . ADDON_EXTENSION , created = None , file_kw = None , version_kw = None , listed = True , nomination = None ) : #NEWLINE# #INDENT# if ( file_kw is None ) : #NEWLINE# #INDENT# file_kw = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if ( version_kw is None ) : #NEWLINE# #INDENT# version_kw = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# ( app_vr , created_ ) = AppVersion . objects . get_or_create ( application = application . id , version = '1.0' ) #NEWLINE# ( ad , created_ ) = Addon . with_unlisted . get_or_create ( name__localized_string = name , defaults = { #NEWLINE# #INDENT# 'type' : addon_type , #NEWLINE# 'name' : name , #NEWLINE# 'is_listed' : listed , #NEWLINE# #UNINDENT# } ) #NEWLINE# if admin_review : #NEWLINE# #INDENT# ad . update ( admin_review = True ) #NEWLINE# #UNINDENT# ( vr , created_ ) = Version . objects . get_or_create ( addon = ad , version = version_str , defaults = version_kw ) #NEWLINE# if ( nomination is not None ) : #NEWLINE# #INDENT# vr . nomination = nomination #NEWLINE# vr . save ( ) #NEWLINE# #UNINDENT# if ( not created_ ) : #NEWLINE# #INDENT# vr . update ( ** version_kw ) #NEWLINE# #UNINDENT# ( va , created_ ) = ApplicationsVersions . objects . get_or_create ( version = vr , application = application . id , min = app_vr , max = app_vr ) #NEWLINE# file_ = File . objects . create ( version = vr , filename = ( '%s.xpi' % name ) , platform = platform . id , status = file_status , ** file_kw ) #NEWLINE# if created : #NEWLINE# #INDENT# vr . update ( created = created ) #NEWLINE# file_ . update ( created = created ) #NEWLINE# #UNINDENT# Addon . with_unlisted . get ( pk = ad . id ) . update ( status = addon_status ) #NEWLINE# return { #NEWLINE# #INDENT# 'addon' : ad , #NEWLINE# 'version' : vr , #NEWLINE# 'file' : file_ , #NEWLINE# #UNINDENT# }