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