svn keywords
[plcapi.git] / PLC / Methods / AddPersonToSite.py
index 8d46624..e4d3aa4 100644 (file)
@@ -1,3 +1,5 @@
+# $Id$
+# $URL$
 from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
@@ -25,27 +27,32 @@ class AddPersonToSite(Method):
         ]
 
     returns = Parameter(int, '1 if successful')
-    event_type = 'AddTo'
-    object_type = 'Site'
-    object_ids = []
 
     def call(self, auth, person_id_or_email, site_id_or_login_base):
         # Get account information
         persons = Persons(self.api, [person_id_or_email])
         if not persons:
             raise PLCInvalidArgument, "No such account"
+        person = persons[0]
 
-        person = persons.values()[0]
+        if person['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local account"
 
         # Get site information
         sites = Sites(self.api, [site_id_or_login_base])
         if not sites:
             raise PLCInvalidArgument, "No such site"
+        site = sites[0]
 
-        site = sites.values()[0]
+        if site['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local site"
 
         if site['site_id'] not in person['site_ids']:
             site.add_person(person)
-       self.object_ids = [site['site_id']]
-       
+
+       # Logging variables
+       self.event_objects = {'Site': [site['site_id']],
+                             'Person': [person['person_id']]}
+       self.message = 'Person %d added to site %d' % \
+               (person['person_id'], site['site_id'])
         return 1