| 13572 |
kshitij.so |
1 |
import json
|
| 13582 |
amit.gupta |
2 |
from dtr import main
|
| 13629 |
kshitij.so |
3 |
from dtr.storage import Mongo
|
|
|
4 |
from bson import json_util
|
| 13772 |
kshitij.so |
5 |
import sys
|
|
|
6 |
sys.path.insert(0, '/usr/local/lib/python2.6/dist-packages/falcon-0.2.0b2-py2.6.egg/')
|
|
|
7 |
sys.path.insert(0, '/usr/local/lib/python2.6/dist-packages/six-1.9.0-py2.6.egg/')
|
|
|
8 |
sys.path.insert(0, '/usr/local/lib/python2.6/dist-packages/python_mimeparse-0.1.4-py2.6.egg/')
|
|
|
9 |
sys.path.insert(0, '/home/anupam/code/trunk/PyProj/src')
|
| 13629 |
kshitij.so |
10 |
import falcon
|
| 13572 |
kshitij.so |
11 |
|
|
|
12 |
|
|
|
13 |
class CategoryDiscountInfo(object):
|
|
|
14 |
|
|
|
15 |
def on_get(self, req, resp):
|
|
|
16 |
|
| 13629 |
kshitij.so |
17 |
result = Mongo.getAllCategoryDiscount()
|
|
|
18 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
|
|
19 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
| 13572 |
kshitij.so |
20 |
|
|
|
21 |
def on_post(self, req, resp):
|
|
|
22 |
|
|
|
23 |
try:
|
|
|
24 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
|
|
25 |
except ValueError:
|
|
|
26 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
27 |
'Malformed JSON',
|
|
|
28 |
'Could not decode the request body. The '
|
|
|
29 |
'JSON was incorrect.')
|
|
|
30 |
|
|
|
31 |
result = Mongo.addCategoryDiscount(result_json)
|
|
|
32 |
resp.body = json.dumps(result, encoding='utf-8')
|
|
|
33 |
|
|
|
34 |
class SkuSchemeDetails(object):
|
|
|
35 |
|
|
|
36 |
def on_get(self, req, resp):
|
| 13629 |
kshitij.so |
37 |
|
| 13635 |
kshitij.so |
38 |
result = Mongo.getAllSkuWiseSchemeDetails()
|
| 13629 |
kshitij.so |
39 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
|
|
40 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
| 13572 |
kshitij.so |
41 |
|
|
|
42 |
|
|
|
43 |
def on_post(self, req, resp):
|
|
|
44 |
|
|
|
45 |
try:
|
|
|
46 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
|
|
47 |
except ValueError:
|
|
|
48 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
49 |
'Malformed JSON',
|
|
|
50 |
'Could not decode the request body. The '
|
|
|
51 |
'JSON was incorrect.')
|
|
|
52 |
|
|
|
53 |
result = Mongo.addSchemeDetailsForSku(result_json)
|
|
|
54 |
resp.body = json.dumps(result, encoding='utf-8')
|
|
|
55 |
|
|
|
56 |
class SkuDiscountInfo():
|
|
|
57 |
|
|
|
58 |
def on_get(self, req, resp):
|
| 13629 |
kshitij.so |
59 |
|
|
|
60 |
result = Mongo.getallSkuDiscountInfo()
|
|
|
61 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
|
|
62 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
| 13572 |
kshitij.so |
63 |
|
|
|
64 |
|
|
|
65 |
def on_post(self, req, resp):
|
|
|
66 |
|
|
|
67 |
try:
|
|
|
68 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
|
|
69 |
except ValueError:
|
|
|
70 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
71 |
'Malformed JSON',
|
|
|
72 |
'Could not decode the request body. The '
|
|
|
73 |
'JSON was incorrect.')
|
|
|
74 |
|
|
|
75 |
result = Mongo.addSkuDiscountInfo(result_json)
|
|
|
76 |
resp.body = json.dumps(result, encoding='utf-8')
|
|
|
77 |
|
|
|
78 |
class ExceptionalNlc():
|
|
|
79 |
|
|
|
80 |
def on_get(self, req, resp):
|
| 13629 |
kshitij.so |
81 |
|
|
|
82 |
result = Mongo.getAllExceptionlNlcItems()
|
|
|
83 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
|
|
84 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
| 13572 |
kshitij.so |
85 |
|
|
|
86 |
def on_post(self, req, resp):
|
|
|
87 |
|
|
|
88 |
try:
|
|
|
89 |
result_json = json.loads(req.stream.read(), encoding='utf-8')
|
|
|
90 |
except ValueError:
|
|
|
91 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
92 |
'Malformed JSON',
|
|
|
93 |
'Could not decode the request body. The '
|
|
|
94 |
'JSON was incorrect.')
|
|
|
95 |
|
|
|
96 |
result = Mongo.addExceptionalNlc(result_json)
|
|
|
97 |
resp.body = json.dumps(result, encoding='utf-8')
|
|
|
98 |
|
| 13582 |
amit.gupta |
99 |
class StoreOrder():
|
|
|
100 |
def on_post(self, req, resp):
|
|
|
101 |
|
|
|
102 |
try:
|
| 13631 |
amit.gupta |
103 |
string1 = req.stream.read()
|
|
|
104 |
req_json = json.loads(string1, encoding='utf-8')
|
| 13582 |
amit.gupta |
105 |
except ValueError:
|
|
|
106 |
raise falcon.HTTPError(falcon.HTTP_400,
|
|
|
107 |
'Malformed JSON',
|
|
|
108 |
'Could not decode the request body. The '
|
|
|
109 |
'JSON was incorrect.')
|
|
|
110 |
|
| 13631 |
amit.gupta |
111 |
store = main.getStore(int(req_json['sourceId']))
|
|
|
112 |
result = store.parseOrderRawHtml(int(req_json['orderId']), req_json['subTagId'], int(req_json['userId']), req_json['rawHtml'], req_json['orderSuccessUrl'])
|
| 13582 |
amit.gupta |
113 |
resp.body = json.dumps({"result":result}, encoding='utf-8')
|
|
|
114 |
|
| 13603 |
amit.gupta |
115 |
def on_get(self, req, resp, userId):
|
|
|
116 |
page = req.get_param_as_int("page")
|
|
|
117 |
window = req.get_param_as_int("window")
|
|
|
118 |
result = Mongo.getMerchantOrdersByUser(int(userId), page, window)
|
|
|
119 |
print result
|
|
|
120 |
resp.body = json.dumps(result, encoding='utf-8')
|
| 13582 |
amit.gupta |
121 |
|
| 13772 |
kshitij.so |
122 |
class Deals():
|
|
|
123 |
def on_get(self,req, resp, userId, categoryId, offset, limit):
|
|
|
124 |
print userId
|
|
|
125 |
print categoryId
|
|
|
126 |
result = Mongo.getDeals(categoryId, offset, limit)
|
|
|
127 |
json_docs = [json.dumps(doc, default=json_util.default) for doc in result]
|
|
|
128 |
resp.body = json.dumps(json_docs, encoding='utf-8')
|
| 13582 |
amit.gupta |
129 |
|