Changes between Version 49 and Version 50 of S3/S3Model/ComponentResources


Ignore:
Timestamp:
02/07/14 10:52:34 (8 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • S3/S3Model/ComponentResources

    v49 v50  
    9898=== Filtered Components ===
    9999
    100 Component joins can be filtered, so that only a subset of the records in the component table forms the actual component:
     100Component joins can be filtered to a subset of the records in the component table:
    101101
    102102{{{#!python
    103103s3db.add_components("org_organisation",
    104104                    org_office={"name": "headquarter",        # the component alias
    105                                 "joinby": "organisation_id"   # the foreign key
     105                                "joinby": "organisation_id",  # the foreign key
    106106                                "filterby": "office_type_id", # the name of the field in the component table to filter by
    107                                 "filterfor": 4,               # the value(s) to filter for
    108                                })
     107                                "filterfor": [4],             # the value(s) to filter for
     108                               },
     109                   )
    109110}}}
    110111
    111112Currently only inclusive filters are supported.
    112113
    113 It is possible to link the same component table to the same master table more than once using different joins and/or filters.
    114 
     114It is possible to link the same component table to the same master table more than once using different aliases with joins and/or filters:
     115
     116{{{#!python
     117s3db.add_components("org_organisation",
     118                    org_office=(
     119                                {"name": "headquarter",
     120                                 "joinby": "organisation_id",
     121                                 "filterby": "office_type_id",
     122                                 "filterfor": [4],
     123                                },
     124                                {"name": "fieldoffice",
     125                                 "joinby": "organisation_id",
     126                                 "filterby": "office_type_id",
     127                                 "filterfor": [5],
     128                                },
     129                               ),
     130                   )
     131}}}
    115132=== Single / Multiple Component Records ===
    116133