X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FPersons.py;h=678697d2ed113a910fec91ea087665c097debb57;hb=5d2859509faf449daf088d98ae5e737c6c096d69;hp=862d6bac8b55f6753299f926f7a52e4ec1ad4504;hpb=962673302f9b196bc1349c8bac53d75b440ee7a9;p=plcapi.git diff --git a/PLC/Persons.py b/PLC/Persons.py index 862d6ba..678697d 100644 --- a/PLC/Persons.py +++ b/PLC/Persons.py @@ -57,6 +57,7 @@ class Person(Row): 'slice_ids': Parameter([int], "List of slice identifiers"), 'peer_id': Parameter(int, "Peer to which this user belongs", nullok = True), 'peer_person_id': Parameter(int, "Foreign user identifier at peer", nullok = True), + 'person_tag_ids' : Parameter ([int], "List of tags attached to this person"), } related_fields = { 'roles': [Mixed(Parameter(int, "Role identifier"), @@ -68,6 +69,10 @@ class Person(Row): 'slices': [Mixed(Parameter(int, "Slice identifier"), Parameter(str, "Slice name"))] } + view_tags_name = "view_person_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_email(self, email): """ @@ -380,8 +385,13 @@ class Persons(Table): def __init__(self, api, person_filter = None, columns = None): Table.__init__(self, api, Person, columns) - sql = "SELECT %s FROM view_persons WHERE deleted IS False" % \ - ", ".join(self.columns) + view = "view_persons" + for tagname in self.tag_columns: + view= "%s left join %s using (%s)"%(view,Person.tagvalue_view_name(tagname), + Person.primary_key) + + sql = "SELECT %s FROM %s WHERE deleted IS False" % \ + (", ".join(self.columns.keys()+self.tag_columns.keys()),view) if person_filter is not None: if isinstance(person_filter, (list, tuple, set)):