Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
442 rajveer 1
'''
2
Created on 13-Sep-2010
3
 
4
@author: rajveer
5
'''
6
from elixir import *
7
import datetime
8
 
9
class Provider(Entity):
10
    id = Field(Integer, primary_key=True, autoincrement=True)
11
    name = Field(String(100))
12
    awb = OneToMany("AWB")
13
 
14
class AWB(Entity):
15
    id = Field(Integer, primary_key=True, autoincrement=True)
16
    awb_number = Field(String(100))
17
    is_available = Field(Boolean)
18
    provider = ManyToOne("Provider")
19
    #shipment = OneToOne("Shipment", inverse="awb")
20
 
21
class ShipmentUpdate(Entity):
22
    id = Field(Integer, primary_key=True, autoincrement=True)
23
    pin = Field(String(20))
24
    timestamp = Field(DateTime)
25
    description = Field(String(100))
26
    #awb = ManyToOne("AWB")
27
    shipment = ManyToOne("Shipment")    
28
 
29
class Shipment(Entity):
30
    id = Field(Integer, primary_key=True, autoincrement=True) 
31
    warehouse_name = Field(String(100))
32
    awb = Field(String(100))
33
    origin = Field(String(100))
34
    destination = Field(String(100))
35
    timestamp = Field(DateTime)
36
    recepient_name = Field(String(100))
37
    recepient_address = Field(String(200))
38
    recepient_pincode = Field(String(20))
39
    recepient_phone = Field(String(20))
40
    shipment_weight = Field(String(20))
41
    shipment_contents = Field(String(100))
42
    status_message = Field(String(100))
43
    #awb = ManyToOne("AWB")
44
    shipment_update = OneToMany("ShipmentUpdate")
45
 
472 rajveer 46
class DeliveryEstimate(Entity):
47
    destination_pin = Field(String(20), primary_key=True)
48
    warehouse_id = Field(Integer)
49
    delivery_time = Field(Integer)
50
    provider = ManyToOne("Provider", primary_key=True)
51
 
52
 
442 rajveer 53
'''
54
struct Shipment{
55
    1:string warehouse_id,
56
    2:string awb,
57
    3:string origin,
58
    4:string destination,
59
    5:i64 timestamp,
60
    6:string recepient_name,
61
    7:string recepient_address,
62
    8:string recepient_pincode,
63
    9:string recepient_phone,
64
    10:string shipment_weight,
65
    11:string shipment_contents
66
}
67
'''
68
 
69
def initialize():
70
    metadata.bind = "sqlite:///logistics.sqlite" #need to read it from configserver.
71
    metadata.bind.echo = True
72
    setup_all(True)
73
 
74
if __name__=="__main__":
75
    initialize()
76