def ajax_session_add(request):
    try:
        form_session = AuctionSessionForm(request.POST or None, prefix="session")
        if form_session.is_valid():

            auction_session = form_session.save(commit=False)
            d = datetime.datetime(
                form_session.cleaned_data["date_from"].year,
                form_session.cleaned_data["date_from"].month,
                form_session.cleaned_data["date_from"].day,
                # int(form_session.cleaned_data['hour_from']),
                # int(form_session.cleaned_data['minute_from']))
            )
            auction_session.start = d
            d = datetime.datetime(
                form_session.cleaned_data["date_to"].year,
                form_session.cleaned_data["date_to"].month,
                form_session.cleaned_data["date_to"].day,
                # int(form_session.cleaned_data['hour_to']),
                # int(form_session.cleaned_data['minute_to']))
            )
            auction_session.end = d
            auction_session.shop = request.shop
            auction_session.save()

            return HttpResponse("")
        return render_to_response(
            "category/ajax_session_add.html", {"form_session": form_session}, RequestContext(request)
        )
    except:
        import logging

        logging.exception("MUERE")
Exemplo n.º 2
0
def lot_add(request):

    if request.method == 'POST':
        form = LotForm(request, request.POST, prefix="lot")
        if form.is_valid():
            lot = form.save(commit=False)
            lot.shop = request.shop
            lot.state = 'A'
            lot.save()
            for img in request.FILES.getlist('file'):
                image = ImageLot(image=img, lot=lot)
                image.save()


#                image.lot = lot
#                image.image.save(img.name,img)
            request.flash['message'] = unicode(_("Lot successfully added."))
            request.flash['severity'] = "success"
            return HttpResponseRedirect(reverse('inventory_lots'))
    else:
        form = LotForm(request, prefix="lot")
    form_category = MarketCategoryForm(prefix="category")
    form_sub_category = MarketSubCategoryForm(request, prefix="sub_category")
    form_session = AuctionSessionForm(prefix="session")

    return render_to_response(
        'lots/lot_add.html', {
            'form': form,
            'form_category': form_category,
            'form_sub_category': form_sub_category,
            'form_session': form_session,
        }, RequestContext(request))
Exemplo n.º 3
0
def ajax_session_add(request):
    try:
        form_session = AuctionSessionForm(request.POST or None,
                                          prefix="session")
        if form_session.is_valid():
            today = datetime.datetime.today()

            sessions = AuctionSession.objects.filter(shop=request.shop).filter(
                end__gt=today)
            html = ""
            for session in sessions:
                html += '<option value="%d">%s</option>' % (session.id,
                                                            session.title)

            auction_session = form_session.save(commit=False)
            d = datetime.datetime(
                form_session.cleaned_data['date_from'].year,
                form_session.cleaned_data['date_from'].month,
                form_session.cleaned_data['date_from'].day,
                #int(form_session.cleaned_data['hour_from']),
                #int(form_session.cleaned_data['minute_from']))
            )
            auction_session.start = d
            d = datetime.datetime(
                form_session.cleaned_data['date_to'].year,
                form_session.cleaned_data['date_to'].month,
                form_session.cleaned_data['date_to'].day,
                #int(form_session.cleaned_data['hour_to']),
                #int(form_session.cleaned_data['minute_to']))
            )
            auction_session.end = d
            auction_session.shop = request.shop
            auction_session.save()

            html += '<option value="%d" selected="selected">%s</option>' % (
                auction_session.id, auction_session.title)
            return HttpResponse(html)

        return render_to_response('category/ajax_session_add.html',
                                  {'form_session': form_session},
                                  RequestContext(request))
    except:
        import logging
        logging.exception("MUERE")
Exemplo n.º 4
0
def ajax_session_add(request):
    try:
        form_session = AuctionSessionForm(request.POST or None, prefix="session")
        if form_session.is_valid():
            today = datetime.datetime.today()
            
            sessions = AuctionSession.objects.filter(shop=request.shop).filter(end__gt=today)
            html = ""
            for session in sessions:
                html += '<option value="%d">%s</option>' % (session.id, session.title)
                
            auction_session = form_session.save(commit = False)
            d = datetime.datetime(form_session.cleaned_data['date_from'].year,
                                  form_session.cleaned_data['date_from'].month,
                                  form_session.cleaned_data['date_from'].day,
                                  #int(form_session.cleaned_data['hour_from']),
                                  #int(form_session.cleaned_data['minute_from']))
                                  )
            auction_session.start = d 
            d = datetime.datetime(form_session.cleaned_data['date_to'].year,
                                  form_session.cleaned_data['date_to'].month,
                                  form_session.cleaned_data['date_to'].day,
                                  #int(form_session.cleaned_data['hour_to']),
                                  #int(form_session.cleaned_data['minute_to']))
                                  )
            auction_session.end = d
            auction_session.shop = request.shop
            auction_session.save() 
            
            html += '<option value="%d" selected="selected">%s</option>' % (auction_session.id, auction_session.title)    
            return HttpResponse(html)
        
        return render_to_response('category/ajax_session_add.html', {'form_session': form_session},
                                  RequestContext(request))
    except:
        import logging
        logging.exception("MUERE")
Exemplo n.º 5
0
def lot_edit(request, lot_id):
    lot = get_object_or_404(Lot, pk=lot_id)
    shop = request.shop
    if lot.shop != shop:
        raise Http404

    if request.method == 'POST':
        form = LotForm(request, request.POST, prefix="lot", instance=lot)
        if form.is_valid():
            lot = form.save()
            #            for img in request.FILES.getlist('file'):
            #                image = ImageLot(image = img, lot=lot)
            #                image.save()
            #                image.lot = lot
            #                image.image.save(img.name,img)
            request.flash['message'] = unicode(
                _("Lot successfully updated. It might take a half hour to reflect the proper search results."
                  ))
            request.flash['severity'] = "success"
        else:
            request.flash['message'] = unicode(_("Lot couldn't be updated."))
            request.flash['severity'] = "error"
        return HttpResponseRedirect(reverse('inventory_lots'))
    else:
        form = LotForm(request, prefix="lot", instance=lot)

    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(
        'lots/lot_edit.html', {
            'form': form,
            'form_category': form_category,
            'form_sub_category': form_sub_category,
            'form_session': form_session,
            'lot': lot,
            'sessions': sessions,
        }, RequestContext(request))
Exemplo n.º 6
0
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))