Subversion Repositories SmartDukaan

Rev

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

Rev 13969 Rev 13970
Line 13... Line 13...
13
        result = Mongo.getAllCategoryDiscount()
13
        result = Mongo.getAllCategoryDiscount()
14
        json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
14
        json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
15
        resp.body = json.dumps(json_docs, encoding='utf-8')
15
        resp.body = json.dumps(json_docs, encoding='utf-8')
16
    
16
    
17
    def on_post(self, req, resp):
17
    def on_post(self, req, resp):
18
        print "Inside post"
-
 
19
        
-
 
20
        try:
18
        try:
21
            result_json = json.loads(req.stream.read(), encoding='utf-8')
19
            result_json = json.loads(req.stream.read(), encoding='utf-8')
22
        except ValueError:
20
        except ValueError:
23
            raise falcon.HTTPError(falcon.HTTP_400,
21
            raise falcon.HTTPError(falcon.HTTP_400,
24
                'Malformed JSON',
22
                'Malformed JSON',
Line 27... Line 25...
27
            
25
            
28
        result = Mongo.addCategoryDiscount(result_json)
26
        result = Mongo.addCategoryDiscount(result_json)
29
        resp.body = json.dumps(result, encoding='utf-8')
27
        resp.body = json.dumps(result, encoding='utf-8')
30
    
28
    
31
    def on_put(self, req, resp, _id):
29
    def on_put(self, req, resp, _id):
-
 
30
        try:
-
 
31
            result_json = json.loads(req.stream.read(), encoding='utf-8')
32
        print "Inside on_put"
32
        except ValueError:
-
 
33
            raise falcon.HTTPError(falcon.HTTP_400,
-
 
34
                'Malformed JSON',
-
 
35
                'Could not decode the request body. The '
-
 
36
                'JSON was incorrect.')
-
 
37
            
-
 
38
        result = Mongo.updateCategoryDiscount(result_json, _id)
-
 
39
        resp.body = json.dumps(result, encoding='utf-8')
-
 
40
            
33
        
41
        
34
        
42
        
35
class SkuSchemeDetails(object):
43
class SkuSchemeDetails(object):
36
    
44
    
37
    def on_get(self, req, resp):
45
    def on_get(self, req, resp):
Line 56... Line 64...
56
        
64
        
57
class SkuDiscountInfo():
65
class SkuDiscountInfo():
58
    
66
    
59
    def on_get(self, req, resp):
67
    def on_get(self, req, resp):
60
        
68
        
-
 
69
        offset = req.get_param_as_int("offset")
-
 
70
        limit = req.get_param_as_int("limit")
61
        result = Mongo.getallSkuDiscountInfo()
71
        result = Mongo.getallSkuDiscountInfo(offset,limit)
62
        json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
72
        json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
63
        resp.body = json.dumps(json_docs, encoding='utf-8')
73
        resp.body = json.dumps(json_docs, encoding='utf-8')
64
 
74
 
65
    
75
    
66
    def on_post(self, req, resp):
76
    def on_post(self, req, resp):
Line 73... Line 83...
73
                'Could not decode the request body. The '
83
                'Could not decode the request body. The '
74
                'JSON was incorrect.')
84
                'JSON was incorrect.')
75
            
85
            
76
        result = Mongo.addSkuDiscountInfo(result_json)
86
        result = Mongo.addSkuDiscountInfo(result_json)
77
        resp.body = json.dumps(result, encoding='utf-8')
87
        resp.body = json.dumps(result, encoding='utf-8')
-
 
88
        
-
 
89
    def on_put(self, req, resp, _id):
-
 
90
        try:
-
 
91
            result_json = json.loads(req.stream.read(), encoding='utf-8')
-
 
92
        except ValueError:
-
 
93
            raise falcon.HTTPError(falcon.HTTP_400,
-
 
94
                'Malformed JSON',
-
 
95
                'Could not decode the request body. The '
-
 
96
                'JSON was incorrect.')
-
 
97
            
-
 
98
        result = Mongo.updateSkuDiscount(result_json, _id)
-
 
99
        resp.body = json.dumps(result, encoding='utf-8')
78
 
100
 
79
class ExceptionalNlc():
101
class ExceptionalNlc():
80
    
102
    
81
    def on_get(self, req, resp):
103
    def on_get(self, req, resp):
82
        
104
        
-
 
105
        offset = req.get_param_as_int("offset")
-
 
106
        limit = req.get_param_as_int("limit")
-
 
107
        
83
        result = Mongo.getAllExceptionlNlcItems()
108
        result = Mongo.getAllExceptionlNlcItems(offset, limit)
84
        json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
109
        json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
85
        resp.body = json.dumps(json_docs, encoding='utf-8')
110
        resp.body = json.dumps(json_docs, encoding='utf-8')
86
    
111
    
87
    def on_post(self, req, resp):
112
    def on_post(self, req, resp):
88
        
113
        
Line 94... Line 119...
94
                'Could not decode the request body. The '
119
                'Could not decode the request body. The '
95
                'JSON was incorrect.')
120
                'JSON was incorrect.')
96
            
121
            
97
        result = Mongo.addExceptionalNlc(result_json)
122
        result = Mongo.addExceptionalNlc(result_json)
98
        resp.body = json.dumps(result, encoding='utf-8')
123
        resp.body = json.dumps(result, encoding='utf-8')
-
 
124
    
-
 
125
    def on_put(self, req, resp, _id):
-
 
126
        try:
-
 
127
            result_json = json.loads(req.stream.read(), encoding='utf-8')
-
 
128
        except ValueError:
-
 
129
            raise falcon.HTTPError(falcon.HTTP_400,
-
 
130
                'Malformed JSON',
-
 
131
                'Could not decode the request body. The '
-
 
132
                'JSON was incorrect.')
-
 
133
            
-
 
134
        result = Mongo.updateExceptionalNlc(result_json, _id)
-
 
135
        resp.body = json.dumps(result, encoding='utf-8')
99
        
136
        
100
class Deals():
137
class Deals():
101
    def on_get(self,req, resp, userId):
138
    def on_get(self,req, resp, userId):
102
        categoryId = req.get_param_as_int("categoryId")
139
        categoryId = req.get_param_as_int("categoryId")
103
        offset = req.get_param_as_int("offset")
140
        offset = req.get_param_as_int("offset")
Line 159... Line 196...
159
    def on_get(self,req, resp):
196
    def on_get(self,req, resp):
160
        X_DealSheet.sendMail()
197
        X_DealSheet.sendMail()
161
        json_docs = json.dumps({'True':'Sheet generated, mail sent.'}, default=json_util.default)
198
        json_docs = json.dumps({'True':'Sheet generated, mail sent.'}, default=json_util.default)
162
        resp.body = json.dumps(json_docs, encoding='utf-8')
199
        resp.body = json.dumps(json_docs, encoding='utf-8')
163
    
200
    
-
 
201
class DealerPrice():
-
 
202
    
-
 
203
    def on_get(self, req, resp):
-
 
204
        
-
 
205
        offset = req.get_param_as_int("offset")
-
 
206
        limit = req.get_param_as_int("limit")
-
 
207
        result = Mongo.getAllDealerPrices(offset,limit)
-
 
208
        json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
-
 
209
        resp.body = json.dumps(json_docs, encoding='utf-8')
-
 
210
    
-
 
211
    def on_post(self, req, resp):
-
 
212
        
-
 
213
        try:
-
 
214
            result_json = json.loads(req.stream.read(), encoding='utf-8')
-
 
215
        except ValueError:
-
 
216
            raise falcon.HTTPError(falcon.HTTP_400,
-
 
217
                'Malformed JSON',
-
 
218
                'Could not decode the request body. The '
-
 
219
                'JSON was incorrect.')
-
 
220
            
-
 
221
        result = Mongo.addSkuDealerPrice(result_json)
-
 
222
        resp.body = json.dumps(result, encoding='utf-8')
-
 
223
    
-
 
224
    def on_put(self, req, resp, _id):
-
 
225
        try:
-
 
226
            result_json = json.loads(req.stream.read(), encoding='utf-8')
-
 
227
        except ValueError:
-
 
228
            raise falcon.HTTPError(falcon.HTTP_400,
-
 
229
                'Malformed JSON',
-
 
230
                'Could not decode the request body. The '
-
 
231
                'JSON was incorrect.')
-
 
232
            
-
 
233
        result = Mongo.updateSkuDealerPrice(result_json, _id)
-
 
234
        resp.body = json.dumps(result, encoding='utf-8')
-
 
235
 
-
 
236
    
164
    
237
    
165
238