| 162 | == Proposal (nursix) == |
| 163 | |
| 164 | a) keep the original dict, but change the values of the dict into tuples like: |
| 165 | {{{ |
| 166 | irs_incident_type_opts = { |
| 167 | 101: ("roadway.bridgeClosure", T("Broken Road")), |
| 168 | } |
| 169 | }}} |
| 170 | b) make the .represent towards normal users show the second item in the tuple |
| 171 | rather than the first (easy tweak), while admin users may see both (the |
| 172 | controller can switch between those two) |
| 173 | |
| 174 | c) have a admin-only-accessible DB table irs_incident_type_opts with the |
| 175 | options available for the "normal" user like: |
| 176 | {{{ |
| 177 | define_table("irs_incident_type_opts", |
| 178 | Field("code", "integer", requires=IS_IN_SET(irs_incident_type_opts))) |
| 179 | }}} |
| 180 | d) In the model, make .requires the normal IS_IN_SET (To allow Sync of records with any of the options): |
| 181 | {{{ |
| 182 | .requires = IS_IN_SET(irs_incident_type_opts) |
| 183 | }}} |
| 184 | f) In the controller, if "normal" user, override this requires by: |
| 185 | {{{ |
| 186 | allowed_options = [opt.code for opt in db().select(db.irs_incident_type_opts.code)] |
| 187 | .requires = IS_IN_SET(allowed_opts) |
| 188 | }}} |
| 189 | |
| 190 | == Questions == |
| 191 | |