From 9101105d1e4bcbaa539e81323c14fca5a5e6c1ed Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Tue, 27 Jul 2010 14:58:30 -0400 Subject: [PATCH] Changed method to use new write policy mechanism --- PLC/Methods/AddPersonToSlice.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/PLC/Methods/AddPersonToSlice.py b/PLC/Methods/AddPersonToSlice.py index 1cee0301..de4974b7 100644 --- a/PLC/Methods/AddPersonToSlice.py +++ b/PLC/Methods/AddPersonToSlice.py @@ -29,32 +29,23 @@ class AddPersonToSlice(Method): def call(self, auth, person_id_or_email, slice_id_or_name): # Get account information + # SSS: Change call to Persons persons = Persons(self.api, [person_id_or_email]) if not persons: raise PLCInvalidArgument, "No such account" person = persons[0] + + ### The code below will eventually turn into a big UPDATE ... WHERE # Get slice information - slices = Slices(self.api, [slice_id_or_name]) + + slices = Slices(self.api, self.caller, [slice_id_or_name]) if not slices: - raise PLCInvalidArgument, "No such slice" + raise PLCInvalidArgument, "No such slice or access denied to requested slice" slice = slices[0] - # N.B. Allow foreign users to be added to local slices and - # local users to be added to foreign slices (and, of course, - # local users to be added to local slices). - if person['peer_id'] is not None and slice['peer_id'] is not None: - raise PLCInvalidArgument, "Cannot add foreign users to foreign slices" - - # If we are not admin, make sure the caller is a PI - # of the site associated with the slice - if 'admin' not in self.caller['roles']: - if slice['site_id'] not in self.caller['site_ids']: - raise PLCPermissionDenied, "Not allowed to add users to this slice" - - if slice['slice_id'] not in person['slice_ids']: - slice.add_person(person) - + slices.update_rows(['key':'slice_person','type':Person,'value':person) + # Logging variables self.event_objects = {'Person': [person['person_id']], 'Slice': [slice['slice_id']]} -- 2.47.0