git://git.onelab.eu
/
plcapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d212f61
)
Rationalize: can now update aggregate values (roles, sites, keys, slices)
author
Tony Mack
<tmack@cs.princeton.edu>
Tue, 6 Nov 2007 03:53:33 +0000
(
03:53
+0000)
committer
Tony Mack
<tmack@cs.princeton.edu>
Tue, 6 Nov 2007 03:53:33 +0000
(
03:53
+0000)
PLC/Methods/UpdatePerson.py
patch
|
blob
|
history
diff --git
a/PLC/Methods/UpdatePerson.py
b/PLC/Methods/UpdatePerson.py
index
790307e
..
8f74fc0
100644
(file)
--- a/
PLC/Methods/UpdatePerson.py
+++ b/
PLC/Methods/UpdatePerson.py
@@
-4,10
+4,11
@@
from PLC.Parameter import Parameter, Mixed
from PLC.Persons import Person, Persons
from PLC.Auth import Auth
from PLC.Persons import Person, Persons
from PLC.Auth import Auth
+related_fields = Person.related_fields.keys()
can_update = lambda (field, value): field in \
['first_name', 'last_name', 'title', 'email',
'password', 'phone', 'url', 'bio', 'accepted_aup',
can_update = lambda (field, value): field in \
['first_name', 'last_name', 'title', 'email',
'password', 'phone', 'url', 'bio', 'accepted_aup',
- 'enabled']
+ 'enabled']
+ related_fields
class UpdatePerson(Method):
"""
class UpdatePerson(Method):
"""
@@
-22,7
+23,7
@@
class UpdatePerson(Method):
roles = ['admin', 'pi', 'user', 'tech']
roles = ['admin', 'pi', 'user', 'tech']
- person_fields = dict(filter(can_update, Person.fields.items()))
+ person_fields = dict(filter(can_update, Person.fields.items()
+ Person.related_fields.items()
))
accepts = [
Auth(),
accepts = [
Auth(),
@@
-51,6
+52,12
@@
class UpdatePerson(Method):
# Check if we can update this account
if not self.caller.can_update(person):
raise PLCPermissionDenied, "Not allowed to update specified account"
# Check if we can update this account
if not self.caller.can_update(person):
raise PLCPermissionDenied, "Not allowed to update specified account"
+
+ # Make requested associations
+ for field in related_fields:
+ if field in person_fields:
+ person.associate(auth, field, person_fields[field])
+ person_fields.pop(field)
person.update(person_fields)
person.update_last_updated(False)
person.update(person_fields)
person.update_last_updated(False)