示例#1
0
def list_existing_item(request, item_id=None):
    try:
        item = Item.objects.get(pk=item_id)
    except Item.DoesNotExist:
        raise Http404

    if item.status == AUCTION_ITEM_STATUS_RUNNING:
        auction_event = AuctionEvent.objects.get(item=item)
        return HttpResponseRedirect(reverse('lebay_view_auction_event', args=[auction_event.pk]))

    if request.method == 'POST':
        auction_form = AuctionEventForm(data=request.POST)
        if auction_form.is_valid():
            auction_event = auction_form.save(item=item)
            return HttpResponseRedirect(reverse('lebay_view_auction_event', args=[auction_event.pk])) 
    else:
        auction_form = AuctionEventForm()

    return render_to_response('list_existing_item.html', {
        'item': item,
        'auction_form': auction_form
    }, context_instance=RequestContext(request))        
示例#2
0
def list_item(request):
    try:
        seller_profile = Seller.objects.get(user=request.user.user)
    except Seller.DoesNotExist:
        return HttpResponseRedirect(reverse('lebay_create_seller_profile') + '?next=%s' % reverse('lebay_list_item'))
    
    if request.method == 'POST':
        item_form = ItemForm(data=request.POST, seller=request.user.user)
        auction_form = AuctionEventForm(data=request.POST)
        
        if item_form.is_valid() and auction_form.is_valid():
            item = item_form.save()
            auction_event = auction_form.save(item=item)
            return HttpResponseRedirect(reverse('lebay_view_auction_event', args=[auction_event.id])) 
    else:
        item_form = ItemForm()
        auction_form = AuctionEventForm(initial={'shipping_method': seller_profile.default_shipping_method, 'shipping_detail': seller_profile.default_shipping_detail, 'payment_detail': seller_profile.default_payment_detail})

    return render_to_response('list_item.html', {
        'item_form': item_form,
        'auction_form': auction_form
    }, context_instance=RequestContext(request))