コード例 #1
0
ファイル: sites.py プロジェクト: aspc/piccolo
def adduser(args):
    logger.debug("add user " + args.username + " to " + args.shortname + " from console")
    thesite = Site.get(args.shortname)
    theuser = User.get(args.username)
    if not thesite:
        logger.error("No site named {0} exists".format(args.shortname))
    if not theuser:
        logger.error("No user named {0} exists".format(args.username))
    if thesite and theuser:
        try:
            thesite.addUser(theuser, suppress_welcome=args.no_email)
        except Site.AlreadyHasUser:
            logger.info("{0} is already an administrator of {1}".format(args.username, args.shortname))
        except ShellActionFailed:
            logger.exception("Could not create {0} because shell actions failed. See log for details.".format(args.username))
コード例 #2
0
ファイル: sites.py プロジェクト: aspc/piccolo
def removeuser(args):
    logger.debug("remove user" + args.username + " from " + args.shortname + " from console")
    thesite = Site.get(args.shortname)
    theuser = User.get(args.username)
    if not thesite:
        logger.error("No site named {0} exists".format(args.shortname))
    if not theuser:
        logger.error("No user named {0} exists".format(args.username))
    if thesite and theuser:
        try:
            thesite.removeUser(theuser)
        except Site.NoSuchUser:
            logger.info("User {0} is not an administrator of {1}".format(
                theuser.username,
                thesite.shortname
            ))
        except ShellActionFailed as e:
            logger.exception("Could not remove {0} from {1} because shell actions failed. User remains in Site in DB.".format(
                theuser.username,
                thesite.shortname,
            ))
コード例 #3
0
ファイル: users.py プロジェクト: aspc/piccolo
def create(args):
    logger.debug("create " + args.full_name + " as " + args.username + " from console")
    try:
        User.create(args.username, args.full_name, args.email, suppress_welcome=args.no_email, fake_create=args.fake_create)
    except User.BadName, why:
        logger.error(why)
コード例 #4
0
ファイル: users.py プロジェクト: aspc/piccolo
def delete(args):
    logger.debug("Delete {0}".format(args.username))
    try:
        User.delete(args.username)
    except User.DoesNotExist:
        logger.exception("There is no user named {0}".format(args.username))