X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FSites.py;h=ef9f02a05e3b1f69cb2980aeaea534464c279278;hb=84d214e3c398bbb172e1a4a0adc22e57179d5954;hp=d31f4ea87312990b81974ec729f13a03938b5896;hpb=8fa2c23822e1bf280351d09b917e3c549951cf5b;p=plcapi.git diff --git a/PLC/Sites.py b/PLC/Sites.py index d31f4ea..ef9f02a 100644 --- a/PLC/Sites.py +++ b/PLC/Sites.py @@ -45,6 +45,7 @@ class Site(Row): 'node_ids': Parameter([int], "List of site node identifiers"), 'peer_id': Parameter(int, "Peer to which this site belongs", nullok = True), 'peer_site_id': Parameter(int, "Foreign site identifier at peer", nullok = True), + 'site_tag_ids' : Parameter ([int], "List of tags attached to this site"), 'ext_consortium_id': Parameter(int, "external consortium id", nullok = True) } related_fields = { @@ -53,6 +54,10 @@ class Site(Row): 'addresses': [Mixed(Parameter(int, "Address identifer"), Filter(Address.fields))] } + view_tags_name = "view_site_tags" + # tags are used by the Add/Get/Update methods to expose tags + # this is initialized here and updated by the accessors factory + tags = { } def validate_name(self, name): if not len(name): @@ -238,9 +243,14 @@ class Sites(Table): def __init__(self, api, site_filter = None, columns = None): Table.__init__(self, api, Site, columns) - - sql = "SELECT %s FROM view_sites WHERE deleted IS False" % \ - ", ".join(self.columns) + + view = "view_sites" + for tagname in self.tag_columns: + view= "%s left join %s using (%s)"%(view,Site.tagvalue_view_name(tagname), + Site.primary_key) + + sql = "SELECT %s FROM %s WHERE deleted IS False" % \ + (", ".join(self.columns.keys()+self.tag_columns.keys()),view) if site_filter is not None: if isinstance(site_filter, (list, tuple, set)):