#NEWLINE# def calculate_price( request , id ) : #NEWLINE# #INDENT# 'Calculates the price of the product on base of choosen properties after\n    a customer has selected a property on product view.\n    ' #NEWLINE# product = Product . objects . get ( pk = for_sale_price ) #NEWLINE# property_price = _calculate_property_price ( request ) #NEWLINE# if product . for_sale : #NEWLINE# #INDENT# for_sale_standard_price = product . get_standard_price ( request , with_properties = False ) #NEWLINE# for_sale_standard_price += property_price #NEWLINE# for_sale_price = product . get_for_sale_price ( request , with_properties = False ) #NEWLINE# for_sale_price += property_price #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# for_sale_standard_price = 0 #NEWLINE# for_sale_price = 0 #NEWLINE# #UNINDENT# price = product . get_price ( request , with_properties = False ) #NEWLINE# price += property_price #NEWLINE# if product . get_active_packing_unit ( ) : #NEWLINE# #INDENT# packing_result = calculate_packing ( request , id , with_properties = True , as_string = True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# packing_result = '' #NEWLINE# #UNINDENT# result = json . dumps ( { #NEWLINE# #INDENT# 'price' : lfs_tags . currency ( price , request ) , #NEWLINE# 'for-sale-standard-price' : lfs_tags . currency ( for_sale_standard_price ) , #NEWLINE# 'for-sale-price' : lfs_tags . currency ( for_sale_price ) , #NEWLINE# 'packing-result' : packing_result , #NEWLINE# 'message' : _ ( 'Price has been changed according to your selection.' ) , #NEWLINE# #UNINDENT# } , cls = LazyEncoder ) #NEWLINE# return HttpResponse ( result , content_type = 'application/json' )