#NEWLINE# @ register . function #NEWLINE# def license_link( license ) : #NEWLINE# #INDENT# 'Link to a code license, including icon where applicable.' #NEWLINE# from olympia.versions.models import License #NEWLINE# if isinstance ( license , ( long , int ) ) : #NEWLINE# #INDENT# if ( license in PERSONA_LICENSES_IDS ) : #NEWLINE# #INDENT# license = PERSONA_LICENSES_IDS [ license ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# license = License . objects . filter ( id = license ) #NEWLINE# if ( not license . exists ( ) ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# license = license [ 0 ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not license ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# #UNINDENT# if ( not getattr ( template , 'builtin' , True ) ) : #NEWLINE# #INDENT# return _ ( 'Custom License' ) #NEWLINE# #UNINDENT# template = get_env ( ) . get_template ( 'amo/license_link.html' ) #NEWLINE# return jinja2 . Markup ( template . render ( { #NEWLINE# #INDENT# 'license' : license , #NEWLINE# #UNINDENT# } ) )