本文整理汇总了Python中cartridge.shop.models.ProductVariation.num_in_stock方法的典型用法代码示例。如果您正苦于以下问题:Python ProductVariation.num_in_stock方法的具体用法?Python ProductVariation.num_in_stock怎么用?Python ProductVariation.num_in_stock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cartridge.shop.models.ProductVariation
的用法示例。
在下文中一共展示了ProductVariation.num_in_stock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buscarDominio
# 需要导入模块: from cartridge.shop.models import ProductVariation [as 别名]
# 或者: from cartridge.shop.models.ProductVariation import num_in_stock [as 别名]
def buscarDominio(request):
resultado = ''
domain = ''
dominio = ''
extension = ''
precio = ''
duracion = 1
descripcion = ''
precio_total = ''
price_unit = ''
if request.method=='POST' and 'buscar' in request.POST:
consulta = BuscarDominioForm(request.POST)
if consulta.is_valid():
dominio = consulta.cleaned_data['dominio']
extension = consulta.cleaned_data['extension']
duracion = consulta.cleaned_data['duracion']
duracion = int(duracion)
request.session['dur'] = duracion
dominio = str(dominio)
sufijo = str(extension)
domain = dominio + '.' + sufijo
request.session['dom'] = domain
result = api.domain.available(apikey, [domain])
while result[domain] == 'pending':
time.sleep(0.7)
result = api.domain.available(apikey, [domain])
if result[domain] == 'available':
resultado = domain + ' se encuentra disponible'
product_spec = {
'product' : {
'description': domain,
'type': 'domain'
},
'action' : {
'name': 'create',
'duration': duracion
}
}
result = api.catalog.list(apikey, product_spec)
result2 = result[0]
price = result2['unit_price']
price2 = price[0]
price_unit = price2['price']
precio = (price_unit + 4)*4
request.session['pr_un'] = price_unit
request.session['pre'] = precio
precio_total = precio*duracion
break
elif result[domain] == 'unavailable':
resultado = domain + ' no se encuentra disponible'
break
request.session['res'] = resultado
elif request.method == 'POST' and 'registro' in request.POST:
producto = Product()
dominio = request.session.get('dom')
dominio = str(dominio)
unit_price = request.session.get('pr_un')
sale_price = request.session.get('pre')
producto.unit_price = unit_price
producto.sale_price = sale_price
producto.num_in_stock = 30
producto.sku = Product.objects.all().count() + 1
duracion = request.session.get('dur')
producto.available = True
producto.title = dominio
producto.save()
product = ProductVariation()
product.product = producto
product.unit_price = unit_price
product.sale_price = sale_price
product.num_in_stock = 30
product.sku = ProductVariation.objects.all().count() + 1
product.save()
request.cart.add_item(product, duracion)
recalculate_cart(request)
return HttpResponseRedirect('/shop/cart/')
else:
consulta = BuscarDominioForm()
return render_to_response('buscadominioform.html',{'consulta':consulta, 'resultado':resultado, 'precio':precio_total}, context_instance=RequestContext(request))