Changes between Version 13 and Version 14 of DeveloperGuidelinesNewModule


Ignore:
Timestamp:
01/03/09 09:46:05 (16 years ago)
Author:
Fran Boon
Comment:

New way of defining crud strings

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelinesNewModule

    v13 v14  
    3535e.g. if beilding a Vehicle Management System, create db.veh_vehicle:
    3636{{{
    37 db.define_table('veh_vehicle',
     37module='veh'
     38resource='vehicle'
     39table=module+'_'+resource
     40single=resource.capitalize()
     41# NB May need manual fixing!
     42plural=single+'s'
     43db.define_table(table,
    3844                SQLField('modified_on','datetime',default=now),
    3945                SQLField('uuid',length=64,default=uuid.uuid4()),
    4046                SQLField('name'))
     47db['%s' % table].represent=lambda table:shn_list_item(table,resource='vehicle',action='display')
    4148db.veh_vehicle.name.requires=IS_NOT_EMPTY()
    4249db.veh_vehicle.name.comment=SPAN("*",_class="req")
     
    4552Also add the messages for your resources:
    4653{{{
    47 crud_strings_vehicle=Storage(title_create=T('Add Vehicle'),
    48             title_display=T('Vehicle Details'),
    49             title_list=T('List Vehicles'),
    50             title_update=T('Edit Vehicle'),
    51             subtitle_list=T('Vehicles'),
    52             subtitle_create=T('Add New Vehicle'),
    53             label_list_button=T('List Vehicles'),
    54             label_create_button=T('Add Shelter'),
    55             msg_record_created=T('Vehicle added'),
    56             msg_record_modified=T('Vehicle updated'),
    57             msg_record_deleted=T('Vehicle deleted'),
    58             msg_list_empty=T('No Vehicles currently registered'))
     54title_create=T('Add %s' % single)
     55title_display=T('%s Details' % single)
     56title_list=T('List %s' % plural)
     57title_update=T('Edit %s' % single)
     58subtitle_create=T('Add New %s' % single)
     59subtitle_list=T('%s' % plural)
     60label_list_button=T('List %s' % plural)
     61label_create_button=T('Add %s' % single)
     62msg_record_created=T('%s added' % single)
     63msg_record_modified=T('%s updated' % single)
     64msg_record_deleted=T('%s deleted' % single)
     65msg_list_empty=T('No %s currently registered' % plural)
     66exec('crud_strings.%s=Storage(title_create=title_create, title_display=title_display, title_list=title_list, title_update=title_update, subtitle_create=subtitle_create, subtitle_list=subtitle_list, label_list_button=label_list_button, label_create_button=label_create_button, msg_record_created=msg_record_created, msg_record_modified=msg_record_modified, msg_record_deleted=msg_record_deleted, msg_list_empty=msg_list_empty)' % resource)
    5967}}}
    6068Copy/paste & do just a few small tweaks once pasted:
    61  * Search/Replace 'Shelter' with Your_resource
    62  * Fix plurals, if required (e.g. Persons -> People, Classs -> Classes, Metadatas -> Metadata)
    6369 * Maybe change phrasing: registered vs defined, etc
    6470