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