Subversion Repositories SmartDukaan

Rev

Rev 13572 | Rev 13582 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
13572 kshitij.so 1
import falcon
2
import json
3
from dtr.storage import Mongo 
4
 
5
 
6
class CategoryDiscountInfo(object):
7
 
8
    def on_get(self, req, resp):
9
 
10
        resp.body = str(Mongo.getAllCategoryDiscount()) 
11
 
12
    def on_post(self, req, resp):
13
 
14
        try:
15
            result_json = json.loads(req.stream.read(), encoding='utf-8')
16
        except ValueError:
17
            raise falcon.HTTPError(falcon.HTTP_400,
18
                'Malformed JSON',
19
                'Could not decode the request body. The '
20
                'JSON was incorrect.')
21
 
22
        result = Mongo.addCategoryDiscount(result_json)
23
        resp.body = json.dumps(result, encoding='utf-8')
24
 
25
class SkuSchemeDetails(object):
26
 
27
    def on_get(self, req, resp):
28
 
29
        resp.body = str(Mongo.getAllSkuWiseSchemeDetails()) 
30
 
31
    def on_post(self, req, resp):
32
 
33
        try:
34
            result_json = json.loads(req.stream.read(), encoding='utf-8')
35
        except ValueError:
36
            raise falcon.HTTPError(falcon.HTTP_400,
37
                'Malformed JSON',
38
                'Could not decode the request body. The '
39
                'JSON was incorrect.')
40
 
41
        result = Mongo.addSchemeDetailsForSku(result_json)
42
        resp.body = json.dumps(result, encoding='utf-8')
43
 
44
class SkuDiscountInfo():
45
 
46
    def on_get(self, req, resp):
47
 
48
        resp.body = str(Mongo.getallSkuDiscountInfo()) 
49
 
50
    def on_post(self, req, resp):
51
 
52
        try:
53
            result_json = json.loads(req.stream.read(), encoding='utf-8')
54
        except ValueError:
55
            raise falcon.HTTPError(falcon.HTTP_400,
56
                'Malformed JSON',
57
                'Could not decode the request body. The '
58
                'JSON was incorrect.')
59
 
60
        result = Mongo.addSkuDiscountInfo(result_json)
61
        resp.body = json.dumps(result, encoding='utf-8')
62
 
63
class ExceptionalNlc():
64
 
65
    def on_get(self, req, resp):
66
 
67
        resp.body = str(Mongo.getAllExceptionlNlcItems()) 
68
 
69
    def on_post(self, req, resp):
70
 
71
        try:
72
            result_json = json.loads(req.stream.read(), encoding='utf-8')
73
        except ValueError:
74
            raise falcon.HTTPError(falcon.HTTP_400,
75
                'Malformed JSON',
76
                'Could not decode the request body. The '
77
                'JSON was incorrect.')
78
 
79
        result = Mongo.addExceptionalNlc(result_json)
80
        resp.body = json.dumps(result, encoding='utf-8')
81