| 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 SocialService(Entity):
|
|
|
17 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
18 |
name = Field(String(100))
|
|
|
19 |
handles = OneToMany("SocialHandle")
|
| 557 |
chandransh |
20 |
using_options(shortnames=True)
|
| 746 |
rajveer |
21 |
using_table_options(mysql_engine="InnoDB")
|
|
|
22 |
|
| 130 |
ashish |
23 |
class SocialHandle(Entity):
|
|
|
24 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
25 |
handle = Field(String(100))
|
|
|
26 |
service = ManyToOne("SocialService")
|
| 557 |
chandransh |
27 |
user = ManyToOne("User")
|
|
|
28 |
using_options(shortnames=True)
|
| 746 |
rajveer |
29 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
30 |
|
| 130 |
ashish |
31 |
class Address(Entity):
|
|
|
32 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
33 |
line_1 = Field(String(100))
|
|
|
34 |
line_2 = Field(String(100))
|
|
|
35 |
landmark = Field(String(100))
|
|
|
36 |
city = Field(String(100))
|
|
|
37 |
state = Field(String(100))
|
|
|
38 |
pin = Field(String(10))
|
|
|
39 |
country = Field(String(100))
|
|
|
40 |
enabled = Field(Boolean)
|
|
|
41 |
type = Field(Integer)
|
|
|
42 |
added_on = Field(DateTime)
|
| 414 |
ashish |
43 |
name = Field(String(100))
|
|
|
44 |
phone = Field(String(20))
|
| 557 |
chandransh |
45 |
user = ManyToOne("User")
|
|
|
46 |
using_options(shortnames=True)
|
| 746 |
rajveer |
47 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
48 |
|
| 130 |
ashish |
49 |
class Phone(Entity):
|
|
|
50 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
51 |
country_code = Field(String(5))
|
|
|
52 |
area_code = Field(String(10))
|
|
|
53 |
number = Field(String(20))
|
|
|
54 |
extension = Field(String(10))
|
|
|
55 |
type = Field(Integer)
|
| 557 |
chandransh |
56 |
user = ManyToOne("User")
|
|
|
57 |
using_options(shortnames=True)
|
| 746 |
rajveer |
58 |
using_table_options(mysql_engine="InnoDB")
|
| 130 |
ashish |
59 |
|
| 557 |
chandransh |
60 |
class InternalInfo(Entity):
|
| 130 |
ashish |
61 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 557 |
chandransh |
62 |
geo_zone = Field(Integer)
|
|
|
63 |
shipment_zone = Field(Integer)
|
|
|
64 |
tax_zone = Field(Integer)
|
|
|
65 |
rank_score = Field(Float)
|
|
|
66 |
user = ManyToOne("User")
|
|
|
67 |
using_options(shortnames=True)
|
| 746 |
rajveer |
68 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
69 |
|
| 130 |
ashish |
70 |
class IPMap(Entity):
|
|
|
71 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
72 |
timestamp = Field(DateTime)
|
|
|
73 |
ip = Field(String(30))
|
| 557 |
chandransh |
74 |
user_state = ManyToOne("UserState")
|
|
|
75 |
using_options(shortnames=True)
|
| 746 |
rajveer |
76 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
77 |
|
|
|
78 |
class UserState(Entity):
|
| 130 |
ashish |
79 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 557 |
chandransh |
80 |
last_login = Field(DateTime)
|
|
|
81 |
last_logout = Field(DateTime)
|
|
|
82 |
email_verification_sent_on = Field(DateTime)
|
|
|
83 |
sms_verification_sent_on = Field(DateTime)
|
|
|
84 |
is_email_verified = Field(Boolean)
|
|
|
85 |
is_sms_verified =Field(Boolean)
|
|
|
86 |
active_since = Field(DateTime)
|
|
|
87 |
account_status = Field(Integer)
|
|
|
88 |
ip_list = OneToMany("IPMap")
|
|
|
89 |
user = ManyToOne("User")
|
|
|
90 |
using_options(shortnames=True)
|
| 746 |
rajveer |
91 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
92 |
|
|
|
93 |
class User(Entity):
|
|
|
94 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 130 |
ashish |
95 |
email = Field(String(100))
|
|
|
96 |
password = Field(String(50))
|
| 557 |
chandransh |
97 |
name = Field(String(150))
|
| 504 |
rajveer |
98 |
default_address_id = Field(Integer)
|
|
|
99 |
communication_email = Field(String(100))
|
| 557 |
chandransh |
100 |
active_cart_id = Field(Integer)
|
|
|
101 |
jsession_id = Field(String(64))
|
|
|
102 |
is_anonymous = Field(Boolean)
|
| 567 |
rajveer |
103 |
date_of_birth = Field(String(20))
|
| 557 |
chandransh |
104 |
sex = Field(Integer)
|
| 567 |
rajveer |
105 |
mobile_number = Field(String(20))
|
| 2020 |
vikas |
106 |
source = Field(String(200))
|
| 2815 |
vikas |
107 |
source_start_time = Field(DateTime)
|
| 3499 |
mandeep.dh |
108 |
trust_level = Field(Float)
|
| 130 |
ashish |
109 |
addresses = OneToMany("Address")
|
|
|
110 |
social_handles = OneToMany("SocialHandle")
|
| 557 |
chandransh |
111 |
using_options(shortnames=True)
|
| 746 |
rajveer |
112 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
113 |
|
|
|
114 |
class Line(Entity):
|
| 643 |
chandransh |
115 |
cart = ManyToOne("Cart", primary_key=True)
|
| 746 |
rajveer |
116 |
item_id = Field(Integer, primary_key=True, autoincrement=False)
|
| 557 |
chandransh |
117 |
quantity = Field(Float)
|
|
|
118 |
line_status = Field(Integer)
|
| 612 |
chandransh |
119 |
estimate = Field(Integer)
|
| 557 |
chandransh |
120 |
created_on = Field(DateTime)
|
|
|
121 |
updated_on = Field(DateTime)
|
| 1976 |
varun.gupt |
122 |
actual_price = Field(Float)
|
|
|
123 |
discounted_price = Field(Float)
|
| 3554 |
varun.gupt |
124 |
discounts = OneToMany('Discount')
|
| 557 |
chandransh |
125 |
using_options(shortnames=True)
|
| 746 |
rajveer |
126 |
using_table_options(mysql_engine="InnoDB")
|
| 504 |
rajveer |
127 |
|
| 557 |
chandransh |
128 |
class Cart(Entity):
|
| 130 |
ashish |
129 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 557 |
chandransh |
130 |
user_id = Field(Integer)
|
|
|
131 |
cart_status = Field(Integer)
|
|
|
132 |
address_id = Field(Integer)
|
| 690 |
chandransh |
133 |
checked_out_on = Field(DateTime)
|
| 557 |
chandransh |
134 |
created_on = Field(DateTime)
|
|
|
135 |
updated_on = Field(DateTime)
|
| 564 |
chandransh |
136 |
lines = OneToMany("Line")
|
| 1976 |
varun.gupt |
137 |
total_price = Field(Float)
|
|
|
138 |
discounted_price = Field(Float)
|
|
|
139 |
coupon_code = Field(String(20))
|
| 557 |
chandransh |
140 |
using_options(shortnames=True)
|
| 746 |
rajveer |
141 |
using_table_options(mysql_engine="InnoDB")
|
| 130 |
ashish |
142 |
|
| 3554 |
varun.gupt |
143 |
class Discount(Entity):
|
|
|
144 |
line = ManyToOne("Line", primary_key=True)
|
|
|
145 |
discount = Field(Float, primary_key = True)
|
|
|
146 |
quantity = Field(Float)
|
|
|
147 |
using_options(shortnames = True)
|
|
|
148 |
using_table_options(mysql_engine = 'InnoDB')
|
|
|
149 |
|
| 557 |
chandransh |
150 |
#===============================================================================
|
| 1976 |
varun.gupt |
151 |
# Entity generated from Promotion Service
|
|
|
152 |
#===============================================================================
|
|
|
153 |
class Promotion(Entity):
|
|
|
154 |
id = Field(Integer, primary_key = True, autoincrement = True)
|
|
|
155 |
name = Field(String(200))
|
|
|
156 |
rule_execution_src = Field(String(100))
|
|
|
157 |
start_on = Field(DateTime)
|
|
|
158 |
end_on = Field(DateTime)
|
|
|
159 |
coupons = OneToMany("Coupon")
|
|
|
160 |
created_on = Field(DateTime)
|
|
|
161 |
using_options(shortnames = True)
|
|
|
162 |
using_table_options(mysql_engine = "InnoDB")
|
|
|
163 |
|
|
|
164 |
class Coupon(Entity):
|
|
|
165 |
coupon_code = Field(String(20))
|
|
|
166 |
promotion = ManyToOne("Promotion")
|
|
|
167 |
arguments = Field(String(200))
|
|
|
168 |
using_options(shortnames = True)
|
|
|
169 |
using_table_options(mysql_engine = "InnoDB")
|
|
|
170 |
|
|
|
171 |
class PromotionTracker(Entity):
|
|
|
172 |
coupon_code = Field(String(20))
|
|
|
173 |
transaction_id = Field(Integer)
|
|
|
174 |
user_id = Field(Integer)
|
|
|
175 |
applied_on = Field(DateTime)
|
|
|
176 |
using_options(shortnames = True)
|
|
|
177 |
using_table_options(mysql_engine = "InnoDB")
|
|
|
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 |
|
| 2641 |
varun.gupt |
245 |
class UserNote(Entity):
|
|
|
246 |
user_id = Field(Integer)
|
|
|
247 |
entity_id = Field(Integer)
|
| 2717 |
varun.gupt |
248 |
slide = Field(String(30))
|
| 2641 |
varun.gupt |
249 |
note = Field(String(500))
|
|
|
250 |
using_options(shortnames=True)
|
|
|
251 |
using_table_options(mysql_engine="InnoDB")
|
|
|
252 |
|
| 3187 |
rajveer |
253 |
def initialize(dbname='user', db_hostname="localhost"):
|
| 772 |
rajveer |
254 |
#metadata.bind = "sqlite:///user.sqlite" #need to read it from configserver.
|
| 5283 |
mandeep.dh |
255 |
engine = create_engine('mysql://root:shop2020@' + db_hostname + '/' + dbname, pool_recycle=7200, max_overflow=20)
|
| 1122 |
chandransh |
256 |
metadata.bind = engine
|
| 772 |
rajveer |
257 |
metadata.bind.echo = True
|
|
|
258 |
setup_all(True)
|
|
|
259 |
|
|
|
260 |
if __name__=="__main__":
|
|
|
261 |
initialize()
|