Ejemplo n.º 1
0
def append_buy_shipping_form(request):
    exhibit = get_object_or_404(Exhibit,
                                pk=request.GET.get('exhibit_id'),
                                last_bidder_member=request.user)
    transaction = Transaction()
    transaction.exhibit = exhibit
    transaction.user = request.user
    form = BuyShippingForm(instance=transaction)

    return render(request, 'payment/modal_buy_shipping.html', {
        'exhibit': exhibit,
        'form': form
    })
Ejemplo n.º 2
0
def append_bids_return_form(request):

    try:
        exhibit = Exhibit.objects.ended()\
            .exclude(last_bidder_member=request.user) \
            .exclude(id__in=[payment.exhibit_id for payment in request.user.payments.processing_item_transaction().all() if payment.exhibit_id]) \
            .extra(select={'refund_time_left': 'FLOOR({}-(UNIX_TIMESTAMP()-ended_unixtime))'.format(settings.BID_REFUND_TIME)}) \
            .extra(where=['UNIX_TIMESTAMP() - ended_unixtime < {}'.format(settings.BID_REFUND_TIME)]) \
            .annotate(bid_refund=Count('id')) \
            .select_related('item') \
            .get(bids__user=request.user, id=request.GET.get('exhibit_id'))
    except Exhibit.DoesNotExist:
        raise Http404

    transaction = Transaction()
    transaction.exhibit = exhibit
    transaction.user = request.user
    form = BuyWithBidsReturnForm(instance=transaction)

    return render(request, 'payment/modal_buy_and_return_bids.html', {
        'exhibit': exhibit,
        'form': form
    })