Changes between Version 51 and Version 52 of S3/S3REST/URLFormat
- Timestamp:
- 04/09/20 13:17:32 (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
S3/S3REST/URLFormat
v51 v52 112 112 113 113 Find persons whose first name starts with "Mir": 114 115 114 {{{ 116 115 /pr/person?person.first_name__like=Mir* … … 118 117 119 118 The tilde {{{~}}} refers to the master resource addressed by the URL, i.e. this one is equivalent to the former: 120 121 119 {{{ 122 120 /pr/person?~.first_name__like=Mir* … … 124 122 125 123 Find offices with location names which start with "Osl": 126 127 124 {{{ 128 125 /org/office?~.location_id$name__like=Osl* … … 130 127 131 128 Query operators can be negated by inserting a {{{!}}}, i.e. find offices with location names which do ''not'' start with "Osl": 132 133 129 {{{ 134 130 /org/office?~.location_id$name__like!=Osl* 135 131 }}} 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) 136 159 137 160 == Bracketed OR Queries ==