156 | | |
| 156 | }}} |
| 157 | |
| 158 | ==== Controller ==== |
| 159 | {{{controllers/gis.py}}} |
| 160 | {{{ |
| 161 | def layer_newlayertype(): |
| 162 | """ RESTful CRUD controller """ |
| 163 | if deployment_settings.get_security_map() and not shn_has_role("MapAdmin"): |
| 164 | unauthorised() |
| 165 | |
| 166 | resource = request.function |
| 167 | tablename = module + "_" + resource |
| 168 | table = db[tablename] |
| 169 | |
| 170 | # Model options |
| 171 | table.url.comment = SPAN("*", _class="req") |
| 172 | |
| 173 | # CRUD Strings |
| 174 | type = "New Layer Type" |
| 175 | LAYERS = T(TYPE_LAYERS_FMT % type) |
| 176 | ADD_NEW_LAYER = T(ADD_NEW_TYPE_LAYER_FMT % type) |
| 177 | EDIT_LAYER = T(EDIT_TYPE_LAYER_FMT % type) |
| 178 | LIST_LAYERS = T(LIST_TYPE_LAYERS_FMT % type) |
| 179 | NO_LAYERS = T(NO_TYPE_LAYERS_FMT % type) |
| 180 | s3.crud_strings[tablename] = Storage( |
| 181 | title_create=ADD_LAYER, |
| 182 | title_display=LAYER_DETAILS, |
| 183 | title_list=LAYERS, |
| 184 | title_update=EDIT_LAYER, |
| 185 | title_search=SEARCH_LAYERS, |
| 186 | subtitle_create=ADD_NEW_LAYER, |
| 187 | subtitle_list=LIST_LAYERS, |
| 188 | label_list_button=LIST_LAYERS, |
| 189 | label_create_button=ADD_LAYER, |
| 190 | label_delete_button = DELETE_LAYER, |
| 191 | msg_record_created=LAYER_ADDED, |
| 192 | msg_record_modified=LAYER_UPDATED, |
| 193 | msg_record_deleted=LAYER_DELETED, |
| 194 | msg_list_empty=NO_LAYERS) |
| 195 | |
| 196 | # Post-processor |
| 197 | def user_postp(jr, output): |
| 198 | shn_action_buttons(jr) |
| 199 | return output |
| 200 | response.s3.postp = user_postp |
| 201 | |
| 202 | output = shn_rest_controller(module, resource) |
| 203 | |
| 204 | if not "gis" in response.view: |
| 205 | response.view = "gis/" + response.view |
| 206 | |
| 207 | return output |
| 208 | }}} |
| 209 | |