2 from PLC.Faults import *
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.Persons import Person, Persons
6 from PLC.Sites import Site, Sites
7 from PLC.Auth import Auth
9 class DeletePersonFromSite(Method):
11 Removes the specified person from the specified site. If the
12 person is not a member of the specified site, no error is
15 Returns 1 if successful, faults otherwise.
22 Mixed(Person.fields['person_id'],
23 Person.fields['email']),
24 Mixed(Site.fields['site_id'],
25 Site.fields['login_base'])
28 returns = Parameter(int, '1 if successful')
30 def call(self, auth, person_id_or_email, site_id_or_login_base):
31 # Get account information
32 persons = Persons(self.api, [person_id_or_email])
34 raise PLCInvalidArgument, "No such account"
37 if person['peer_id'] is not None:
38 raise PLCInvalidArgument, "Not a local account"
40 # Get site information
41 sites = Sites(self.api, [site_id_or_login_base])
43 raise PLCInvalidArgument, "No such site"
46 if site['peer_id'] is not None:
47 raise PLCInvalidArgument, "Not a local site"
49 if site['site_id'] in person['site_ids']:
50 site.remove_person(person)
53 self.event_objects = {'Site': [site['site_id']],
54 'Person': [person['person_id']]}
55 self.message = 'Person %d deleted from site %d ' % \
56 (person['person_id'], site['site_id'])