Example #1
0
def closedTrade(request, *args, **kwargs):
    """Need update end_time to now."""
    initParam = {}
    transaction = get_object_or_404(models.Transaction,
                                    pk=kwargs.get('txn_id'),
                                    buyer_id=kwargs.get('buyer_id'),
                                    is_active=True)
    transaction.status = 4
    transaction.end_date = datetime.datetime.now()
    transaction.save()
    #Log transaction
    transactionsLog = models.TransactionLog()
    transactionsLog.transaction = transaction
    transactionsLog.app = transaction.app
    transactionsLog.status = transaction.status
    transactionsLog.buyer = transaction.buyer
    transactionsLog.save()
    #Increase seller and buyer credit point
    point = common.getSystemParam(key='cp_closed_trade', default=50)
    creditViews.increaseCreditPoint(user=transaction.buyer, point=point)
    creditViews.increaseCreditPoint(user=transaction.seller, point=point)
    #Send email to seller and buyer
    notificationViews.closedTradeInform(transaction=transaction)

    initParam['transaction'] = transaction
    return render_to_response('transaction/trade_action.html',
                              initParam,
                              context_instance=RequestContext(request))
Example #2
0
def tradeOperation(request, *args, **kwargs):
    initParam = kwargs.get('initParam')
    transaction = kwargs.get('transaction')
    if transaction and request.method == 'POST':
        delivery = request.POST.get('delivery')
        if delivery and delivery == 'confirm_delivery':
            if transaction.status == 3:
                transaction.status = 4
                transaction.end_time = datetime.datetime.now()
                transaction.save()
                #Log transaction
                transactionsLog = models.TransactionLog()
                transactionsLog.transaction = transaction
                transactionsLog.app = transaction.app
                transactionsLog.status = transaction.status
                transactionsLog.buyer = transaction.buyer
                transactionsLog.save()
                #Send email to seller and buyer
                notificationViews.closedTradeInform(transaction=transaction)
                return transaction
            else:
                initParam['error_msg'] = _(
                    'Transaction can not be confirmed delivery.')
                log.error(
                    _('Transaction: %(param1)s, status: %(param2)s can not confirm delivery.'
                      ) % {
                          'param1': transaction.id,
                          'param2': transaction.status
                      })
        #TODO:if no complain, then increase credit point.
        #Increase seller and buyer credit point
        # point = common.getSystemParam(key='cp_closed_trade', default=50)
        # creditViews.increaseCreditPoint(user=transaction.buyer, point=point)
        # creditViews.increaseCreditPoint(user=transaction.seller, point=point)
    return None
Example #3
0
def tradeOperation(request, *args, **kwargs):
    initParam = kwargs.get('initParam')
    transaction = kwargs.get('transaction')
    if transaction and request.method == 'POST':
        delivery = request.POST.get('delivery')
        if delivery and delivery == 'confirm_delivery':
            if transaction.status == 3:
                transaction.status = 4
                transaction.end_time = datetime.datetime.now()
                transaction.save()
                #Log transaction
                transactionsLog = models.TransactionLog()
                transactionsLog.transaction = transaction
                transactionsLog.app = transaction.app
                transactionsLog.status = transaction.status
                transactionsLog.buyer = transaction.buyer
                transactionsLog.save()
                #Send email to seller and buyer
                notificationViews.closedTradeInform(transaction=transaction)
                return transaction
            else:
                initParam['error_msg'] = _('Transaction can not be confirmed delivery.')
                log.error(_('Transaction: %(param1)s, status: %(param2)s can not confirm delivery.')
                      % {'param1': transaction.id, 'param2': transaction.status})
        #TODO:if no complain, then increase credit point.
        #Increase seller and buyer credit point
        # point = common.getSystemParam(key='cp_closed_trade', default=50)
        # creditViews.increaseCreditPoint(user=transaction.buyer, point=point)
        # creditViews.increaseCreditPoint(user=transaction.seller, point=point)
    return None
Example #4
0
def closedTrade(request, *args, **kwargs):
    """Need update end_time to now."""
    initParam = {}
    transaction = get_object_or_404(models.Transaction, pk=kwargs.get('txn_id'), buyer_id=kwargs.get('buyer_id'), is_active=True)
    transaction.status = 4
    transaction.end_date = datetime.datetime.now()
    transaction.save()
    #Log transaction
    transactionsLog = models.TransactionLog()
    transactionsLog.transaction = transaction
    transactionsLog.app = transaction.app
    transactionsLog.status = transaction.status
    transactionsLog.buyer = transaction.buyer
    transactionsLog.save()
    #Increase seller and buyer credit point
    point = common.getSystemParam(key='cp_closed_trade', default=50)
    creditViews.increaseCreditPoint(user=transaction.buyer, point=point)
    creditViews.increaseCreditPoint(user=transaction.seller, point=point)
    #Send email to seller and buyer
    notificationViews.closedTradeInform(transaction=transaction)

    initParam['transaction'] = transaction
    return render_to_response('transaction/trade_action.html', initParam, context_instance=RequestContext(request))