当前位置: 首页>>代码示例>>Python>>正文


Python Item.update_latest_item方法代码示例

本文整理汇总了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"))
开发者ID:,项目名称:,代码行数:12,代码来源:

示例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"))
开发者ID:,项目名称:,代码行数:14,代码来源:

示例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))
开发者ID:,项目名称:,代码行数:39,代码来源:


注:本文中的models.Item.update_latest_item方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。