本文整理汇总了Python中models.Item.update_latest_item方法的典型用法代码示例。如果您正苦于以下问题:Python Item.update_latest_item方法的具体用法?Python Item.update_latest_item怎么用?Python Item.update_latest_item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Item
的用法示例。
在下文中一共展示了Item.update_latest_item方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: item_delete
# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import update_latest_item [as 别名]
def item_delete(request, item_id):
item = get_object_or_404(Item, pk=item_id)
if item.shop != request.shop:
raise Http404
item.delete()
Item.update_latest_item(request.shop)
request.flash['message'] = unicode(_("Item successfully deleted."))
request.flash['severity'] = "success"
return HttpResponseRedirect(reverse("inventory_items"))
示例2: items_bulk_delete
# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import update_latest_item [as 别名]
def items_bulk_delete(request):
ids = request.POST
for (item_id, status) in ids.items():
if status == "on":
item = get_object_or_404(Item, pk=item_id)
item.delete()
Item.update_latest_item(request.shop)
request.flash['message'] = unicode(_("Items removed"))
request.flash['severity'] = "success"
return HttpResponseRedirect(reverse("inventory_items"))
示例3: item_add
# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import update_latest_item [as 别名]
def item_add(request):
shop = request.shop
items_plan_limit = shop.plan().concurrent_store_items
if shop.total_items() >= items_plan_limit:
request.flash['message'] = "You have reached the limit of items that can hold simultaneously."
request.flash['severity'] = "error"
return HttpResponseRedirect(reverse('inventory_items'))
if request.method == 'POST':
form = ItemForm(request, request.POST, request.FILES, prefix="item")
if form.is_valid():
item = form.save(commit=False)
item.shop = request.shop
item.save()
Item.update_latest_item(shop)
for img in request.FILES.getlist('file'):
image = ImageItem()
image.item = item
image.image.save(img.name,img)
request.flash['message'] = unicode(_("Item successfully added."))
request.flash['severity'] = "success"
return HttpResponseRedirect(reverse('inventory_items'))
else:
form = ItemForm(request, prefix="item")
form_category = MarketCategoryForm(prefix="category")
form_sub_category = MarketSubCategoryForm(request, prefix="sub_category")
form_session = AuctionSessionForm(prefix="session")
sessions = AuctionSession.objects.filter(shop = request.shop)
return render_to_response('for_sale/item_add.html',
{'form': form,
'form_category': form_category,
'form_sub_category': form_sub_category,
'form_session': form_session,
'sessions': sessions,
},
RequestContext(request))