Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
94 ashish 1
'''
2
Created on 22-Mar-2010
3
 
4
@author: ashish
5
'''
4873 mandeep.dh 6
from elixir import metadata, setup_all
94 ashish 7
from elixir.entity import Entity
8
from elixir.fields import Field
4873 mandeep.dh 9
from elixir.options import using_options, using_table_options
5318 rajveer 10
from elixir.relationships import OneToMany, ManyToOne
4873 mandeep.dh 11
from sqlalchemy import create_engine
6903 anupam.sin 12
from sqlalchemy.types import Integer, String, DateTime, Float, Boolean, Text, Enum, BigInteger
4873 mandeep.dh 13
import datetime
14
import elixir
94 ashish 15
 
626 chandransh 16
class EntityIDGenerator(Entity):
17
    id=Field(Integer, primary_key=True)
18
    using_options(shortnames=True)
746 rajveer 19
    using_table_options(mysql_engine="InnoDB")
122 ashish 20
 
94 ashish 21
class Item(Entity):
122 ashish 22
    id = Field(Integer, primary_key=True, autoincrement=True)
963 chandransh 23
    product_group = Field(String(100))
4917 phani.kuma 24
    brand = Field(String(100), default='', server_default='')
25
    model_number = Field(String(50), default='', server_default='')
26
    model_name = Field(String(100), default='', server_default='')
27
    color = Field(String(20), default='', server_default='')
28
    category = Field(Integer, default=0, server_default="0")
483 rajveer 29
    comments = Field(String(200))
122 ashish 30
    catalog_item_id = Field(Integer)
31
    feature_id = Field(Integer)
32
    feature_description = Field(String(200))
483 rajveer 33
    mrp = Field(Float)
34
    sellingPrice = Field(Float)
35
    weight = Field(Float)
122 ashish 36
    addedOn = Field(DateTime)
609 chandransh 37
    updatedOn = Field(DateTime)
122 ashish 38
    startDate = Field(DateTime)
39
    retireDate = Field(DateTime)
5217 amit.gupta 40
    comingSoonStartDate = Field(DateTime)
41
    expectedArrivalDate = Field(DateTime)
483 rajveer 42
    status = Field(Integer)
2035 rajveer 43
    status_description = Field(String(100))
609 chandransh 44
    bestDealText = Field(String(100))
6777 vikram.rag 45
    bestDealsDetailsText = Field(String(1000))
46
    bestDealsDetailsLink = Field(String(200))
630 chandransh 47
    bestDealValue = Field(Float)
621 chandransh 48
    bestSellingRank = Field(Integer)
103 ashish 49
    statusChangeLog = OneToMany("ItemChangeLog")
1910 varun.gupt 50
    defaultForEntity = Field(Boolean)
2251 ankur.sing 51
    risky = Field(Boolean)
3355 chandransh 52
    expectedDelay = Field(Integer)
4295 varun.gupt 53
    warranty_period = Field(Integer)
4406 anupam.sin 54
    isWarehousePreferenceSticky = Field(Boolean)
4506 phani.kuma 55
    preferredVendor = Field(Integer)
5135 mandeep.dh 56
    type = Field(Enum('SERIALIZED', 'NON_SERIALIZED'), default = 'NON_SERIALIZED', server_default='NON_SERIALIZED')
5385 phani.kuma 57
    hasItemNo = Field(Boolean)
7256 rajveer 58
    activeOnStore = Field(Boolean)
6039 amit.gupta 59
    vatPercentage = Field(Float)
6241 amit.gupta 60
    showSellingPrice = Field(Boolean)
6805 anupam.sin 61
    preferredInsurer = Field(Integer)
746 rajveer 62
    using_options(shortnames=True)
63
    using_table_options(mysql_engine="InnoDB")
103 ashish 64
 
94 ashish 65
    def __repr__(self):
122 ashish 66
        return "<Item>%d</item>" % (self.id)
1308 chandransh 67
 
103 ashish 68
class ItemChangeLog(Entity):
122 ashish 69
    id = Field(Integer, primary_key=True, autoincrement=True)
103 ashish 70
    old_status = Field(Integer)
71
    new_status = Field(Integer)
1308 chandransh 72
    timestamp = Field(DateTime)
103 ashish 73
    item = ManyToOne("Item")
746 rajveer 74
    using_options(shortnames=True)
75
    using_table_options(mysql_engine="InnoDB")
94 ashish 76
 
103 ashish 77
    def __repr__(self):
78
        return "<Log><id>%d</id><item>%d</item><old_status>%d</old_status><new_status>%d</new_status></Log>" %(self.id,self.item.id, self.old_status, self.new_status)    
94 ashish 79
 
635 rajveer 80
class Category(Entity):
1970 rajveer 81
    id = Field(Integer, primary_key=True, autoincrement=False)
82
    label = Field(String(50))
83
    description = Field(String(200))
84
    parent_category_id = Field(Integer)
4762 phani.kuma 85
    display_name = Field(String(50))
746 rajveer 86
    using_options(shortnames=True)
87
    using_table_options(mysql_engine="InnoDB")
1970 rajveer 88
 
3008 rajveer 89
class SimilarItems(Entity):
90
    item = ManyToOne('Item', primary_key=True)
91
    catalog_item_id = Field(Integer, primary_key=True, autoincrement=False)
92
    using_options(shortnames=True)
93
    using_table_options(mysql_engine="InnoDB")
94
 
3079 rajveer 95
class ProductNotification(Entity):
96
    item = ManyToOne('Item', primary_key=True)
97
    email = Field(String(100), primary_key=True, autoincrement=False)
98
    addedOn = Field(DateTime, primary_key=True, autoincrement=False) 
99
    using_options(shortnames=True)
100
    using_table_options(mysql_engine="InnoDB")
3557 rajveer 101
 
102
class Source(Entity):
103
    id = Field(Integer, primary_key=True, autoincrement=True)
104
    name = Field(String(50))
105
    identifier = Field(String(100))
106
    using_options(shortnames=True)
107
    using_table_options(mysql_engine="InnoDB")
6511 kshitij.so 108
 
3557 rajveer 109
class SourceItemPricing(Entity):
110
    source = ManyToOne('Source', primary_key=True)
111
    item = ManyToOne('Item', primary_key=True)
112
    mrp = Field(Float)
113
    sellingPrice = Field(Float)
114
    using_options(shortnames=True)
115
    using_table_options(mysql_engine="InnoDB")
746 rajveer 116
 
4649 phani.kuma 117
class AuthorizationLog(Entity):
118
    id = Field(Integer, primary_key=True, autoincrement = True)    
119
    timestamp = Field(DateTime, default=datetime.datetime.now())
120
    item = ManyToOne('Item')
121
    username = Field(String(30))
122
    reason = Field(Text)
123
    using_options(shortnames=True)
124
    using_table_options(mysql_engine="InnoDB")
125
 
5504 phani.kuma 126
class VoucherItemMapping(Entity):
5512 rajveer 127
    voucherType = Field(Integer, primary_key=True)
5504 phani.kuma 128
    item = ManyToOne('Item', primary_key=True)
129
    amount = Field(Integer, default=0, server_default="0")
130
    using_options(shortnames=True)
131
    using_table_options(mysql_engine="InnoDB")
132
 
6039 amit.gupta 133
class CategoryVatMaster(Entity):
134
    categoryId = Field(Integer, primary_key=True)
135
    minVal = Field(Integer, primary_key=True)
136
    maxVal = Field(Integer, primary_key=True)
137
    vatPercent = Field(Float)
138
    using_options(shortnames=True)
139
    using_table_options(mysql_engine="InnoDB")
140
 
6255 rajveer 141
class OOSTracker(Entity):
142
    itemId = Field(Integer, primary_key=True)
143
    using_options(shortnames=True)
144
    using_table_options(mysql_engine="InnoDB")
6532 amit.gupta 145
 
146
class EntityTag(Entity):
147
    tag = Field(String(100),primary_key=True)
148
    entityId = Field(Integer, primary_key=True, autoincrement=False)
149
    using_options(shortnames=True)
150
    using_table_options(mysql_engine="InnoDB")
6848 kshitij.so 151
 
152
class Banner(Entity):
153
    bannerName = Field(String(100),primary_key=True)
154
    imageName = Field(String(100))
155
    link = Field(String(400))
156
    priority = Field(Integer)
157
    isActive = Field(Boolean)
158
    hasMap = Field(Boolean)
159
    using_options(shortnames=True)
160
    using_table_options(mysql_engine="InnoDB")
161
 
162
class BannerMap(Entity):
163
    bannerName = Field(String(100))
164
    mapLink = Field(String(400))
165
    coordinates = Field(String(20))
166
    using_options(shortnames=True)
167
    using_table_options(mysql_engine="InnoDB")
6255 rajveer 168
 
6805 anupam.sin 169
class ItemInsurerMapping(Entity):
170
    id = Field(Integer, primary_key=True, autoincrement=True)
171
    itemId = Field(Integer)
172
    insurerId = Field(Integer)
173
    premiumType = Field(Integer)
174
    premiumAmount = Field(Float)
175
    using_options(shortnames=True)
176
    using_table_options(mysql_engine="InnoDB")
177
 
178
class Insurer(Entity):
179
    id = Field(Integer, primary_key=True, autoincrement=True)
180
    name = Field(String(255))
181
    address = Field(String(255))
6903 anupam.sin 182
    declaredAmount = Field(BigInteger)
183
    creditedAmount = Field(BigInteger)
6805 anupam.sin 184
    using_options(shortnames=True)
185
    using_table_options(mysql_engine="InnoDB")
7190 amar.kumar 186
 
187
class FreebieItem(Entity):
188
    itemId = Field(Integer, primary_key=True)
189
    freebieItemId = Field(Integer)
190
    using_options(shortnames=True)
191
    using_table_options(mysql_engine="InnoDB")
7256 rajveer 192
 
193
class StorePricing(Entity):
194
    item = ManyToOne('Item', primary_key=True)
195
    recommendedPrice = Field(Float)
196
    minPrice = Field(Float)
197
    maxPrice = Field(Float)
198
    minAdvancePrice = Field(Float)
199
    using_options(shortnames=True)
200
    using_table_options(mysql_engine="InnoDB")
6805 anupam.sin 201
 
3187 rajveer 202
def initialize(dbname='catalog', db_hostname="localhost"):
746 rajveer 203
    #metadata.bind = "sqlite:///inventory-new.sqlite" #need to read it from configserver.
1122 chandransh 204
    #metadata.bind = 'mysql://root:shop2020@localhost/catalog'
6532 amit.gupta 205
    cengine = create_engine('mysql://root:shop2020@' + db_hostname + '/' + dbname, pool_recycle=7200)
206
    metadata.bind = cengine
94 ashish 207
    metadata.bind.echo = True
208
    setup_all(True)
115 ashish 209
 
210
if __name__=="__main__":
211
    initialize()