Subversion Repositories SmartDukaan

Rev

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