| 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))
|
| 130 |
ashish |
107 |
addresses = OneToMany("Address")
|
|
|
108 |
social_handles = OneToMany("SocialHandle")
|
| 557 |
chandransh |
109 |
using_options(shortnames=True)
|
| 746 |
rajveer |
110 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
111 |
|
|
|
112 |
class Line(Entity):
|
| 643 |
chandransh |
113 |
cart = ManyToOne("Cart", primary_key=True)
|
| 746 |
rajveer |
114 |
item_id = Field(Integer, primary_key=True, autoincrement=False)
|
| 557 |
chandransh |
115 |
quantity = Field(Float)
|
|
|
116 |
line_status = Field(Integer)
|
| 612 |
chandransh |
117 |
estimate = Field(Integer)
|
| 557 |
chandransh |
118 |
created_on = Field(DateTime)
|
|
|
119 |
updated_on = Field(DateTime)
|
| 1976 |
varun.gupt |
120 |
actual_price = Field(Float)
|
|
|
121 |
discounted_price = Field(Float)
|
| 557 |
chandransh |
122 |
using_options(shortnames=True)
|
| 746 |
rajveer |
123 |
using_table_options(mysql_engine="InnoDB")
|
| 504 |
rajveer |
124 |
|
| 557 |
chandransh |
125 |
class Cart(Entity):
|
| 130 |
ashish |
126 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 557 |
chandransh |
127 |
user_id = Field(Integer)
|
|
|
128 |
cart_status = Field(Integer)
|
|
|
129 |
address_id = Field(Integer)
|
| 690 |
chandransh |
130 |
checked_out_on = Field(DateTime)
|
| 557 |
chandransh |
131 |
created_on = Field(DateTime)
|
|
|
132 |
updated_on = Field(DateTime)
|
| 564 |
chandransh |
133 |
lines = OneToMany("Line")
|
| 1976 |
varun.gupt |
134 |
total_price = Field(Float)
|
|
|
135 |
discounted_price = Field(Float)
|
|
|
136 |
coupon_code = Field(String(20))
|
| 557 |
chandransh |
137 |
using_options(shortnames=True)
|
| 746 |
rajveer |
138 |
using_table_options(mysql_engine="InnoDB")
|
| 130 |
ashish |
139 |
|
| 557 |
chandransh |
140 |
#===============================================================================
|
| 1976 |
varun.gupt |
141 |
# Entity generated from Promotion Service
|
|
|
142 |
#===============================================================================
|
|
|
143 |
class Promotion(Entity):
|
|
|
144 |
id = Field(Integer, primary_key = True, autoincrement = True)
|
|
|
145 |
name = Field(String(200))
|
|
|
146 |
rule_execution_src = Field(String(100))
|
|
|
147 |
start_on = Field(DateTime)
|
|
|
148 |
end_on = Field(DateTime)
|
|
|
149 |
coupons = OneToMany("Coupon")
|
|
|
150 |
created_on = Field(DateTime)
|
|
|
151 |
using_options(shortnames = True)
|
|
|
152 |
using_table_options(mysql_engine = "InnoDB")
|
|
|
153 |
|
|
|
154 |
class Coupon(Entity):
|
|
|
155 |
coupon_code = Field(String(20))
|
|
|
156 |
promotion = ManyToOne("Promotion")
|
|
|
157 |
arguments = Field(String(200))
|
|
|
158 |
using_options(shortnames = True)
|
|
|
159 |
using_table_options(mysql_engine = "InnoDB")
|
|
|
160 |
|
|
|
161 |
class PromotionTracker(Entity):
|
|
|
162 |
coupon_code = Field(String(20))
|
|
|
163 |
transaction_id = Field(Integer)
|
|
|
164 |
user_id = Field(Integer)
|
|
|
165 |
applied_on = Field(DateTime)
|
|
|
166 |
using_options(shortnames = True)
|
|
|
167 |
using_table_options(mysql_engine = "InnoDB")
|
|
|
168 |
|
|
|
169 |
#===============================================================================
|
| 1273 |
varun.gupt |
170 |
# Entity generated from Contact Us form
|
|
|
171 |
#===============================================================================
|
|
|
172 |
class UserCommunication(Entity):
|
|
|
173 |
id = Field(Integer, primary_key = True, autoincrement = True)
|
|
|
174 |
user_id = Field(Integer)
|
|
|
175 |
communication_type = Field(Integer)
|
|
|
176 |
order_id = Field(Integer)
|
|
|
177 |
airwaybill_no = Field(String(50))
|
|
|
178 |
reply_to = Field(String(50))
|
|
|
179 |
product_name = Field(String(200))
|
|
|
180 |
subject = Field(String(200))
|
|
|
181 |
message = Field(String(600))
|
| 1301 |
varun.gupt |
182 |
communication_timestamp = Field(DateTime)
|
| 1273 |
varun.gupt |
183 |
using_options(shortnames = True)
|
|
|
184 |
using_table_options(mysql_engine = "InnoDB")
|
|
|
185 |
|
|
|
186 |
#===============================================================================
|
| 557 |
chandransh |
187 |
# Different entities for the Widget service
|
|
|
188 |
#===============================================================================
|
|
|
189 |
|
|
|
190 |
class Widget(Entity):
|
| 130 |
ashish |
191 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 557 |
chandransh |
192 |
type = Field(Integer)
|
| 772 |
rajveer |
193 |
user_id = Field(Integer)
|
| 557 |
chandransh |
194 |
name = Field(String(100))
|
| 772 |
rajveer |
195 |
enabled = Field(Boolean)
|
| 557 |
chandransh |
196 |
items = OneToMany("WidgetItem")
|
|
|
197 |
using_options(shortnames=True)
|
| 746 |
rajveer |
198 |
using_table_options(mysql_engine="InnoDB")
|
| 130 |
ashish |
199 |
|
| 557 |
chandransh |
200 |
class WidgetItem(Entity):
|
| 130 |
ashish |
201 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 557 |
chandransh |
202 |
added_on = Field(DateTime)
|
|
|
203 |
item = ManyToOne("Item")
|
|
|
204 |
widget = ManyToOne("Widget")
|
|
|
205 |
using_options(shortnames=True)
|
| 746 |
rajveer |
206 |
using_table_options(mysql_engine="InnoDB")
|
| 130 |
ashish |
207 |
|
| 557 |
chandransh |
208 |
class Item(Entity):
|
|
|
209 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
210 |
item_id = Field(Integer)
|
| 772 |
rajveer |
211 |
enabled = Field(Boolean)
|
| 557 |
chandransh |
212 |
widget_items=OneToMany("WidgetItem")
|
|
|
213 |
using_options(shortnames=True)
|
| 746 |
rajveer |
214 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
215 |
|
| 1845 |
vikas |
216 |
class MasterAffiliate(Entity):
|
|
|
217 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
218 |
name = Field(String(100), unique=True)
|
| 1859 |
vikas |
219 |
added_on = Field(DateTime)
|
| 1845 |
vikas |
220 |
affiliates = OneToMany("Affiliate")
|
|
|
221 |
using_options(shortnames=True)
|
|
|
222 |
using_table_options(mysql_engine="InnoDB")
|
|
|
223 |
|
|
|
224 |
class Affiliate(Entity):
|
|
|
225 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
226 |
master_affiliate = ManyToOne("MasterAffiliate")
|
|
|
227 |
name = Field(String(100), unique=True)
|
|
|
228 |
url = Field(String(200))
|
| 1859 |
vikas |
229 |
added_on = Field(DateTime)
|
| 1996 |
vikas |
230 |
tracklogs = OneToMany("TrackLog")
|
| 1845 |
vikas |
231 |
using_options(shortnames=True)
|
|
|
232 |
using_table_options(mysql_engine="InnoDB")
|
|
|
233 |
|
|
|
234 |
class Tracker(Entity):
|
|
|
235 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 2004 |
vikas |
236 |
affiliate_id = Field(Integer)
|
|
|
237 |
added_on = Field(DateTime)
|
| 1845 |
vikas |
238 |
using_options(shortnames=True)
|
|
|
239 |
using_table_options(mysql_engine="InnoDB")
|
|
|
240 |
|
|
|
241 |
class TrackLog(Entity):
|
|
|
242 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 1859 |
vikas |
243 |
added_on = Field(DateTime)
|
| 1996 |
vikas |
244 |
affiliate = ManyToOne("Affiliate")
|
| 1845 |
vikas |
245 |
user_id = Field(Integer)
|
|
|
246 |
event = Field(String(100))
|
|
|
247 |
url = Field(String(200))
|
|
|
248 |
data = Field(String(200))
|
|
|
249 |
using_options(shortnames=True)
|
|
|
250 |
using_table_options(mysql_engine="InnoDB")
|
|
|
251 |
|
| 2641 |
varun.gupt |
252 |
class UserNote(Entity):
|
|
|
253 |
user_id = Field(Integer)
|
|
|
254 |
entity_id = Field(Integer)
|
| 2717 |
varun.gupt |
255 |
slide = Field(String(30))
|
| 2641 |
varun.gupt |
256 |
note = Field(String(500))
|
|
|
257 |
using_options(shortnames=True)
|
|
|
258 |
using_table_options(mysql_engine="InnoDB")
|
|
|
259 |
|
| 1249 |
chandransh |
260 |
def initialize(dbname='user'):
|
| 772 |
rajveer |
261 |
#metadata.bind = "sqlite:///user.sqlite" #need to read it from configserver.
|
| 1249 |
chandransh |
262 |
engine = create_engine('mysql://root:shop2020@localhost/' + dbname, pool_recycle=7200)
|
| 1122 |
chandransh |
263 |
metadata.bind = engine
|
| 772 |
rajveer |
264 |
metadata.bind.echo = True
|
|
|
265 |
setup_all(True)
|
|
|
266 |
|
|
|
267 |
if __name__=="__main__":
|
|
|
268 |
initialize()
|
|
|
269 |
|
|
|
270 |
|
|
|
271 |
'''
|
| 557 |
chandransh |
272 |
class Ratings(Entity):
|
|
|
273 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
274 |
item_id = Field(Integer)
|
|
|
275 |
type = Field(Integer)
|
|
|
276 |
rating = Field(Float)
|
|
|
277 |
using_options(shortnames=True)
|
| 746 |
rajveer |
278 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
279 |
|
|
|
280 |
class UserRatings(Entity):
|
|
|
281 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
282 |
item_id = Field(Integer)
|
|
|
283 |
rating = Field(Float)
|
|
|
284 |
user_id = Field(Integer)
|
|
|
285 |
using_options(shortnames=True)
|
| 746 |
rajveer |
286 |
using_table_options(mysql_engine="InnoDB")
|
| 772 |
rajveer |
287 |
'''
|