| 21 | == Resource Tagging == |
| 22 | |
| 23 | Resource tagging can be a method to assign tickets to resources, e.g. to hospitals, organisations or projects. |
| 24 | |
| 25 | A resource tag is basically a table with: |
| 26 | * tag ID |
| 27 | * ticket ID |
| 28 | * resource name (=tablename) |
| 29 | * resource UID |
| 30 | |
| 31 | which links tickets to any resource (many-to-many, a ticket can be linked to multiple resources). |
| 32 | |
| 33 | A RESTful controller for resource tags can CRUD all tickets that are assigned to a specific resource, or to a type of resources, e.g. like: |
| 34 | |
| 35 | {{{ |
| 36 | def tag(): |
| 37 | |
| 38 | tablename = request.vars.get("tag.resource", None) |
| 39 | uid = request.vars.get("tag.uid", None) |
| 40 | filter = None |
| 41 | |
| 42 | if tablename: |
| 43 | filter = (db.ticket_tag.resource_name==tablename) |
| 44 | if uid: |
| 45 | filter = (db.ticket_tag.resource_uid==uid) & filter |
| 46 | response.s3.filter = filter |
| 47 | |
| 48 | return shn_rest_controller("ticket", "tag", ...) |
| 49 | }}} |
| 50 | |
| 51 | This controller can be linked-in in any relevant resource view (e.g. as a popup) in a generic way. |
| 52 | The tags can also be used to link module-specific request/response information to the tickets. |
| 53 | |