Changes between Version 31 and Version 32 of DeveloperGuidelines/GIS


Ignore:
Timestamp:
09/01/10 10:22:30 (11 years ago)
Author:
Fran Boon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/GIS

    v31 v32  
    133133Assuming that !OpenLayers supports the layertype:
    134134==== Model ====
    135 {{{models/_gis.py}}}
     135{{{models/03_gis.py}}}
    136136{{{
    137 gis_layer_types=['newlayertype','...']
    138 gis_layer_newlayertype_subtypes=['Satellite','Maps','Hybrid']
     137gis_layer_types = ["newlayertype", "..."]
     138gis_layer_newlayertype_subtypes = ["Subtype"]
    139139# Base table from which the rest inherit
    140 gis_layer=SQLTable(db,'gis_layer',
    141             db.Field('modified_on','datetime',default=now),
    142             #db.Field('uuid',length=64,default=uuid.uuid4()),   # Layers like OpenStreetMap, Google, etc shouldn't sync
    143             db.Field('name'),
    144             db.Field('description',length=256),
    145             #db.Field('priority','integer'),    # System default priority is set in ol_layers_all.js. User priorities are set in WMC.
    146             db.Field('enabled','boolean',default=True))
    147 gis_layer.name.requires=IS_NOT_EMPTY()
     140gis_layer = db.Table(db, "gis_layer", timestamp,
     141            #uuidstamp, # Layers like OpenStreetMap, Google, etc shouldn't sync
     142            Field("name", notnull=True, label=T("Name"), requires=IS_NOT_EMPTY(), comment=SPAN("*", _class="req")),
     143            Field("description", label=T("Description")),
     144            #Field("priority", "integer", label=T("Priority")),    # System default priority is set in ol_layers_all.js. User priorities are set in WMC.
     145            Field("enabled", "boolean", default=True, label=T("Available in Viewer?")))
    148146for layertype in gis_layer_types:
    149     resource='layer_'+layertype
    150     table=module+'_'+resource
    151     title_create=T('Add Layer')
    152     title_display=T('Layer Details')
    153     title_list=T('List Layers')
    154     title_update=T('Edit Layer')
    155     subtitle_create=T('Add New Layer')
    156     subtitle_list=T('Layers')
    157     label_list_button=T('List Layers')
    158     label_create_button=T('Add Layer')
    159     msg_record_created=T('Layer added')
    160     msg_record_modified=T('Layer updated')
    161     msg_record_deleted=T('Layer deleted')
    162     msg_list_empty=T('No Layers currently defined')
     147    resource = "layer_" + layertype
     148    tablename = "%s_%s" % (module, resource)
    163149    # Create Type-specific Layer tables
    164     if layertype=="newlayertype":
    165         t=SQLTable(db,table,
    166             db.Field('subtype'),
    167             gis_layer)
    168         t.subtype.requires=IS_IN_SET(gis_layer_newlayertype_subtypes)
    169         db.define_table(table,t)
    170         db['%s' % table].represent=lambda table:shn_list_item(table,resource='layer_newlayertype',action='display',extra=str(table.enabled))
    171         if not len(db().select(db['%s' % table].ALL)):
    172             # Populate table
    173             for subtype in gis_layer_newlayertype_subtypes:
    174                 db['%s' % table].insert(
    175                         name='New Layer Type '+subtype,
    176                         subtype=subtype
    177                     )
    178         # Customise CRUD strings if-desired
    179         msg_list_empty=T('No New Layer Type Layers currently defined')
    180         exec('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)
    181 }}}
    182 
     150    if layertype == "newlayertype":
     151        t = db.Table(db, table,
     152            gis_layer,
     153            Field("subtype", label=T("Sub-type"), requires = IS_IN_SET(gis_layer_newlayertype_subtypes, zero=None)),
     154            Field("layer_specific_option"))
     155        table = db.define_table(tablename, t, migrate=migrate)
     156   
    183157==== Module ====
    184158New Layer Types & their Fields need adding to {{{modules/s3gis.py}}}