Subversion Repositories SmartDukaan

Rev

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

Rev 17289 Rev 17307
Line 294... Line 294...
294
        except ValueError:
294
        except ValueError:
295
            raise falcon.HTTPError(falcon.HTTP_400,
295
            raise falcon.HTTPError(falcon.HTTP_400,
296
                'Malformed JSON',
296
                'Malformed JSON',
297
                'Could not decode the request body. The '
297
                'Could not decode the request body. The '
298
                'JSON was incorrect.')
298
                'JSON was incorrect.')
-
 
299
 
-
 
300
class AmazonSummary():
-
 
301
    def on_get(self, req, resp,userId):
-
 
302
        try:
-
 
303
            result = getSummary(userId)
-
 
304
            if result:
-
 
305
                resp.body = result
-
 
306
            else:
-
 
307
                resp.body = ''
-
 
308
            resp.content_type = 'text/html'
-
 
309
        except ValueError:
-
 
310
            raise falcon.HTTPError(falcon.HTTP_400,
-
 
311
                'Malformed JSON',
-
 
312
                'Could not decode the request body. The '
-
 
313
                'JSON was incorrect.')
-
 
314
 
-
 
315
 
-
 
316
def getSummary(userId):
-
 
317
    directory = "/AmazonTrack/User/" + userId
-
 
318
    date1 = datetime(2015,1,1)
-
 
319
    finalFile = None
-
 
320
    str1 = None
-
 
321
    try:
-
 
322
        for file in os.listdir(directory):
-
 
323
            if file.startswith("orderSummary"):
-
 
324
                date2 = datetime.strptime("2015-" + file.split("orderSummary")[1].split(":")[0], "%Y-%d-%m")
-
 
325
                if date2 > date1:
-
 
326
                    date1 = date2
-
 
327
                    finalFile=file
-
 
328
        str1 = open(directory + "/" + finalFile).read()
-
 
329
        return str1
-
 
330
    except:
-
 
331
        print "Missing directory"
-
 
332
    return str1
299
        
333
        
300
class PendingCashBacks():
334
class PendingCashBacks():
301
    def on_get(self, req, resp,userId):
335
    def on_get(self, req, resp,userId):
302
        try:
336
        try:
303
            result = Mongo.getPendingCashbacks(int(userId))
337
            result = Mongo.getPendingCashbacks(int(userId))