Updated can_update() and can_view() to check on "roles" capabilities
authorMarc Fiuczynski <mef@cs.princeton.edu>
Wed, 27 May 2009 16:05:14 +0000 (16:05 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Wed, 27 May 2009 16:05:14 +0000 (16:05 +0000)
rather than use the relative values of role_ids.  The code now
functions even when a person has no roles whatsoever, which under
certain error conditions can occur.

PLC/Persons.py

index ee01550..3c49ae6 100644 (file)
@@ -152,8 +152,8 @@ class Person(Row):
 
         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
 
@@ -175,7 +175,7 @@ class Person(Row):
         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