# Copyright (C) 2006 The Trustees of Princeton University
#
# $Id$
+# $URL$
#
from types import StringTypes
Parameter(str, "Slice name"))]
}
-
-
- # for Cache
- class_key = 'email'
- foreign_fields = ['first_name', 'last_name', 'title', 'email', 'phone', 'url',
- 'bio', 'enabled', 'password', ]
- # forget about these ones, they are read-only anyway
- # handling them causes Cache to re-sync all over again
- # 'last_updated', 'date_created'
- foreign_xrefs = [
- {'field' : 'key_ids', 'class': 'Key', 'table' : 'person_key' } ,
- {'field' : 'site_ids', 'class': 'Site', 'table' : 'person_site'},
-# xxx this is not handled by Cache yet
-# 'role_ids': Parameter([int], "List of role identifiers"),
-]
-
def validate_email(self, email):
"""
Validate email address. Stolen from Mailman.
if 'pi' in self['roles']:
if set(self['site_ids']).intersection(person['site_ids']):
- # Can update people with higher role IDs
- return min(self['role_ids']) < min(person['role_ids'])
+ # Can update person is neither a PI or ADMIN
+ return (not (('pi' in person['roles']) or ('admin' in person['roles'])))
return False
if 'pi' in self['roles']:
if set(self['site_ids']).intersection(person['site_ids']):
# Can view people with equal or higher role IDs
- return min(self['role_ids']) <= min(person['role_ids'])
+ return 'admin' not in person['roles']
return False
assert 'person_id' in self
assert isinstance(value, list)
- (role_ids, roles_names) = self.separate_types(value)[0:2]
+ (role_ids, role_names) = self.separate_types(value)[0:2]
# Translate roles into role_ids
- if roles_names:
- roles = Roles(self.api, role_names, ['role_id']).dict('role_id')
+ if role_names:
+ roles = Roles(self.api, role_names).dict('role_id')
role_ids += roles.keys()
# Add new ids, remove stale ids
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)
+
foreign_fields = {'role_ids': ('role_id', 'person_role'),
'roles': ('name', 'roles'),
'site_ids': ('site_id', 'person_site'),