| 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
|
| 5318 |
rajveer |
12 |
from sqlalchemy.types import Integer, String, DateTime, Float, Boolean, Text, Enum
|
| 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))
|
| 630 |
chandransh |
45 |
bestDealValue = Field(Float)
|
| 621 |
chandransh |
46 |
bestSellingRank = Field(Integer)
|
| 103 |
ashish |
47 |
statusChangeLog = OneToMany("ItemChangeLog")
|
| 1910 |
varun.gupt |
48 |
defaultForEntity = Field(Boolean)
|
| 2251 |
ankur.sing |
49 |
risky = Field(Boolean)
|
| 3355 |
chandransh |
50 |
expectedDelay = Field(Integer)
|
| 4295 |
varun.gupt |
51 |
warranty_period = Field(Integer)
|
| 4406 |
anupam.sin |
52 |
isWarehousePreferenceSticky = Field(Boolean)
|
| 4506 |
phani.kuma |
53 |
preferredVendor = Field(Integer)
|
| 5135 |
mandeep.dh |
54 |
type = Field(Enum('SERIALIZED', 'NON_SERIALIZED'), default = 'NON_SERIALIZED', server_default='NON_SERIALIZED')
|
| 5385 |
phani.kuma |
55 |
hasItemNo = Field(Boolean)
|
| 5460 |
phani.kuma |
56 |
clearance = Field(Boolean)
|
| 6039 |
amit.gupta |
57 |
vatPercentage = Field(Float)
|
| 6241 |
amit.gupta |
58 |
showSellingPrice = Field(Boolean)
|
| 746 |
rajveer |
59 |
using_options(shortnames=True)
|
|
|
60 |
using_table_options(mysql_engine="InnoDB")
|
| 103 |
ashish |
61 |
|
| 94 |
ashish |
62 |
def __repr__(self):
|
| 122 |
ashish |
63 |
return "<Item>%d</item>" % (self.id)
|
| 1308 |
chandransh |
64 |
|
| 103 |
ashish |
65 |
class ItemChangeLog(Entity):
|
| 122 |
ashish |
66 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
| 103 |
ashish |
67 |
old_status = Field(Integer)
|
|
|
68 |
new_status = Field(Integer)
|
| 1308 |
chandransh |
69 |
timestamp = Field(DateTime)
|
| 103 |
ashish |
70 |
item = ManyToOne("Item")
|
| 746 |
rajveer |
71 |
using_options(shortnames=True)
|
|
|
72 |
using_table_options(mysql_engine="InnoDB")
|
| 94 |
ashish |
73 |
|
| 103 |
ashish |
74 |
def __repr__(self):
|
|
|
75 |
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 |
76 |
|
| 635 |
rajveer |
77 |
class Category(Entity):
|
| 1970 |
rajveer |
78 |
id = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
79 |
label = Field(String(50))
|
|
|
80 |
description = Field(String(200))
|
|
|
81 |
parent_category_id = Field(Integer)
|
| 4762 |
phani.kuma |
82 |
display_name = Field(String(50))
|
| 746 |
rajveer |
83 |
using_options(shortnames=True)
|
|
|
84 |
using_table_options(mysql_engine="InnoDB")
|
| 1970 |
rajveer |
85 |
|
| 3008 |
rajveer |
86 |
class SimilarItems(Entity):
|
|
|
87 |
item = ManyToOne('Item', primary_key=True)
|
|
|
88 |
catalog_item_id = Field(Integer, primary_key=True, autoincrement=False)
|
|
|
89 |
using_options(shortnames=True)
|
|
|
90 |
using_table_options(mysql_engine="InnoDB")
|
|
|
91 |
|
| 3079 |
rajveer |
92 |
class ProductNotification(Entity):
|
|
|
93 |
item = ManyToOne('Item', primary_key=True)
|
|
|
94 |
email = Field(String(100), primary_key=True, autoincrement=False)
|
|
|
95 |
addedOn = Field(DateTime, primary_key=True, autoincrement=False)
|
|
|
96 |
using_options(shortnames=True)
|
|
|
97 |
using_table_options(mysql_engine="InnoDB")
|
| 3557 |
rajveer |
98 |
|
|
|
99 |
class Source(Entity):
|
|
|
100 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
101 |
name = Field(String(50))
|
|
|
102 |
identifier = Field(String(100))
|
|
|
103 |
using_options(shortnames=True)
|
|
|
104 |
using_table_options(mysql_engine="InnoDB")
|
|
|
105 |
|
|
|
106 |
class SourceItemPricing(Entity):
|
|
|
107 |
source = ManyToOne('Source', primary_key=True)
|
|
|
108 |
item = ManyToOne('Item', primary_key=True)
|
|
|
109 |
mrp = Field(Float)
|
|
|
110 |
sellingPrice = Field(Float)
|
|
|
111 |
using_options(shortnames=True)
|
|
|
112 |
using_table_options(mysql_engine="InnoDB")
|
| 746 |
rajveer |
113 |
|
| 4649 |
phani.kuma |
114 |
class AuthorizationLog(Entity):
|
|
|
115 |
id = Field(Integer, primary_key=True, autoincrement = True)
|
|
|
116 |
timestamp = Field(DateTime, default=datetime.datetime.now())
|
|
|
117 |
item = ManyToOne('Item')
|
|
|
118 |
username = Field(String(30))
|
|
|
119 |
reason = Field(Text)
|
|
|
120 |
using_options(shortnames=True)
|
|
|
121 |
using_table_options(mysql_engine="InnoDB")
|
|
|
122 |
|
| 5504 |
phani.kuma |
123 |
class VoucherItemMapping(Entity):
|
| 5512 |
rajveer |
124 |
voucherType = Field(Integer, primary_key=True)
|
| 5504 |
phani.kuma |
125 |
item = ManyToOne('Item', primary_key=True)
|
|
|
126 |
amount = Field(Integer, default=0, server_default="0")
|
|
|
127 |
using_options(shortnames=True)
|
|
|
128 |
using_table_options(mysql_engine="InnoDB")
|
|
|
129 |
|
| 6039 |
amit.gupta |
130 |
class CategoryVatMaster(Entity):
|
|
|
131 |
categoryId = Field(Integer, primary_key=True)
|
|
|
132 |
minVal = Field(Integer, primary_key=True)
|
|
|
133 |
maxVal = Field(Integer, primary_key=True)
|
|
|
134 |
vatPercent = Field(Float)
|
|
|
135 |
using_options(shortnames=True)
|
|
|
136 |
using_table_options(mysql_engine="InnoDB")
|
|
|
137 |
|
| 3187 |
rajveer |
138 |
def initialize(dbname='catalog', db_hostname="localhost"):
|
| 746 |
rajveer |
139 |
#metadata.bind = "sqlite:///inventory-new.sqlite" #need to read it from configserver.
|
| 1122 |
chandransh |
140 |
#metadata.bind = 'mysql://root:shop2020@localhost/catalog'
|
| 3187 |
rajveer |
141 |
engine = create_engine('mysql://root:shop2020@' + db_hostname + '/' + dbname, pool_recycle=7200)
|
| 1122 |
chandransh |
142 |
metadata.bind = engine
|
| 94 |
ashish |
143 |
metadata.bind.echo = True
|
|
|
144 |
setup_all(True)
|
| 115 |
ashish |
145 |
|
|
|
146 |
if __name__=="__main__":
|
|
|
147 |
initialize()
|