Ignore:
Timestamp:
Oct 28, 2007, 11:57:32 PM (17 years ago)
Author:
ecprice
Message:

Remove the useless User class (now user is a string)
Allow creation under another owner.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/templates/validation.py

    r211 r228  
    2525        owner = machine.owner
    2626    else:
    27         owner = user.username
     27        owner = user
    2828    return Machine.select_by(owner=owner)
    2929
     
    6969def haveAccess(user, machine):
    7070    """Return whether a user has adminstrative access to a machine"""
    71     if user.username == 'moo':
    72         return True
    73     if user.username in (machine.administrator, machine.owner):
    74         return True
    75     if getafsgroups.checkAfsGroup(user.username, machine.administrator,
     71    if user == 'moo':
     72        return True
     73    if user in (machine.administrator, machine.owner):
     74        return True
     75    if getafsgroups.checkAfsGroup(user, machine.administrator,
    7676                                  'athena.mit.edu'): #XXX Cell?
    7777        return True
    78     if getafsgroups.checkLockerOwner(user.username, machine.owner):
     78    if getafsgroups.checkLockerOwner(user, machine.owner):
    7979        return True
    8080    return owns(user, machine)
     
    8282def owns(user, machine):
    8383    """Return whether a user owns a machine"""
    84     if user.username == 'moo':
    85         return True
    86     return getafsgroups.checkLockerOwner(user.username, machine.owner)
     84    if user == 'moo':
     85        return True
     86    return getafsgroups.checkLockerOwner(user, machine.owner)
    8787
    8888def validMachineName(name):
     
    154154    if admin in (None, machine.administrator):
    155155        return None
    156     if admin == user.username:
     156    if admin == user:
    157157        return admin
    158     if getafsgroups.checkAfsGroup(user.username, admin, 'athena.mit.edu'):
     158    if getafsgroups.checkAfsGroup(user, admin, 'athena.mit.edu'):
    159159        return admin
    160     if getafsgroups.checkAfsGroup(user.username, 'system:'+admin,
     160    if getafsgroups.checkAfsGroup(user, 'system:'+admin,
    161161                                  'athena.mit.edu'):
    162162        return 'system:'+admin
    163163    return admin
    164164   
    165 def testOwner(user, owner, machine):
    166     if owner in (None, machine.owner):
    167         return None
    168     value = getafsgroups.checkLockerOwner(user.username, owner, verbose=True)
     165def testOwner(user, owner, machine=None):
     166    if owner == user or machine is not None and owner == machine.owner:
     167        return owner
     168    if owner is None:
     169        raise InvalidInput('owner', owner, "Owner must be specified")
     170    value = getafsgroups.checkLockerOwner(user, owner, verbose=True)
    169171    if not value:
    170172        return owner
Note: See TracChangeset for help on using the changeset viewer.