132 | | |
| 132 | If you want to add additional restrictions to the automatically provided buttons then try the following code, which has been used to restrict the delete button to records with a certain status |
| 133 | {{{ |
| 134 | query = (r.table.status == 1) # Status of Pending |
| 135 | rows = db(query).select(r.table.id) |
| 136 | try: |
| 137 | response.s3.actions[1]['restrict'].extend(str(row.id) for row in rows) |
| 138 | except KeyError: # the restrict key doesn't exist |
| 139 | response.s3.actions[1]['restrict'] = [str(row.id) for row in rows] |
| 140 | except IndexError: # the delete buttons doen't exist |
| 141 | pass |
| 142 | }}} |