TheLegace

db.py

Aug 6th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. db = DAL('sqlite://storage.sqlite')
  2.  
  3. from gluon.tools import *
  4. auth = Auth(db)
  5. auth.define_tables()
  6. crud = Crud(db)
  7.  
  8. education = ['Doctorate','Masters','Undergraduate', 'High School', 'Other']
  9. languages = ['English', 'French', 'Other']
  10. services = ['Immigration Documents', 'Get House', 'Find a Job']
  11.  
  12.  
  13. db.define_table('service',
  14.     Field('type'), Field('active', 'boolean'),
  15.     Field('content', 'text'), Field('date_service', 'date'))
  16.  
  17. db.define_table('client',
  18.     Field('first', requires=IS_NOT_EMPTY()), Field('last', requires=IS_NOT_EMPTY()), Field('middle', label='MI'),
  19.     Field('country'),
  20.     Field('date_client', 'date', label='Created On'), Field('address', 'text'),
  21.     Field('city',), Field('province'),
  22.     Field('education'), Field('languages'),
  23.     Field('services', db.service),
  24.     format='%(last)s, %(first)s')
  25.  
  26.    
  27. db.client.education.requires=IS_IN_SET(education)
  28. db.client.languages.requires=IS_IN_SET(languages)
  29. db.service.type.requires=IS_IN_SET(services)
  30. db.client.widget = SQLFORM.widgets.autocomplete(
  31.      request, db.client.first, limitby=(0,10), min_length=2)
Advertisement
Add Comment
Please, Sign In to add comment