| 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
|
| 1122 |
chandransh |
10 |
from sqlalchemy import create_engine
|
| 130 |
ashish |
11 |
from sqlalchemy.types import Integer
|
|
|
12 |
from elixir.relationships import OneToMany, ManyToOne
|
|
|
13 |
import datetime
|
| 746 |
rajveer |
14 |
import elixir
|
| 8707 |
manish.sha |
15 |
from sqlalchemy.types import Integer, String, Float, DateTime, Boolean, Enum, \
|
|
|
16 |
Numeric, BigInteger, LargeBinary,Date
|
| 130 |
ashish |
17 |
|
|
|
18 |
class Address(Entity):
|
|
|
19 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
20 |
line_1 = Field(String(100))
|
|
|
21 |
line_2 = Field(String(100))
|
|
|
22 |
landmark = Field(String(100))
|
|
|
23 |
city = Field(String(100))
|
|
|
24 |
state = Field(String(100))
|
|
|
25 |
pin = Field(String(10))
|
|
|
26 |
country = Field(String(100))
|
|
|
27 |
enabled = Field(Boolean)
|
|
|
28 |
type = Field(Integer)
|
|
|
29 |
added_on = Field(DateTime)
|
| 414 |
ashish |
30 |
name = Field(String(100))
|
|
|
31 |
phone = Field(String(20))
|
| 557 |
chandransh |
32 |
user = ManyToOne("User")
|
|
|
33 |
using_options(shortnames=True)
|
| 746 |
rajveer |
34 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
35 |
|
|
|
36 |
class User(Entity):
|
|
|
37 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 130 |
ashish |
38 |
email = Field(String(100))
|
|
|
39 |
password = Field(String(50))
|
| 557 |
chandransh |
40 |
name = Field(String(150))
|
| 504 |
rajveer |
41 |
default_address_id = Field(Integer)
|
|
|
42 |
communication_email = Field(String(100))
|
| 5326 |
rajveer |
43 |
active_cart = ManyToOne("Cart")
|
| 557 |
chandransh |
44 |
jsession_id = Field(String(64))
|
|
|
45 |
is_anonymous = Field(Boolean)
|
| 567 |
rajveer |
46 |
date_of_birth = Field(String(20))
|
| 557 |
chandransh |
47 |
sex = Field(Integer)
|
| 567 |
rajveer |
48 |
mobile_number = Field(String(20))
|
| 2020 |
vikas |
49 |
source = Field(String(200))
|
| 2815 |
vikas |
50 |
source_start_time = Field(DateTime)
|
| 3499 |
mandeep.dh |
51 |
trust_level = Field(Float)
|
| 5326 |
rajveer |
52 |
last_login = Field(DateTime)
|
|
|
53 |
last_logout = Field(DateTime)
|
|
|
54 |
active_since = Field(DateTime)
|
| 7883 |
rajveer |
55 |
fbusers = OneToMany("FacebookUser")
|
|
|
56 |
addresses = OneToMany("Address")
|
| 8201 |
rajveer |
57 |
sources = OneToMany("UserSource")
|
| 7883 |
rajveer |
58 |
using_options(shortnames=True)
|
|
|
59 |
using_table_options(mysql_engine="InnoDB")
|
|
|
60 |
|
|
|
61 |
class FacebookUser(Entity):
|
|
|
62 |
user = ManyToOne("User", primary_key=True)
|
| 7825 |
amar.kumar |
63 |
facebook_access_token = Field(String(200))
|
|
|
64 |
facebook_id = Field(String(50))
|
| 557 |
chandransh |
65 |
using_options(shortnames=True)
|
| 746 |
rajveer |
66 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
67 |
|
| 8201 |
rajveer |
68 |
class UserSource(Entity):
|
|
|
69 |
user = ManyToOne("User", primary_key=True)
|
|
|
70 |
source_id = Field(Integer)
|
|
|
71 |
using_options(shortnames=True)
|
|
|
72 |
using_table_options(mysql_engine="InnoDB")
|
|
|
73 |
|
| 557 |
chandransh |
74 |
class Line(Entity):
|
| 643 |
chandransh |
75 |
cart = ManyToOne("Cart", primary_key=True)
|
| 746 |
rajveer |
76 |
item_id = Field(Integer, primary_key=True, autoincrement=False)
|
| 557 |
chandransh |
77 |
quantity = Field(Float)
|
|
|
78 |
line_status = Field(Integer)
|
| 612 |
chandransh |
79 |
estimate = Field(Integer)
|
| 557 |
chandransh |
80 |
created_on = Field(DateTime)
|
|
|
81 |
updated_on = Field(DateTime)
|
| 1976 |
varun.gupt |
82 |
actual_price = Field(Float)
|
|
|
83 |
discounted_price = Field(Float)
|
| 3554 |
varun.gupt |
84 |
discounts = OneToMany('Discount')
|
| 6903 |
anupam.sin |
85 |
insurer = Field(Integer)
|
|
|
86 |
insuranceAmount = Field(Float)
|
| 9300 |
kshitij.so |
87 |
dataProtectionInsurer =Field(Integer, default=0, server_default="0")
|
|
|
88 |
dataProtectionAmount = Field(Float, default=0, server_default="0")
|
| 11653 |
amit.gupta |
89 |
dealText=Field(String(200))
|
|
|
90 |
freebieId=Field(Integer)
|
| 557 |
chandransh |
91 |
using_options(shortnames=True)
|
| 746 |
rajveer |
92 |
using_table_options(mysql_engine="InnoDB")
|
| 504 |
rajveer |
93 |
|
| 557 |
chandransh |
94 |
class Cart(Entity):
|
| 130 |
ashish |
95 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 557 |
chandransh |
96 |
cart_status = Field(Integer)
|
|
|
97 |
address_id = Field(Integer)
|
| 5555 |
rajveer |
98 |
pickupStoreId = Field(Integer)
|
| 690 |
chandransh |
99 |
checked_out_on = Field(DateTime)
|
| 557 |
chandransh |
100 |
created_on = Field(DateTime)
|
|
|
101 |
updated_on = Field(DateTime)
|
| 564 |
chandransh |
102 |
lines = OneToMany("Line")
|
| 1976 |
varun.gupt |
103 |
total_price = Field(Float)
|
|
|
104 |
discounted_price = Field(Float)
|
|
|
105 |
coupon_code = Field(String(20))
|
| 5326 |
rajveer |
106 |
user = OneToMany("User")
|
| 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)
|
|
|
134 |
created_on = Field(DateTime)
|
|
|
135 |
isActive = Field(Boolean)
|
| 11657 |
amit.gupta |
136 |
using_options(shortnames = True)
|
|
|
137 |
using_table_options(mysql_engine = "InnoDB")
|
| 1976 |
varun.gupt |
138 |
|
|
|
139 |
class Coupon(Entity):
|
|
|
140 |
coupon_code = Field(String(20))
|
|
|
141 |
promotion = ManyToOne("Promotion")
|
|
|
142 |
arguments = Field(String(200))
|
| 8707 |
manish.sha |
143 |
coupon_category = Field(Enum('CUSTOMER_SATISFACTION','MARKETING','REFUND'))
|
| 1976 |
varun.gupt |
144 |
using_options(shortnames = True)
|
|
|
145 |
using_table_options(mysql_engine = "InnoDB")
|
|
|
146 |
|
|
|
147 |
class PromotionTracker(Entity):
|
|
|
148 |
coupon_code = Field(String(20))
|
|
|
149 |
transaction_id = Field(Integer)
|
|
|
150 |
user_id = Field(Integer)
|
|
|
151 |
applied_on = Field(DateTime)
|
| 7987 |
amit.gupta |
152 |
promotion_id = Field(Integer)
|
| 1976 |
varun.gupt |
153 |
using_options(shortnames = True)
|
|
|
154 |
using_table_options(mysql_engine = "InnoDB")
|
| 5469 |
rajveer |
155 |
|
|
|
156 |
class RechargeVoucher(Entity):
|
|
|
157 |
id = Field(Integer, primary_key = True, autoincrement = True)
|
|
|
158 |
voucherCode = Field(String(30))
|
|
|
159 |
voucherType = Field(Integer)
|
|
|
160 |
amount = Field(Numeric(precision=8, scale=2, asdecimal=False))
|
|
|
161 |
available = Field(Boolean)
|
|
|
162 |
issuedOn = Field(DateTime)
|
|
|
163 |
expiredOn = Field(DateTime)
|
|
|
164 |
redeemed = Field(Boolean)
|
|
|
165 |
redeemedOn = Field(DateTime)
|
|
|
166 |
email = Field(String(100))
|
|
|
167 |
userId = Field(Integer)
|
|
|
168 |
using_options(shortnames = True)
|
|
|
169 |
using_table_options(mysql_engine = "InnoDB")
|
| 1976 |
varun.gupt |
170 |
|
|
|
171 |
#===============================================================================
|
| 1273 |
varun.gupt |
172 |
# Entity generated from Contact Us form
|
|
|
173 |
#===============================================================================
|
|
|
174 |
class UserCommunication(Entity):
|
|
|
175 |
id = Field(Integer, primary_key = True, autoincrement = True)
|
|
|
176 |
user_id = Field(Integer)
|
|
|
177 |
communication_type = Field(Integer)
|
|
|
178 |
order_id = Field(Integer)
|
|
|
179 |
airwaybill_no = Field(String(50))
|
|
|
180 |
reply_to = Field(String(50))
|
|
|
181 |
product_name = Field(String(200))
|
|
|
182 |
subject = Field(String(200))
|
|
|
183 |
message = Field(String(600))
|
| 1301 |
varun.gupt |
184 |
communication_timestamp = Field(DateTime)
|
| 1273 |
varun.gupt |
185 |
using_options(shortnames = True)
|
|
|
186 |
using_table_options(mysql_engine = "InnoDB")
|
|
|
187 |
|
|
|
188 |
#===============================================================================
|
| 557 |
chandransh |
189 |
# Different entities for the Widget service
|
|
|
190 |
#===============================================================================
|
|
|
191 |
|
| 2981 |
rajveer |
192 |
class UserWidgetItem(Entity):
|
|
|
193 |
userId = Field(Integer, primary_key=True)
|
|
|
194 |
widgetId = Field(Integer, primary_key=True)
|
|
|
195 |
itemId = Field(Integer, primary_key=True)
|
|
|
196 |
addedOn = Field(DateTime)
|
| 557 |
chandransh |
197 |
using_options(shortnames=True)
|
| 746 |
rajveer |
198 |
using_table_options(mysql_engine="InnoDB")
|
| 130 |
ashish |
199 |
|
| 1845 |
vikas |
200 |
class MasterAffiliate(Entity):
|
|
|
201 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
202 |
name = Field(String(100), unique=True)
|
| 1859 |
vikas |
203 |
added_on = Field(DateTime)
|
| 1845 |
vikas |
204 |
affiliates = OneToMany("Affiliate")
|
|
|
205 |
using_options(shortnames=True)
|
|
|
206 |
using_table_options(mysql_engine="InnoDB")
|
|
|
207 |
|
|
|
208 |
class Affiliate(Entity):
|
|
|
209 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
210 |
master_affiliate = ManyToOne("MasterAffiliate")
|
|
|
211 |
name = Field(String(100), unique=True)
|
|
|
212 |
url = Field(String(200))
|
| 1859 |
vikas |
213 |
added_on = Field(DateTime)
|
| 1996 |
vikas |
214 |
tracklogs = OneToMany("TrackLog")
|
| 1845 |
vikas |
215 |
using_options(shortnames=True)
|
|
|
216 |
using_table_options(mysql_engine="InnoDB")
|
|
|
217 |
|
|
|
218 |
class Tracker(Entity):
|
|
|
219 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 2004 |
vikas |
220 |
affiliate_id = Field(Integer)
|
|
|
221 |
added_on = Field(DateTime)
|
| 1845 |
vikas |
222 |
using_options(shortnames=True)
|
|
|
223 |
using_table_options(mysql_engine="InnoDB")
|
|
|
224 |
|
|
|
225 |
class TrackLog(Entity):
|
|
|
226 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 1859 |
vikas |
227 |
added_on = Field(DateTime)
|
| 1996 |
vikas |
228 |
affiliate = ManyToOne("Affiliate")
|
| 1845 |
vikas |
229 |
user_id = Field(Integer)
|
|
|
230 |
event = Field(String(100))
|
| 3378 |
vikas |
231 |
event_id = Field(Integer)
|
| 1845 |
vikas |
232 |
url = Field(String(200))
|
|
|
233 |
data = Field(String(200))
|
|
|
234 |
using_options(shortnames=True)
|
|
|
235 |
using_table_options(mysql_engine="InnoDB")
|
|
|
236 |
|
| 6903 |
anupam.sin |
237 |
class InsuranceDetails(Entity):
|
|
|
238 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
239 |
addressId = Field(Integer)
|
|
|
240 |
dob = Field(String(64))
|
|
|
241 |
guardianName = Field(String(255))
|
|
|
242 |
using_options(shortnames=True)
|
|
|
243 |
using_table_options(mysql_engine="InnoDB")
|
|
|
244 |
|
| 3187 |
rajveer |
245 |
def initialize(dbname='user', db_hostname="localhost"):
|
| 772 |
rajveer |
246 |
#metadata.bind = "sqlite:///user.sqlite" #need to read it from configserver.
|
| 5283 |
mandeep.dh |
247 |
engine = create_engine('mysql://root:shop2020@' + db_hostname + '/' + dbname, pool_recycle=7200, max_overflow=20)
|
| 1122 |
chandransh |
248 |
metadata.bind = engine
|
| 772 |
rajveer |
249 |
metadata.bind.echo = True
|
|
|
250 |
setup_all(True)
|
|
|
251 |
|
|
|
252 |
if __name__=="__main__":
|
|
|
253 |
initialize()
|