Subversion Repositories SmartDukaan

Rev

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