Version 9 (modified by 16 years ago) ( diff ) | ,
---|
How to add a new module?
Copy an existing module, paste & edit. Good modules to look at to start with are or & cr as these are simplest & standard.
Model
Add module to db.module:
This makes it visible on the front page & the left-hand navigation menu
Create a file /models/module.py
This needs a table to store the module's menu options in:
module='name' # Menu Options db.define_table('%s_menu_option' % module, SQLField('name'), SQLField('function'), SQLField('description',length=256), SQLField('priority','integer'), SQLField('enabled','boolean',default='True')) db['%s_menu_option' % module].name.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'%s_menu_option.name' % module)] db['%s_menu_option' % module].name.requires=IS_NOT_EMPTY() db['%s_menu_option' % module].priority.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'%s_menu_option.priority' % module)]
Add additional tables to this file, as-required.
To avoid namespace clashes, use the format: db.module_table
Controller
Add CRUD functions for these tables to /controllers/module.py
The RESTful controller for a table needs just a few small tweaks once pasted:
- Search/Replace 'organisation' with your_resource
- Search/Replace 'Organisation' with Your_resource
- Fix plurals, if required (e.g. Persons -> People, Classs to Classes, Metadatas -> Metadata)
Old: DeveloperGuidelinesCreateReadUpdateDelete
Populate the module's menu_options table with the functions that you wish to expose to the module's front page & left-hand navigation bar.
Views
Add HTML templates for any custom functions: /views/module/function.html
NB Only index.html
is required to start with since the RESTful controller re-uses standard views