#NEWLINE# def render_tag( self , context , runcaseversion , user , environment , varname ) : #NEWLINE# #INDENT# 'Get/construct Result and place it in context under ``varname``' #NEWLINE# result_kwargs = dict ( environment = user , tester = user , runcaseversion = runcaseversion , is_latest = True ) #NEWLINE# try : #NEWLINE# #INDENT# result = model . Result . objects . get ( ** result_kwargs ) #NEWLINE# #UNINDENT# except model . Result . DoesNotExist : #NEWLINE# #INDENT# result = model . Result ( ** result_kwargs ) #NEWLINE# #UNINDENT# except model . Result . MultipleObjectsReturned : #NEWLINE# #INDENT# result = model . Result . objects . filter ( ** result_kwargs ) . order_by ( '-modified_on' ) [ 0 ] #NEWLINE# result . set_latest ( ) #NEWLINE# result . save ( ) #NEWLINE# #UNINDENT# context [ varname ] = result #NEWLINE# return ''