Subversion Repositories SmartDukaan

Rev

Rev 16697 | Rev 16739 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16697 Rev 16737
Line 233... Line 233...
233
        
233
        
234
    if window==None:
234
    if window==None:
235
        window = 10
235
        window = 10
236
    result = {}
236
    result = {}
237
    skip = (page-1)*window
237
    skip = (page-1)*window
238
    collection = get_mongo_connection().Dtr.refund
238
    con = get_mongo_connection()
-
 
239
    collection = con.Dtr.refund
-
 
240
    user = con.Dtr.user
-
 
241
    credited = user.find({"userId":userId}).get("credited")
-
 
242
    if not credited:
-
 
243
        credited = 0
239
    cursor = collection.find({"userId":userId})
244
    cursor = collection.find({"userId":userId})
240
    total_count = cursor.count()
245
    total_count = cursor.count()
241
    pages = total_count/window + (0 if total_count%window==0 else 1)  
246
    pages = total_count/window + (0 if total_count%window==0 else 1)  
242
    print "total_count", total_count
247
    print "total_count", total_count
243
    if total_count > skip:
248
    if total_count > skip:
244
        cursor = cursor.skip(skip).limit(window).sort([('batch',-1)])
249
        cursor = cursor.skip(skip).limit(window).sort([('batch',-1)])
245
        refunds = []
250
        refunds = []
246
        for refund in cursor:
251
        for refund in cursor:
247
            del(refund["_id"])
252
            del(refund["_id"])
248
            refunds.append(refund)
253
            refunds.append(refund)
-
 
254
        result['credited'] = 0
249
        result['data'] = refunds
255
        result['data'] = refunds
250
        result['window'] = window
256
        result['window'] = window
251
        result['totalCount'] = total_count 
257
        result['totalCount'] = total_count 
252
        result['currCount'] = cursor.count()
258
        result['currCount'] = cursor.count()
253
        result['totalPages'] = pages
259
        result['totalPages'] = pages