svn keywords
[plcapi.git] / PLC / Methods / DeletePersonFromSlice.py
index f21db58..d36a1c3 100644 (file)
@@ -1,3 +1,5 @@
+# $Id$
+# $URL$
 from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
@@ -30,16 +32,20 @@ class DeletePersonFromSlice(Method):
         persons = Persons(self.api, [person_id_or_email])
         if not persons:
             raise PLCInvalidArgument, "No such account"
-
         person = persons[0]
 
         # Get slice information
         slices = Slices(self.api, [slice_id_or_name])
         if not slices:
             raise PLCInvalidArgument, "No such 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 delete foreign users from 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']:
@@ -48,5 +54,8 @@ class DeletePersonFromSlice(Method):
 
        if slice['slice_id'] in person['slice_ids']:
             slice.remove_person(person)
+       
+       self.event_objects = {'Slice': [slice['slice_id']],
+                             'Person': [person['person_id']]}  
 
         return 1