-def testOwner(user, owner, machine=None):
- if not getafsgroups.checkLockerOwner(user.username, owner):
- raise InvalidInput('owner', owner,
- "Invalid")
- return owner
+def testAdmin(user, admin, machine):
+ if admin in (None, machine.administrator):
+ return None
+ if admin == user.username:
+ return admin
+ if getafsgroups.checkAfsGroup(user.username, admin, 'athena.mit.edu'):
+ return admin
+ if getafsgroups.checkAfsGroup(user.username, 'system:'+admin, 'athena.mit.edu'):
+ return 'system:'+admin
+ raise InvalidInput('admin', admin,
+ 'You must control the group you move it to')
+
+def testOwner(user, owner, machine):
+ if owner in (None, machine.owner):
+ return None
+ #XXX should you be able to transfer ownership if you don't already own it?
+ #if not owns(user, machine):
+ # raise InvalidInput('owner', owner, "You don't own this machine, so you can't transfer ownership")
+ value = getafsgroups.checkLockerOwner(user.username, owner, verbose=True)
+ if value == True:
+ return owner
+ raise InvalidInput('owner', owner, value)