#NEWLINE# def get_variant_properties( self ) : #NEWLINE# #INDENT# '\n        Returns the property value of a variant in the correct ordering of the\n        properties.\n        ' #NEWLINE# from lfs.caching.utils import get_cache_group_id #NEWLINE# pid = self . get_parent ( ) . pk #NEWLINE# properties_version = get_cache_group_id ( 'global-properties-version' ) #NEWLINE# group_id = ( '%s-%s' % ( properties_version , get_cache_group_id ( ( 'properties-%s' % pid ) ) ) ) #NEWLINE# cache_key = ( '%s-variant-properties-%s-%s' % ( settings . CACHE_MIDDLEWARE_KEY_PREFIX , group_id , self . id ) ) #NEWLINE# properties = cache . get ( cache_key ) #NEWLINE# if properties : #NEWLINE# #INDENT# return properties #NEWLINE# #UNINDENT# properties = [ ] #NEWLINE# for ppv in self . property_values . filter ( type = PROPERTY_VALUE_TYPE_VARIANT ) . order_by ( 'property_group__name' , 'property__position' ) : #NEWLINE# #INDENT# if ppv . property . is_select_field : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# po = PropertyOption . objects . get ( pk = int ( float ( ppv . value ) ) ) #NEWLINE# #UNINDENT# except PropertyOption . DoesNotExist : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# value = po . name #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# value = ppv . value #NEWLINE# #UNINDENT# properties . append ( { #NEWLINE# #INDENT# 'name' : ppv . property . name , #NEWLINE# 'title' : ppv . property . title , #NEWLINE# 'value' : value , #NEWLINE# 'unit' : ppv . property . unit , #NEWLINE# 'property_group' : ppv . property_group , #NEWLINE# 'property_group_id' : ( ppv . property_group_id if ppv . property_group else 0 ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# cache . set ( cache_key , properties ) #NEWLINE# return properties