Subversion Repositories SmartDukaan

Rev

Rev 7039 | Rev 7883 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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 Address(Entity):
17
    id = Field(Integer, primary_key=True, autoincrement=True)
18
    line_1 = Field(String(100))
19
    line_2 = Field(String(100))
20
    landmark = Field(String(100))
21
    city = Field(String(100))
22
    state = Field(String(100))
23
    pin = Field(String(10))
24
    country = Field(String(100))
25
    enabled = Field(Boolean)
26
    type = Field(Integer)
27
    added_on = Field(DateTime)
414 ashish 28
    name = Field(String(100))
29
    phone = Field(String(20))
557 chandransh 30
    user = ManyToOne("User")
31
    using_options(shortnames=True)
746 rajveer 32
    using_table_options(mysql_engine="InnoDB")
557 chandransh 33
 
34
class User(Entity):
35
    id = Field(Integer, primary_key=True, autoincrement=True)
130 ashish 36
    email = Field(String(100))
37
    password = Field(String(50))
557 chandransh 38
    name = Field(String(150))
504 rajveer 39
    default_address_id = Field(Integer)
40
    communication_email = Field(String(100))
5326 rajveer 41
    active_cart = ManyToOne("Cart")
557 chandransh 42
    jsession_id = Field(String(64))
43
    is_anonymous = Field(Boolean)
567 rajveer 44
    date_of_birth = Field(String(20))
557 chandransh 45
    sex = Field(Integer)
567 rajveer 46
    mobile_number = Field(String(20))
2020 vikas 47
    source = Field(String(200))
2815 vikas 48
    source_start_time = Field(DateTime)
3499 mandeep.dh 49
    trust_level = Field(Float)
5326 rajveer 50
    last_login = Field(DateTime)
51
    last_logout = Field(DateTime)
52
    active_since = Field(DateTime)
7825 amar.kumar 53
    is_facebook_user = Field(Boolean)
54
    facebook_access_token = Field(String(200))
55
    facebook_id = Field(String(50))
130 ashish 56
    addresses = OneToMany("Address")
557 chandransh 57
    using_options(shortnames=True)
746 rajveer 58
    using_table_options(mysql_engine="InnoDB")
557 chandransh 59
 
60
class Line(Entity):
643 chandransh 61
    cart = ManyToOne("Cart", primary_key=True)
746 rajveer 62
    item_id = Field(Integer, primary_key=True, autoincrement=False)
557 chandransh 63
    quantity = Field(Float)
64
    line_status = Field(Integer)
612 chandransh 65
    estimate = Field(Integer)
557 chandransh 66
    created_on = Field(DateTime)
67
    updated_on = Field(DateTime)
1976 varun.gupt 68
    actual_price = Field(Float)
69
    discounted_price = Field(Float)
3554 varun.gupt 70
    discounts = OneToMany('Discount')
6903 anupam.sin 71
    insurer = Field(Integer)
72
    insuranceAmount = Field(Float)
557 chandransh 73
    using_options(shortnames=True)
746 rajveer 74
    using_table_options(mysql_engine="InnoDB")
504 rajveer 75
 
557 chandransh 76
class Cart(Entity):
130 ashish 77
    id = Field(Integer, primary_key=True, autoincrement=True)
557 chandransh 78
    cart_status = Field(Integer)
79
    address_id = Field(Integer)
5555 rajveer 80
    pickupStoreId = Field(Integer)
690 chandransh 81
    checked_out_on = Field(DateTime)
557 chandransh 82
    created_on = Field(DateTime)
83
    updated_on = Field(DateTime)
564 chandransh 84
    lines = OneToMany("Line")
1976 varun.gupt 85
    total_price = Field(Float)
86
    discounted_price = Field(Float)
87
    coupon_code = Field(String(20))
5326 rajveer 88
    user = OneToMany("User")
557 chandransh 89
    using_options(shortnames=True)
746 rajveer 90
    using_table_options(mysql_engine="InnoDB")
130 ashish 91
 
3554 varun.gupt 92
class Discount(Entity):
93
    line = ManyToOne("Line", primary_key=True)
94
    discount = Field(Float, primary_key = True)
95
    quantity = Field(Float)
96
    using_options(shortnames = True)
97
    using_table_options(mysql_engine = 'InnoDB')
98
 
557 chandransh 99
#===============================================================================
1976 varun.gupt 100
# Entity generated from Promotion Service
101
#===============================================================================
102
class Promotion(Entity):
103
    id = Field(Integer, primary_key = True, autoincrement = True)
104
    name = Field(String(200))
105
    rule_execution_src = Field(String(100))
106
    start_on = Field(DateTime)
107
    end_on = Field(DateTime)
108
    coupons = OneToMany("Coupon")
109
    created_on = Field(DateTime)
6367 amit.gupta 110
    type = Field(Integer)
1976 varun.gupt 111
    using_options(shortnames = True)
112
    using_table_options(mysql_engine = "InnoDB")
113
 
114
class Coupon(Entity):
115
    coupon_code = Field(String(20))
116
    promotion = ManyToOne("Promotion")
117
    arguments = Field(String(200))
118
    using_options(shortnames = True)
119
    using_table_options(mysql_engine = "InnoDB")
120
 
121
class PromotionTracker(Entity):
122
    coupon_code = Field(String(20))
123
    transaction_id = Field(Integer)
124
    user_id = Field(Integer)
125
    applied_on = Field(DateTime)
126
    using_options(shortnames = True)
127
    using_table_options(mysql_engine = "InnoDB")
5469 rajveer 128
 
129
class RechargeVoucher(Entity):
130
    id = Field(Integer, primary_key = True, autoincrement = True)
131
    voucherCode = Field(String(30))
132
    voucherType = Field(Integer)
133
    amount = Field(Numeric(precision=8, scale=2, asdecimal=False))
134
    available = Field(Boolean)
135
    issuedOn = Field(DateTime)
136
    expiredOn = Field(DateTime)
137
    redeemed = Field(Boolean)
138
    redeemedOn = Field(DateTime)
139
    email = Field(String(100))
140
    userId = Field(Integer)
141
    using_options(shortnames = True)
142
    using_table_options(mysql_engine = "InnoDB")
1976 varun.gupt 143
 
144
#===============================================================================
1273 varun.gupt 145
# Entity generated from Contact Us form
146
#===============================================================================
147
class UserCommunication(Entity):
148
    id = Field(Integer, primary_key = True, autoincrement = True)
149
    user_id = Field(Integer)
150
    communication_type = Field(Integer)
151
    order_id = Field(Integer)
152
    airwaybill_no = Field(String(50))
153
    reply_to = Field(String(50))
154
    product_name = Field(String(200))
155
    subject = Field(String(200))
156
    message = Field(String(600))
1301 varun.gupt 157
    communication_timestamp = Field(DateTime)
1273 varun.gupt 158
    using_options(shortnames = True)
159
    using_table_options(mysql_engine = "InnoDB")
160
 
161
#===============================================================================
557 chandransh 162
# Different entities for the Widget service
163
#===============================================================================
164
 
2981 rajveer 165
class UserWidgetItem(Entity):
166
    userId = Field(Integer, primary_key=True)
167
    widgetId = Field(Integer, primary_key=True)
168
    itemId = Field(Integer, primary_key=True)
169
    addedOn = Field(DateTime)
557 chandransh 170
    using_options(shortnames=True)    
746 rajveer 171
    using_table_options(mysql_engine="InnoDB")
130 ashish 172
 
1845 vikas 173
class MasterAffiliate(Entity):
174
    id = Field(Integer, primary_key=True, autoincrement=True)
175
    name = Field(String(100), unique=True)
1859 vikas 176
    added_on = Field(DateTime)
1845 vikas 177
    affiliates = OneToMany("Affiliate")
178
    using_options(shortnames=True)
179
    using_table_options(mysql_engine="InnoDB")
180
 
181
class Affiliate(Entity):
182
    id = Field(Integer, primary_key=True, autoincrement=True)
183
    master_affiliate = ManyToOne("MasterAffiliate")
184
    name = Field(String(100), unique=True)
185
    url = Field(String(200))
1859 vikas 186
    added_on = Field(DateTime)
1996 vikas 187
    tracklogs = OneToMany("TrackLog")
1845 vikas 188
    using_options(shortnames=True)
189
    using_table_options(mysql_engine="InnoDB")
190
 
191
class Tracker(Entity):
192
    id = Field(Integer, primary_key=True, autoincrement=True)
2004 vikas 193
    affiliate_id = Field(Integer)
194
    added_on = Field(DateTime)
1845 vikas 195
    using_options(shortnames=True)
196
    using_table_options(mysql_engine="InnoDB")
197
 
198
class TrackLog(Entity):
199
    id = Field(Integer, primary_key=True, autoincrement=True)
1859 vikas 200
    added_on = Field(DateTime)
1996 vikas 201
    affiliate = ManyToOne("Affiliate")
1845 vikas 202
    user_id = Field(Integer)
203
    event = Field(String(100))
3378 vikas 204
    event_id = Field(Integer)
1845 vikas 205
    url = Field(String(200))
206
    data = Field(String(200))
207
    using_options(shortnames=True)
208
    using_table_options(mysql_engine="InnoDB")
209
 
6903 anupam.sin 210
class InsuranceDetails(Entity):
211
    id = Field(Integer, primary_key=True, autoincrement=True)
212
    addressId = Field(Integer)
213
    dob = Field(String(64))
214
    guardianName = Field(String(255))
215
    using_options(shortnames=True)
216
    using_table_options(mysql_engine="InnoDB")
217
 
3187 rajveer 218
def initialize(dbname='user', db_hostname="localhost"):
772 rajveer 219
    #metadata.bind = "sqlite:///user.sqlite" #need to read it from configserver.
5283 mandeep.dh 220
    engine = create_engine('mysql://root:shop2020@' + db_hostname + '/' + dbname, pool_recycle=7200, max_overflow=20)
1122 chandransh 221
    metadata.bind = engine
772 rajveer 222
    metadata.bind.echo = True
223
    setup_all(True)
224
 
225
if __name__=="__main__":
226
    initialize()