| | 132 | |
| | 133 | Find all people *without* a specific [set of] qualification(s): |
| | 134 | |
| | 135 | This isn't supported out of the box, as it cannot be done with WHERE clause(s). However it is easy to do it with a little custom code: |
| | 136 | {{{ |
| | 137 | def customise_pr_person_resource(r, tablename): |
| | 138 | # Filtered Component to allow an exclusive filter |
| | 139 | s3db = current.s3db |
| | 140 | ctable = s3db.hrm_certificate |
| | 141 | query = (ctable.name.like("Fire%")) & \ |
| | 142 | (ctable.deleted == False) |
| | 143 | rows = current.db(query).select(stable.id) |
| | 144 | fire_cert_ids = [row.id for row in rows] |
| | 145 | s3db.add_components("pr_person", |
| | 146 | hrm_certification = {"name": "missing_qualification", |
| | 147 | "joinby": "person_id", |
| | 148 | "filterby": {"certificate_id": fire_cert_ids}, |
| | 149 | }, |
| | 150 | ) |
| | 151 | settings.customise_pr_person_resource = customise_pr_person_resource |
| | 152 | }}} |
| | 153 | |
| | 154 | Then you can do: |
| | 155 | {{{ |
| | 156 | /pr/person?missing_qualification.id=None* |
| | 157 | }}} |
| | 158 | (This can be then further refined using standard UI Filter Widgets) |