| 130 |
ashish |
1 |
'''
|
|
|
2 |
Created on 28-Apr-2010
|
|
|
3 |
|
|
|
4 |
@author: ashish
|
|
|
5 |
'''
|
|
|
6 |
|
|
|
7 |
from elixir import *
|
|
|
8 |
from elixir.entity import Entity
|
|
|
9 |
from elixir.fields import Field
|
| 12696 |
amit.gupta |
10 |
from elixir.relationships import OneToMany, ManyToOne
|
| 1122 |
chandransh |
11 |
from sqlalchemy import create_engine
|
| 12696 |
amit.gupta |
12 |
from sqlalchemy.types import Integer, Integer, String, Float, DateTime, Boolean, \
|
|
|
13 |
Enum, Numeric, BigInteger, LargeBinary, Date
|
| 130 |
ashish |
14 |
import datetime
|
| 746 |
rajveer |
15 |
import elixir
|
| 130 |
ashish |
16 |
|
|
|
17 |
class Address(Entity):
|
|
|
18 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
19 |
line_1 = Field(String(100))
|
|
|
20 |
line_2 = Field(String(100))
|
|
|
21 |
landmark = Field(String(100))
|
|
|
22 |
city = Field(String(100))
|
|
|
23 |
state = Field(String(100))
|
|
|
24 |
pin = Field(String(10))
|
|
|
25 |
country = Field(String(100))
|
|
|
26 |
enabled = Field(Boolean)
|
|
|
27 |
type = Field(Integer)
|
|
|
28 |
added_on = Field(DateTime)
|
| 414 |
ashish |
29 |
name = Field(String(100))
|
|
|
30 |
phone = Field(String(20))
|
| 557 |
chandransh |
31 |
user = ManyToOne("User")
|
|
|
32 |
using_options(shortnames=True)
|
| 746 |
rajveer |
33 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
34 |
|
|
|
35 |
class User(Entity):
|
|
|
36 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 130 |
ashish |
37 |
email = Field(String(100))
|
|
|
38 |
password = Field(String(50))
|
| 557 |
chandransh |
39 |
name = Field(String(150))
|
| 504 |
rajveer |
40 |
default_address_id = Field(Integer)
|
|
|
41 |
communication_email = Field(String(100))
|
| 5326 |
rajveer |
42 |
active_cart = ManyToOne("Cart")
|
| 557 |
chandransh |
43 |
jsession_id = Field(String(64))
|
|
|
44 |
is_anonymous = Field(Boolean)
|
| 567 |
rajveer |
45 |
date_of_birth = Field(String(20))
|
| 557 |
chandransh |
46 |
sex = Field(Integer)
|
| 567 |
rajveer |
47 |
mobile_number = Field(String(20))
|
| 2020 |
vikas |
48 |
source = Field(String(200))
|
| 2815 |
vikas |
49 |
source_start_time = Field(DateTime)
|
| 3499 |
mandeep.dh |
50 |
trust_level = Field(Float)
|
| 5326 |
rajveer |
51 |
last_login = Field(DateTime)
|
|
|
52 |
last_logout = Field(DateTime)
|
|
|
53 |
active_since = Field(DateTime)
|
| 7883 |
rajveer |
54 |
fbusers = OneToMany("FacebookUser")
|
|
|
55 |
addresses = OneToMany("Address")
|
| 8201 |
rajveer |
56 |
sources = OneToMany("UserSource")
|
| 7883 |
rajveer |
57 |
using_options(shortnames=True)
|
|
|
58 |
using_table_options(mysql_engine="InnoDB")
|
|
|
59 |
|
|
|
60 |
class FacebookUser(Entity):
|
|
|
61 |
user = ManyToOne("User", primary_key=True)
|
| 7825 |
amar.kumar |
62 |
facebook_access_token = Field(String(200))
|
|
|
63 |
facebook_id = Field(String(50))
|
| 557 |
chandransh |
64 |
using_options(shortnames=True)
|
| 746 |
rajveer |
65 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
66 |
|
| 8201 |
rajveer |
67 |
class UserSource(Entity):
|
|
|
68 |
user = ManyToOne("User", primary_key=True)
|
|
|
69 |
source_id = Field(Integer)
|
|
|
70 |
using_options(shortnames=True)
|
|
|
71 |
using_table_options(mysql_engine="InnoDB")
|
|
|
72 |
|
| 557 |
chandransh |
73 |
class Line(Entity):
|
| 643 |
chandransh |
74 |
cart = ManyToOne("Cart", primary_key=True)
|
| 746 |
rajveer |
75 |
item_id = Field(Integer, primary_key=True, autoincrement=False)
|
| 557 |
chandransh |
76 |
quantity = Field(Float)
|
|
|
77 |
line_status = Field(Integer)
|
| 612 |
chandransh |
78 |
estimate = Field(Integer)
|
| 557 |
chandransh |
79 |
created_on = Field(DateTime)
|
|
|
80 |
updated_on = Field(DateTime)
|
| 1976 |
varun.gupt |
81 |
actual_price = Field(Float)
|
|
|
82 |
discounted_price = Field(Float)
|
| 3554 |
varun.gupt |
83 |
discounts = OneToMany('Discount')
|
| 6903 |
anupam.sin |
84 |
insurer = Field(Integer)
|
|
|
85 |
insuranceAmount = Field(Float)
|
| 9300 |
kshitij.so |
86 |
dataProtectionInsurer =Field(Integer, default=0, server_default="0")
|
|
|
87 |
dataProtectionAmount = Field(Float, default=0, server_default="0")
|
| 11653 |
amit.gupta |
88 |
dealText=Field(String(200))
|
|
|
89 |
freebieId=Field(Integer)
|
| 557 |
chandransh |
90 |
using_options(shortnames=True)
|
| 746 |
rajveer |
91 |
using_table_options(mysql_engine="InnoDB")
|
| 504 |
rajveer |
92 |
|
| 557 |
chandransh |
93 |
class Cart(Entity):
|
| 130 |
ashish |
94 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 557 |
chandransh |
95 |
cart_status = Field(Integer)
|
|
|
96 |
address_id = Field(Integer)
|
| 5555 |
rajveer |
97 |
pickupStoreId = Field(Integer)
|
| 690 |
chandransh |
98 |
checked_out_on = Field(DateTime)
|
| 557 |
chandransh |
99 |
created_on = Field(DateTime)
|
|
|
100 |
updated_on = Field(DateTime)
|
| 564 |
chandransh |
101 |
lines = OneToMany("Line")
|
| 1976 |
varun.gupt |
102 |
total_price = Field(Float)
|
|
|
103 |
discounted_price = Field(Float)
|
|
|
104 |
coupon_code = Field(String(20))
|
| 13139 |
amit.gupta |
105 |
user = OneToMany("User")
|
| 20873 |
kshitij.so |
106 |
wallet_amount = Field(Float, default=0, server_default="0")
|
| 557 |
chandransh |
107 |
using_options(shortnames=True)
|
| 746 |
rajveer |
108 |
using_table_options(mysql_engine="InnoDB")
|
| 130 |
ashish |
109 |
|
| 3554 |
varun.gupt |
110 |
class Discount(Entity):
|
|
|
111 |
line = ManyToOne("Line", primary_key=True)
|
|
|
112 |
discount = Field(Float, primary_key = True)
|
|
|
113 |
quantity = Field(Float)
|
|
|
114 |
using_options(shortnames = True)
|
|
|
115 |
using_table_options(mysql_engine = 'InnoDB')
|
|
|
116 |
|
| 557 |
chandransh |
117 |
#===============================================================================
|
| 1976 |
varun.gupt |
118 |
# Entity generated from Promotion Service
|
|
|
119 |
#===============================================================================
|
|
|
120 |
class Promotion(Entity):
|
|
|
121 |
id = Field(Integer, primary_key = True, autoincrement = True)
|
|
|
122 |
name = Field(String(200))
|
|
|
123 |
rule_execution_src = Field(String(100))
|
|
|
124 |
start_on = Field(DateTime)
|
|
|
125 |
end_on = Field(DateTime)
|
|
|
126 |
coupons = OneToMany("Coupon")
|
|
|
127 |
created_on = Field(DateTime)
|
| 6367 |
amit.gupta |
128 |
type = Field(Integer)
|
| 1976 |
varun.gupt |
129 |
using_options(shortnames = True)
|
|
|
130 |
using_table_options(mysql_engine = "InnoDB")
|
| 11653 |
amit.gupta |
131 |
|
|
|
132 |
class PrivateDealUser(Entity):
|
|
|
133 |
id = Field(Integer, primary_key=True)
|
| 12696 |
amit.gupta |
134 |
counter = ManyToOne("Counter")
|
|
|
135 |
tin = Field(String(20))
|
| 11653 |
amit.gupta |
136 |
created_on = Field(DateTime)
|
|
|
137 |
isActive = Field(Boolean)
|
| 13400 |
manish.sha |
138 |
bulkShipmentAmountLimit = Field(Float, default=50000)
|
| 18590 |
manish.sha |
139 |
creditorAssigned = Field(Boolean)
|
| 18735 |
manish.sha |
140 |
tinVerified = Field(Boolean)
|
| 22715 |
amit.gupta |
141 |
isFofo = Field(Boolean)
|
| 11657 |
amit.gupta |
142 |
using_options(shortnames = True)
|
|
|
143 |
using_table_options(mysql_engine = "InnoDB")
|
| 1976 |
varun.gupt |
144 |
|
|
|
145 |
class Coupon(Entity):
|
|
|
146 |
coupon_code = Field(String(20))
|
|
|
147 |
promotion = ManyToOne("Promotion")
|
|
|
148 |
arguments = Field(String(200))
|
| 8707 |
manish.sha |
149 |
coupon_category = Field(Enum('CUSTOMER_SATISFACTION','MARKETING','REFUND'))
|
| 1976 |
varun.gupt |
150 |
using_options(shortnames = True)
|
|
|
151 |
using_table_options(mysql_engine = "InnoDB")
|
|
|
152 |
|
|
|
153 |
class PromotionTracker(Entity):
|
|
|
154 |
coupon_code = Field(String(20))
|
|
|
155 |
transaction_id = Field(Integer)
|
|
|
156 |
user_id = Field(Integer)
|
|
|
157 |
applied_on = Field(DateTime)
|
| 7987 |
amit.gupta |
158 |
promotion_id = Field(Integer)
|
| 13521 |
amit.gupta |
159 |
amount = Field(Integer)
|
|
|
160 |
is_digital = Field(Boolean)
|
| 1976 |
varun.gupt |
161 |
using_options(shortnames = True)
|
|
|
162 |
using_table_options(mysql_engine = "InnoDB")
|
| 5469 |
rajveer |
163 |
|
|
|
164 |
class RechargeVoucher(Entity):
|
|
|
165 |
id = Field(Integer, primary_key = True, autoincrement = True)
|
|
|
166 |
voucherCode = Field(String(30))
|
|
|
167 |
voucherType = Field(Integer)
|
|
|
168 |
amount = Field(Numeric(precision=8, scale=2, asdecimal=False))
|
|
|
169 |
available = Field(Boolean)
|
|
|
170 |
issuedOn = Field(DateTime)
|
|
|
171 |
expiredOn = Field(DateTime)
|
|
|
172 |
redeemed = Field(Boolean)
|
|
|
173 |
redeemedOn = Field(DateTime)
|
|
|
174 |
email = Field(String(100))
|
|
|
175 |
userId = Field(Integer)
|
|
|
176 |
using_options(shortnames = True)
|
|
|
177 |
using_table_options(mysql_engine = "InnoDB")
|
| 1976 |
varun.gupt |
178 |
|
|
|
179 |
#===============================================================================
|
| 1273 |
varun.gupt |
180 |
# Entity generated from Contact Us form
|
|
|
181 |
#===============================================================================
|
|
|
182 |
class UserCommunication(Entity):
|
|
|
183 |
id = Field(Integer, primary_key = True, autoincrement = True)
|
|
|
184 |
user_id = Field(Integer)
|
|
|
185 |
communication_type = Field(Integer)
|
|
|
186 |
order_id = Field(Integer)
|
|
|
187 |
airwaybill_no = Field(String(50))
|
|
|
188 |
reply_to = Field(String(50))
|
|
|
189 |
product_name = Field(String(200))
|
|
|
190 |
subject = Field(String(200))
|
|
|
191 |
message = Field(String(600))
|
| 1301 |
varun.gupt |
192 |
communication_timestamp = Field(DateTime)
|
| 1273 |
varun.gupt |
193 |
using_options(shortnames = True)
|
|
|
194 |
using_table_options(mysql_engine = "InnoDB")
|
|
|
195 |
|
|
|
196 |
#===============================================================================
|
| 557 |
chandransh |
197 |
# Different entities for the Widget service
|
|
|
198 |
#===============================================================================
|
|
|
199 |
|
| 2981 |
rajveer |
200 |
class UserWidgetItem(Entity):
|
|
|
201 |
userId = Field(Integer, primary_key=True)
|
|
|
202 |
widgetId = Field(Integer, primary_key=True)
|
|
|
203 |
itemId = Field(Integer, primary_key=True)
|
|
|
204 |
addedOn = Field(DateTime)
|
| 557 |
chandransh |
205 |
using_options(shortnames=True)
|
| 746 |
rajveer |
206 |
using_table_options(mysql_engine="InnoDB")
|
| 130 |
ashish |
207 |
|
| 1845 |
vikas |
208 |
class MasterAffiliate(Entity):
|
|
|
209 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
210 |
name = Field(String(100), unique=True)
|
| 1859 |
vikas |
211 |
added_on = Field(DateTime)
|
| 1845 |
vikas |
212 |
affiliates = OneToMany("Affiliate")
|
|
|
213 |
using_options(shortnames=True)
|
|
|
214 |
using_table_options(mysql_engine="InnoDB")
|
|
|
215 |
|
|
|
216 |
class Affiliate(Entity):
|
|
|
217 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
218 |
master_affiliate = ManyToOne("MasterAffiliate")
|
|
|
219 |
name = Field(String(100), unique=True)
|
|
|
220 |
url = Field(String(200))
|
| 1859 |
vikas |
221 |
added_on = Field(DateTime)
|
| 1996 |
vikas |
222 |
tracklogs = OneToMany("TrackLog")
|
| 1845 |
vikas |
223 |
using_options(shortnames=True)
|
|
|
224 |
using_table_options(mysql_engine="InnoDB")
|
|
|
225 |
|
|
|
226 |
class Tracker(Entity):
|
|
|
227 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 2004 |
vikas |
228 |
affiliate_id = Field(Integer)
|
|
|
229 |
added_on = Field(DateTime)
|
| 1845 |
vikas |
230 |
using_options(shortnames=True)
|
|
|
231 |
using_table_options(mysql_engine="InnoDB")
|
|
|
232 |
|
|
|
233 |
class TrackLog(Entity):
|
|
|
234 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 1859 |
vikas |
235 |
added_on = Field(DateTime)
|
| 1996 |
vikas |
236 |
affiliate = ManyToOne("Affiliate")
|
| 1845 |
vikas |
237 |
user_id = Field(Integer)
|
|
|
238 |
event = Field(String(100))
|
| 3378 |
vikas |
239 |
event_id = Field(Integer)
|
| 1845 |
vikas |
240 |
url = Field(String(200))
|
|
|
241 |
data = Field(String(200))
|
|
|
242 |
using_options(shortnames=True)
|
|
|
243 |
using_table_options(mysql_engine="InnoDB")
|
|
|
244 |
|
| 6903 |
anupam.sin |
245 |
class InsuranceDetails(Entity):
|
|
|
246 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
247 |
addressId = Field(Integer)
|
|
|
248 |
dob = Field(String(64))
|
|
|
249 |
guardianName = Field(String(255))
|
|
|
250 |
using_options(shortnames=True)
|
|
|
251 |
using_table_options(mysql_engine="InnoDB")
|
| 12696 |
amit.gupta |
252 |
|
|
|
253 |
class Counter(Entity):
|
|
|
254 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
255 |
code = Field(String(10),unique=True)
|
|
|
256 |
dealUsers = OneToMany("PrivateDealUser")
|
|
|
257 |
name = Field(String(128))
|
|
|
258 |
ownerName = Field(String(100))
|
|
|
259 |
email = Field(String(80))
|
|
|
260 |
mobile = Field(String(10))
|
|
|
261 |
alternateMobile = Field(String(10))
|
|
|
262 |
addressId = Field(Integer)
|
|
|
263 |
striker = Field(Boolean)
|
|
|
264 |
tin = Field(String(20), unique=True)
|
| 21908 |
amit.gupta |
265 |
gstin = Field(String(20), unique=True)
|
| 12696 |
amit.gupta |
266 |
spCounterSize = Field(Integer)
|
|
|
267 |
fpCounterSize = Field(Integer)
|
| 12722 |
amit.gupta |
268 |
dob = Field(String(20))
|
| 12696 |
amit.gupta |
269 |
createdOn = Field(DateTime)
|
| 12730 |
amit.gupta |
270 |
lastPurchasedOn = Field(DateTime)
|
| 18530 |
manish.sha |
271 |
documentVerified = Field(Boolean)
|
|
|
272 |
verificationType = Field(Integer)
|
|
|
273 |
verifiedOn = Field(DateTime)
|
| 12696 |
amit.gupta |
274 |
using_options(shortnames=True)
|
|
|
275 |
using_table_options(mysql_engine="InnoDB")
|
| 15251 |
manish.sha |
276 |
|
| 18530 |
manish.sha |
277 |
class CounterOnlineInfo(Entity):
|
|
|
278 |
counterId = Field(Integer, primary_key=True)
|
|
|
279 |
tinNumber = Field(String(30))
|
|
|
280 |
cstNumber = Field(String(30))
|
|
|
281 |
dealerName = Field(String(100))
|
|
|
282 |
dealerAddress = Field(Text)
|
|
|
283 |
state = Field(String(20))
|
|
|
284 |
pan = Field(String(20))
|
|
|
285 |
registrationDate = Field(DateTime)
|
|
|
286 |
registrationStatus = Field(Boolean)
|
|
|
287 |
validatedTill = Field(DateTime)
|
| 18634 |
manish.sha |
288 |
created = Field(DateTime,default = datetime.datetime.now)
|
| 18530 |
manish.sha |
289 |
using_options(shortnames=True)
|
|
|
290 |
using_table_options(mysql_engine="InnoDB")
|
|
|
291 |
|
| 18735 |
manish.sha |
292 |
class PrivateDealUserAddressMapping(Entity):
|
| 18736 |
manish.sha |
293 |
user_id = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
294 |
address_id = Field(Integer, primary_key=True, autoincrement=False)
|
| 18735 |
manish.sha |
295 |
taxInvoiceAvailable = Field(Boolean)
|
|
|
296 |
creditOptionAvailable = Field(Boolean)
|
|
|
297 |
createdAt = Field(DateTime,default = datetime.datetime.now)
|
|
|
298 |
using_options(shortnames=True)
|
|
|
299 |
using_table_options(mysql_engine="InnoDB")
|
|
|
300 |
|
| 15251 |
manish.sha |
301 |
class AccessTokenizer(Entity):
|
|
|
302 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
303 |
userId = Field(Integer)
|
|
|
304 |
source = Field(String(50))
|
|
|
305 |
tokenString = Field(String(50))
|
|
|
306 |
expiredTime = Field(DateTime)
|
|
|
307 |
expired = Field(Boolean)
|
|
|
308 |
using_options(shortnames=True)
|
|
|
309 |
using_table_options(mysql_engine="InnoDB")
|
| 6903 |
anupam.sin |
310 |
|
| 19236 |
manish.sha |
311 |
def initialize(dbname='user', db_hostname="localhost", setup=True):
|
| 772 |
rajveer |
312 |
#metadata.bind = "sqlite:///user.sqlite" #need to read it from configserver.
|
| 35608 |
amit |
313 |
engine = create_engine('mysql://root:shop2020@' + db_hostname + '/' + dbname,
|
| 35701 |
amit |
314 |
pool_recycle=3600, pool_timeout=30, max_overflow=50)
|
| 1122 |
chandransh |
315 |
metadata.bind = engine
|
| 35608 |
amit |
316 |
metadata.bind.echo = False
|
| 19236 |
manish.sha |
317 |
setup_all(setup)
|
| 772 |
rajveer |
318 |
|
|
|
319 |
if __name__=="__main__":
|
|
|
320 |
initialize()
|