Rev 13572 | Rev 13582 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
import falconimport jsonfrom dtr.storage import Mongoclass CategoryDiscountInfo(object):def on_get(self, req, resp):resp.body = str(Mongo.getAllCategoryDiscount())def on_post(self, req, resp):try:result_json = json.loads(req.stream.read(), encoding='utf-8')except ValueError:raise falcon.HTTPError(falcon.HTTP_400,'Malformed JSON','Could not decode the request body. The ''JSON was incorrect.')result = Mongo.addCategoryDiscount(result_json)resp.body = json.dumps(result, encoding='utf-8')class SkuSchemeDetails(object):def on_get(self, req, resp):resp.body = str(Mongo.getAllSkuWiseSchemeDetails())def on_post(self, req, resp):try:result_json = json.loads(req.stream.read(), encoding='utf-8')except ValueError:raise falcon.HTTPError(falcon.HTTP_400,'Malformed JSON','Could not decode the request body. The ''JSON was incorrect.')result = Mongo.addSchemeDetailsForSku(result_json)resp.body = json.dumps(result, encoding='utf-8')class SkuDiscountInfo():def on_get(self, req, resp):resp.body = str(Mongo.getallSkuDiscountInfo())def on_post(self, req, resp):try:result_json = json.loads(req.stream.read(), encoding='utf-8')except ValueError:raise falcon.HTTPError(falcon.HTTP_400,'Malformed JSON','Could not decode the request body. The ''JSON was incorrect.')result = Mongo.addSkuDiscountInfo(result_json)resp.body = json.dumps(result, encoding='utf-8')class ExceptionalNlc():def on_get(self, req, resp):resp.body = str(Mongo.getAllExceptionlNlcItems())def on_post(self, req, resp):try:result_json = json.loads(req.stream.read(), encoding='utf-8')except ValueError:raise falcon.HTTPError(falcon.HTTP_400,'Malformed JSON','Could not decode the request body. The ''JSON was incorrect.')result = Mongo.addExceptionalNlc(result_json)resp.body = json.dumps(result, encoding='utf-8')