示例#1
0
	def view( self, request, shop_name, product_id ):
		req_get = request.GET		
		product = Product.objects.get( id = int( product_id ) )
		shop_id = get_shop_id_by_name( request.session, shop_name )

		if product.shop.id != shop_id:
			raise ProductNotInThisShopError( "Product with id {0} not found in shop {1}".format( product_id, self._shop_name ) )		
		cart = Cart( request.session)
		in_cart = str( product.id ) in cart.as_dict()

		location = Location( request.session, 'shop' )
		if location.is_set():
			back = location.get()
		else:
			back = None

		return super( ProductView, self ).view(	request, 
												shop_name, 
												{ 
													'back': back, 
													'product': product, 
													'in_cart': in_cart, 
													'opt': req_get[ 'opt' ] if 'opt' in req_get else None 
												} )