| 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
|
|
|
10 |
from sqlalchemy.types import Integer
|
|
|
11 |
from elixir.relationships import OneToMany, ManyToOne
|
|
|
12 |
import datetime
|
| 746 |
rajveer |
13 |
import elixir
|
| 130 |
ashish |
14 |
|
|
|
15 |
class SocialService(Entity):
|
|
|
16 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
17 |
name = Field(String(100))
|
|
|
18 |
handles = OneToMany("SocialHandle")
|
| 557 |
chandransh |
19 |
using_options(shortnames=True)
|
| 746 |
rajveer |
20 |
using_table_options(mysql_engine="InnoDB")
|
|
|
21 |
|
| 130 |
ashish |
22 |
class SocialHandle(Entity):
|
|
|
23 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
24 |
handle = Field(String(100))
|
|
|
25 |
service = ManyToOne("SocialService")
|
| 557 |
chandransh |
26 |
user = ManyToOne("User")
|
|
|
27 |
using_options(shortnames=True)
|
| 746 |
rajveer |
28 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
29 |
|
| 130 |
ashish |
30 |
class Address(Entity):
|
|
|
31 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
32 |
line_1 = Field(String(100))
|
|
|
33 |
line_2 = Field(String(100))
|
|
|
34 |
landmark = Field(String(100))
|
|
|
35 |
city = Field(String(100))
|
|
|
36 |
state = Field(String(100))
|
|
|
37 |
pin = Field(String(10))
|
|
|
38 |
country = Field(String(100))
|
|
|
39 |
enabled = Field(Boolean)
|
|
|
40 |
type = Field(Integer)
|
|
|
41 |
added_on = Field(DateTime)
|
| 414 |
ashish |
42 |
name = Field(String(100))
|
|
|
43 |
phone = Field(String(20))
|
| 557 |
chandransh |
44 |
user = ManyToOne("User")
|
|
|
45 |
using_options(shortnames=True)
|
| 746 |
rajveer |
46 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
47 |
|
| 130 |
ashish |
48 |
class Phone(Entity):
|
|
|
49 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
50 |
country_code = Field(String(5))
|
|
|
51 |
area_code = Field(String(10))
|
|
|
52 |
number = Field(String(20))
|
|
|
53 |
extension = Field(String(10))
|
|
|
54 |
type = Field(Integer)
|
| 557 |
chandransh |
55 |
user = ManyToOne("User")
|
|
|
56 |
using_options(shortnames=True)
|
| 746 |
rajveer |
57 |
using_table_options(mysql_engine="InnoDB")
|
| 130 |
ashish |
58 |
|
| 557 |
chandransh |
59 |
class InternalInfo(Entity):
|
| 130 |
ashish |
60 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 557 |
chandransh |
61 |
geo_zone = Field(Integer)
|
|
|
62 |
shipment_zone = Field(Integer)
|
|
|
63 |
tax_zone = Field(Integer)
|
|
|
64 |
rank_score = Field(Float)
|
|
|
65 |
user = ManyToOne("User")
|
|
|
66 |
using_options(shortnames=True)
|
| 746 |
rajveer |
67 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
68 |
|
| 130 |
ashish |
69 |
class IPMap(Entity):
|
|
|
70 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
71 |
timestamp = Field(DateTime)
|
|
|
72 |
ip = Field(String(30))
|
| 557 |
chandransh |
73 |
user_state = ManyToOne("UserState")
|
|
|
74 |
using_options(shortnames=True)
|
| 746 |
rajveer |
75 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
76 |
|
|
|
77 |
class UserState(Entity):
|
| 130 |
ashish |
78 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 557 |
chandransh |
79 |
last_login = Field(DateTime)
|
|
|
80 |
last_logout = Field(DateTime)
|
|
|
81 |
email_verification_sent_on = Field(DateTime)
|
|
|
82 |
sms_verification_sent_on = Field(DateTime)
|
|
|
83 |
is_email_verified = Field(Boolean)
|
|
|
84 |
is_sms_verified =Field(Boolean)
|
|
|
85 |
active_since = Field(DateTime)
|
|
|
86 |
account_status = Field(Integer)
|
|
|
87 |
ip_list = OneToMany("IPMap")
|
|
|
88 |
user = ManyToOne("User")
|
|
|
89 |
using_options(shortnames=True)
|
| 746 |
rajveer |
90 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
91 |
|
|
|
92 |
class User(Entity):
|
|
|
93 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 130 |
ashish |
94 |
email = Field(String(100))
|
|
|
95 |
password = Field(String(50))
|
| 557 |
chandransh |
96 |
name = Field(String(150))
|
| 504 |
rajveer |
97 |
default_address_id = Field(Integer)
|
|
|
98 |
communication_email = Field(String(100))
|
| 557 |
chandransh |
99 |
active_cart_id = Field(Integer)
|
|
|
100 |
jsession_id = Field(String(64))
|
|
|
101 |
is_anonymous = Field(Boolean)
|
| 567 |
rajveer |
102 |
date_of_birth = Field(String(20))
|
| 557 |
chandransh |
103 |
sex = Field(Integer)
|
| 567 |
rajveer |
104 |
mobile_number = Field(String(20))
|
| 130 |
ashish |
105 |
addresses = OneToMany("Address")
|
|
|
106 |
social_handles = OneToMany("SocialHandle")
|
| 557 |
chandransh |
107 |
using_options(shortnames=True)
|
| 746 |
rajveer |
108 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
109 |
|
|
|
110 |
class Line(Entity):
|
| 643 |
chandransh |
111 |
cart = ManyToOne("Cart", primary_key=True)
|
| 746 |
rajveer |
112 |
item_id = Field(Integer, primary_key=True, autoincrement=False)
|
| 557 |
chandransh |
113 |
quantity = Field(Float)
|
|
|
114 |
line_status = Field(Integer)
|
| 612 |
chandransh |
115 |
estimate = Field(Integer)
|
| 557 |
chandransh |
116 |
created_on = Field(DateTime)
|
|
|
117 |
updated_on = Field(DateTime)
|
|
|
118 |
using_options(shortnames=True)
|
| 746 |
rajveer |
119 |
using_table_options(mysql_engine="InnoDB")
|
| 504 |
rajveer |
120 |
|
| 557 |
chandransh |
121 |
class Cart(Entity):
|
| 130 |
ashish |
122 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 557 |
chandransh |
123 |
user_id = Field(Integer)
|
|
|
124 |
cart_status = Field(Integer)
|
|
|
125 |
address_id = Field(Integer)
|
| 690 |
chandransh |
126 |
checked_out_on = Field(DateTime)
|
| 557 |
chandransh |
127 |
created_on = Field(DateTime)
|
|
|
128 |
updated_on = Field(DateTime)
|
| 564 |
chandransh |
129 |
lines = OneToMany("Line")
|
| 557 |
chandransh |
130 |
using_options(shortnames=True)
|
| 746 |
rajveer |
131 |
using_table_options(mysql_engine="InnoDB")
|
| 130 |
ashish |
132 |
|
| 557 |
chandransh |
133 |
#===============================================================================
|
|
|
134 |
# Different entities for the Widget service
|
|
|
135 |
#===============================================================================
|
|
|
136 |
|
|
|
137 |
class Widget(Entity):
|
| 130 |
ashish |
138 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 557 |
chandransh |
139 |
type = Field(Integer)
|
|
|
140 |
customer_id = Field(Integer)
|
|
|
141 |
name = Field(String(100))
|
|
|
142 |
enabled = Field(Integer)
|
|
|
143 |
session_id = Field(Integer)
|
|
|
144 |
items = OneToMany("WidgetItem")
|
|
|
145 |
using_options(shortnames=True)
|
| 746 |
rajveer |
146 |
using_table_options(mysql_engine="InnoDB")
|
| 130 |
ashish |
147 |
|
| 557 |
chandransh |
148 |
class WidgetItem(Entity):
|
| 130 |
ashish |
149 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 557 |
chandransh |
150 |
added_on = Field(DateTime)
|
|
|
151 |
item = ManyToOne("Item")
|
|
|
152 |
widget = ManyToOne("Widget")
|
|
|
153 |
using_options(shortnames=True)
|
| 746 |
rajveer |
154 |
using_table_options(mysql_engine="InnoDB")
|
| 130 |
ashish |
155 |
|
| 557 |
chandransh |
156 |
class Item(Entity):
|
|
|
157 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
158 |
item_id = Field(Integer)
|
|
|
159 |
snippet = Field(Integer)
|
|
|
160 |
enabled = Field(Integer)
|
|
|
161 |
widget_items=OneToMany("WidgetItem")
|
|
|
162 |
using_options(shortnames=True)
|
| 746 |
rajveer |
163 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
164 |
|
|
|
165 |
class Ratings(Entity):
|
|
|
166 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
167 |
item_id = Field(Integer)
|
|
|
168 |
type = Field(Integer)
|
|
|
169 |
rating = Field(Float)
|
|
|
170 |
using_options(shortnames=True)
|
| 746 |
rajveer |
171 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
172 |
|
|
|
173 |
class UserRatings(Entity):
|
|
|
174 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
175 |
item_id = Field(Integer)
|
|
|
176 |
rating = Field(Float)
|
|
|
177 |
user_id = Field(Integer)
|
|
|
178 |
using_options(shortnames=True)
|
| 746 |
rajveer |
179 |
using_table_options(mysql_engine="InnoDB")
|
| 557 |
chandransh |
180 |
|
| 130 |
ashish |
181 |
def initialize():
|
| 746 |
rajveer |
182 |
#metadata.bind = "sqlite:///user.sqlite" #need to read it from configserver.
|
|
|
183 |
metadata.bind = 'mysql://root:shop2020@localhost/user'
|
| 130 |
ashish |
184 |
metadata.bind.echo = True
|
|
|
185 |
setup_all(True)
|
|
|
186 |
|
|
|
187 |
if __name__=="__main__":
|
| 746 |
rajveer |
188 |
initialize()
|
|
|
189 |
|