97 | | ''[tbd]'' |
| 97 | The {{{auth_Consent.consent_query}}} method can be used to filter a DAL table for records belonging to persons that have consented to a particular processing type: |
| 98 | |
| 99 | {{{#!python |
| 100 | # Get HR records where the person has consented to the HRDSHARE processing type: |
| 101 | table = s3db.hrm_human_resource |
| 102 | query = s3db.auth_Consent.consent_query(table, "HRDSHARE", field="person_id") & (table.deleted==False) |
| 103 | rows = db(query).select(...) |
| 104 | }}} |
| 105 | |
| 106 | If {{{field}}} is not specified, {{{person_id}}} will be assumed (or {{{id}}} when the table is pr_person). |
| 107 | |
| 108 | {{{consent_query}}} is a class method, so instantiation of {{{auth_Consent}}} is not required. |
| 109 | |
| 110 | The consent sub-query will include an implicit inner join with the {{{auth_consent}}} table (not aliased), which may need to be taken into account when the overall query constructs additional joins. |
| 111 | |
| 112 | {{{consent_query}}} takes into account whether the consent record or the consent option have expired, but it will not verify the integrity of any consent records. |