Hi Alan,

Sorry for the late reply.. 

Table Definition:


##Customer table.
db.define_table('Customer',
    Field('CustID', type = 'string', length = 10, notnull = True, unique = 
True),
    Field('Surname', type = 'string', length = 15, notnull = True),
    Field('FirstName', type = 'string', length = 15, notnull = True),
    Field('Address', length = 50, notnull = True),
    Field('EmailID', type = 'string', length = 30, notnull = True, unique = 
True),
    Field('Phone', type = 'string', length = 10, unique = True),
    Field('Password', type='password'))

##Booking Table.
db.define_table('Booking',
    Field('BookingID', type = 'string', length = 10, notnull = True, unique 
= True),
    Field('CustID', type = 'string', length = 10, notnull = True),
    Field('FlightNum', type = 'string', length = 10, notnull = True),
    Field('DepartureLocation', type = 'string', length = 20, notnull = 
True),
    Field('ArrivalLocation', type = 'string', length = 20, notnull = True),
    Field('DepartureDate', type='date'),
    Field('ArrivalDate', type='date'),
    Field('DepartureTime', type = 'time'),
    Field('ArrivalTime', type = 'time'))

##Flight Table
db.define_table('Flight',
    Field('FlightNum', type = 'string', length = 10, notnull = True),
    Field('PlaneID', type = 'string', length = 10, notnull = True),
    Field('DepartureLocation', type = 'string', length = 20, notnull = 
True),
    Field('ArrivalLocation', type = 'string', length = 20, notnull = True),
    Field('DepartureDate', type='date'),
    Field('ArrivalDate', type='date'),
    Field('DepartureTime', type = 'time'),
    Field('ArrivalTime', type = 'time'))  

##Plane table
db.define_table('Plane',
    Field('PlaneID', type = 'string', length = 10, notnull = True, unique = 
True),
    Field('CarrierID', type = 'string', length = 10, notnull = True),
    Field('Model', type = 'string', length = 15, notnull = True),
    Field('Make', type = 'string', length = 15, notnull = True),
    Field('FirstClassCapacity', type = 'integer', notnull = True),
    Field('BusClassCapacity', type = 'integer', notnull = True),
    Field('EcoClassCapacity', type = 'integer', notnull = True),
    Field('FirstClassPrice', type = 'integer', notnull = True),
    Field('BusClassPrice', type = 'integer', notnull = True),
    Field('EcoClassPrice', type = 'integer', notnull = True))

## Carrier table.
db.define_table('Carrier', 
    Field('CarrierID', type = 'string', length = 10, notnull = True, unique 
= True),
    Field('Name', type = 'string', length = 30, notnull = True, unique = 
True),
    Field('Picture', type = 'upload'))


##Below is the code for changing the dateform for the date type in the code.
db.Flight.DepartureDate.requires = IS_DATE(format='%m/%d/%Y')
db.Flight.ArrivalDate.requires= IS_DATE(format='%m/%d/%Y')

##Below is code the drop down menu which is mapped to the STATE module in 
modules.
db.Flight.DepartureLocation.requires = IS_IN_SET(states)
db.Flight.ArrivalLocation.requires = IS_IN_SET(states)

##Validators for fields:
db.Customer.EmailID.requires = IS_EMAIL(error_message='Please check your 
email address!')
db.Customer.Phone.requires = IS_NOT_EMPTY()
db.Customer.Surname.requires = IS_NOT_EMPTY()
db.Customer.FirstName.requires = IS_NOT_EMPTY()

##Below are the conditions where the foreign key is referencing primary key 
in the above tables.
db.Booking.CustID.requires = [IS_IN_DB(db, db.Customer.CustID)]
db.Booking.FlightNum.requires = [IS_IN_DB(db, db.Flight.FlightNum)]
db.Flight.PlaneID.requires = [IS_IN_DB(db, db.Plane.PlaneID)]
db.Plane.CarrierID.requires = [IS_IN_DB(db, db.Carrier.CarrierID)]

We aren't allowed to use CRUD..

On Thursday, January 17, 2013 10:13:26 PM UTC+10:30, Alan Etkin wrote:
>
> I've tried that however when I hit search flight button it returns an 
>> empty page with no data from the database... 
>>
>
> Please post your model also (the table definitions). And consider using 
> SQLFORM <http://www.web2py.com/books/default/chapter/29/07#SQLFORM>, as 
> Anthony suggested, or 
> CRUD<http://www.web2py.com/books/default/chapter/29/07#CRUD>, 
> for an easier way of handling user input.
>
>

-- 



Reply via email to