| 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")
|
|
|
18 |
|
|
|
19 |
class SocialHandle(Entity):
|
|
|
20 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
21 |
handle = Field(String(100))
|
|
|
22 |
service = ManyToOne("SocialService")
|
|
|
23 |
primary_info = ManyToOne("PrimaryInfo")
|
|
|
24 |
|
|
|
25 |
class Address(Entity):
|
|
|
26 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
27 |
line_1 = Field(String(100))
|
|
|
28 |
line_2 = Field(String(100))
|
|
|
29 |
landmark = Field(String(100))
|
|
|
30 |
city = Field(String(100))
|
|
|
31 |
state = Field(String(100))
|
|
|
32 |
pin = Field(String(10))
|
|
|
33 |
country = Field(String(100))
|
|
|
34 |
enabled = Field(Boolean)
|
|
|
35 |
type = Field(Integer)
|
|
|
36 |
added_on = Field(DateTime)
|
| 414 |
ashish |
37 |
name = Field(String(100))
|
|
|
38 |
phone = Field(String(20))
|
| 130 |
ashish |
39 |
primary_info = ManyToOne("PrimaryInfo")
|
|
|
40 |
|
|
|
41 |
class Phone(Entity):
|
|
|
42 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
43 |
country_code = Field(String(5))
|
|
|
44 |
area_code = Field(String(10))
|
|
|
45 |
number = Field(String(20))
|
|
|
46 |
extension = Field(String(10))
|
|
|
47 |
type = Field(Integer)
|
|
|
48 |
enabled = Field(Boolean)
|
|
|
49 |
primary_info = ManyToOne("PrimaryInfo")
|
|
|
50 |
|
|
|
51 |
class Date(Entity):
|
|
|
52 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
53 |
date = Field(Integer)
|
|
|
54 |
month = Field(Integer)
|
|
|
55 |
year = Field(Integer)
|
|
|
56 |
type = Field(Integer)
|
|
|
57 |
primary_info = ManyToOne("PrimaryInfo")
|
|
|
58 |
|
|
|
59 |
class IPMap(Entity):
|
|
|
60 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
61 |
timestamp = Field(DateTime)
|
|
|
62 |
ip = Field(String(30))
|
|
|
63 |
user_info = ManyToOne("State")
|
|
|
64 |
|
|
|
65 |
class PrimaryInfo(Entity):
|
|
|
66 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
67 |
title = Field(String(50))
|
|
|
68 |
first_name = Field(String(50))
|
|
|
69 |
middle_name = Field(String(50))
|
|
|
70 |
last_name = Field(String(50))
|
|
|
71 |
occupation = Field(String(50))
|
|
|
72 |
hint_question = Field(String(200))
|
|
|
73 |
hint_answer = Field(String(50))
|
|
|
74 |
picture_id = Field(String(100))
|
| 509 |
rajveer |
75 |
date_of_birth = Field(DateTime)
|
| 130 |
ashish |
76 |
email = Field(String(100))
|
|
|
77 |
user_handle = Field(String(100))
|
|
|
78 |
password = Field(String(50))
|
|
|
79 |
shipment_option = Field(Integer)
|
| 504 |
rajveer |
80 |
default_address_id = Field(Integer)
|
|
|
81 |
communication_email = Field(String(100))
|
| 130 |
ashish |
82 |
phones = OneToMany("Phone")
|
|
|
83 |
dates = OneToMany("Date")
|
|
|
84 |
addresses = OneToMany("Address")
|
|
|
85 |
social_handles = OneToMany("SocialHandle")
|
|
|
86 |
user = ManyToOne("User")
|
| 504 |
rajveer |
87 |
|
| 130 |
ashish |
88 |
class State(Entity):
|
|
|
89 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
90 |
is_enrolled = Field(Boolean)
|
|
|
91 |
is_email_verified = Field(Boolean)
|
|
|
92 |
is_sms_verified =Field(Boolean)
|
|
|
93 |
last_login_timestamp = Field(DateTime)
|
|
|
94 |
last_logout = Field(DateTime)
|
|
|
95 |
email_verification_sent_on = Field(DateTime)
|
|
|
96 |
sms_verification_sent_on = Field(DateTime)
|
|
|
97 |
active_since = Field(DateTime)
|
|
|
98 |
current_shopping_cart = Field(Integer)
|
|
|
99 |
is_logged_in = Field(Boolean)
|
|
|
100 |
account_status = Field(Integer)
|
|
|
101 |
ip_list = OneToMany("IPMap")
|
|
|
102 |
user = ManyToOne("User")
|
|
|
103 |
|
|
|
104 |
class InternalInfo(Entity):
|
|
|
105 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
106 |
geo_zone = Field(Integer)
|
|
|
107 |
shipment_zone = Field(Integer)
|
|
|
108 |
tax_zone = Field(Integer)
|
|
|
109 |
rank_score = Field(Float)
|
|
|
110 |
user = ManyToOne("User")
|
|
|
111 |
|
|
|
112 |
class User(Entity):
|
|
|
113 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 413 |
rajveer |
114 |
session_id = Field(Integer, autoincrement=True)
|
| 130 |
ashish |
115 |
primary_info = OneToOne("PrimaryInfo")
|
|
|
116 |
internal_info = OneToOne("InternalInfo")
|
|
|
117 |
state = OneToOne("State")
|
|
|
118 |
|
|
|
119 |
def initialize():
|
|
|
120 |
metadata.bind = "sqlite:///user.sqlite" #need to read it from configserver.
|
|
|
121 |
metadata.bind.echo = True
|
|
|
122 |
setup_all(True)
|
|
|
123 |
|
|
|
124 |
if __name__=="__main__":
|
|
|
125 |
initialize()
|