Changes between Version 26 and Version 27 of DeveloperGuidelinesNewModule


Ignore:
Timestamp:
05/26/09 22:05:48 (13 years ago)
Author:
Fran Boon
Comment:

00_db.py, Menu defined in Controller

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelinesNewModule

    v26 v27  
    1212This makes it visible on the front page & the left-hand navigation menu.
    1313
    14 To make this change in code not just in this isnatcne, then edit {{{/models/__db.py}}}:
     14To make this change in code not just in this instance, then edit {{{/models/00_db.py}}}:
    1515{{{
    1616# Populate table with Default modules
     
    2828Create a file {{{/models/module.py}}}
    2929
    30 This needs a table to store the module's menu options in:
    31 {{{
    32 module = 'name'
    33 
    34 # Menu Options
    35 db.define_table('%s_menu_option' % module,
    36                 db.Field('name'),
    37                 db.Field('function'),
    38                 db.Field('description', length=256),
    39                 db.Field('priority', 'integer'),
    40                 db.Field('enabled', 'boolean', default='True'))
    41 db['%s_menu_option' % module].name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, '%s_menu_option.name' % module)]
    42 db['%s_menu_option' % module].name.requires = IS_NOT_EMPTY()
    43 db['%s_menu_option' % module].priority.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, '%s_menu_option.priority' % module)]
    44 }}}
    45 Populate this table with the functions that you wish to expose to the module's front page & left-hand navigation bar:
    46 {{{
    47 if not len(db().select(db['%s' % table].ALL)):
    48         db[table].insert(
    49         name="Home",
    50         function="index",
    51         priority=0,
    52         description="Home",
    53         enabled='True'
    54         )
    55         db[table].insert(
    56         name="Add Vehicle",
    57         function="vehicle/create",
    58         priority=1,
    59         description="Add a vehicle to the database",
    60         enabled='True'
    61         )
    62         db[table].insert(
    63         name="List Vehicles",
    64         function="vehicle",
    65         priority=2,
    66         description="List information of all vehicles",
    67         enabled='True'
    68         )
    69         db[table].insert(
    70         name="Search Vehicles",
    71         function="vehicle/search",
    72         priority=3,
    73         description="List information of all vehicles",
    74         enabled='True'
    75         )
    76 }}}
    77 
    78 Add additional tables to this file, as-required for your resources.[[BR]]
     30Add tables to this file, as-required for your resources.[[BR]]
    7931To avoid namespace clashes, use the format: {{{db.module_table}}}
    8032
     
    9143}}}
    9244
    93 Also add the messages for your resources:
     45Add the messages for your resources:
    9446{{{
    9547title_create = T('Add Vehicle')