Subversion Repositories SmartDukaan

Rev

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

Rev 14482 Rev 14483
Line 3... Line 3...
3
from dtr.storage import Mongo
3
from dtr.storage import Mongo
4
from bson import json_util
4
from bson import json_util
5
import falcon
5
import falcon
6
from dtr.utils import FetchLivePrices, DealSheet as X_DealSheet, \
6
from dtr.utils import FetchLivePrices, DealSheet as X_DealSheet, \
7
UserSpecificDeals
7
UserSpecificDeals
-
 
8
from bson.json_util import dumps
8
 
9
 
9
 
10
 
10
class CategoryDiscountInfo(object):
11
class CategoryDiscountInfo(object):
11
    
12
    
12
    def on_get(self, req, resp):
13
    def on_get(self, req, resp):
Line 283... Line 284...
283
        
284
        
284
        offset = req.get_param_as_int("offset")
285
        offset = req.get_param_as_int("offset")
285
        limit = req.get_param_as_int("limit")
286
        limit = req.get_param_as_int("limit")
286
        
287
        
287
        result = Mongo.getAllNegativeDeals(offset, limit)
288
        result = Mongo.getAllNegativeDeals(offset, limit)
288
        json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
-
 
289
        resp.body = json_docs
289
        resp.body = dumps(result) 
290
 
290
 
291
    
291
    
292
    def on_post(self, req, resp):
292
    def on_post(self, req, resp):
293
        
293
        
294
        try:
294
        try:
Line 308... Line 308...
308
        
308
        
309
        offset = req.get_param_as_int("offset")
309
        offset = req.get_param_as_int("offset")
310
        limit = req.get_param_as_int("limit")
310
        limit = req.get_param_as_int("limit")
311
        
311
        
312
        result = Mongo.getAllManualDeals(offset, limit)
312
        result = Mongo.getAllManualDeals(offset, limit)
313
        json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
-
 
314
        resp.body = json_docs
313
        resp.body = dumps(result)
315
 
314
 
316
    
315
    
317
    def on_post(self, req, resp):
316
    def on_post(self, req, resp):
318
        
317
        
319
        try:
318
        try:
Line 322... Line 321...
322
            raise falcon.HTTPError(falcon.HTTP_400,
321
            raise falcon.HTTPError(falcon.HTTP_400,
323
                'Malformed JSON',
322
                'Malformed JSON',
324
                'Could not decode the request body. The '
323
                'Could not decode the request body. The '
325
                'JSON was incorrect.')
324
                'JSON was incorrect.')
326
            
325
            
327
        result = Mongo.addManualDeals(result_json)
326
        result = Mongo.addManualDeal(result_json)
328
        resp.body = json.dumps(result, encoding='utf-8')
327
        resp.body = json.dumps(result, encoding='utf-8')
329
        
328
        
330
class CommonDelete():
329
class CommonDelete():
331
    
330
    
332
    def on_post(self,req,resp):
331
    def on_post(self,req,resp):
Line 348... Line 347...
348
        offset = req.get_param_as_int("offset")
347
        offset = req.get_param_as_int("offset")
349
        limit = req.get_param_as_int("limit")
348
        limit = req.get_param_as_int("limit")
350
        search_term = req.get_param("search")
349
        search_term = req.get_param("search")
351
        
350
        
352
        result = Mongo.searchMaster(offset, limit, search_term)
351
        result = Mongo.searchMaster(offset, limit, search_term)
353
        json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
-
 
354
        resp.body = json_docs
352
        resp.body = dumps(result) 
355
 
353
 
356
        
354
        
357
    
355