示例#1
0
def remove_role(login, role):
    """[-login] LOGIN [-role] ROLE_NAME
    Remove a role from the user
    """
    from main import db
    from bundles.users.models import User

    user = User.by_login(login)
    if not user:
        print 'User `%s` not found.' % login.encode('utf8')
        return
    user.remove_role(role)
    db.commit()
    print 'User `%s` no longer has the `%s` role.' % (login.encode('utf8'),
                                                      role.encode('utf8'))
示例#2
0
def add_role(login, role):
    """[-login] LOGIN [-role] ROLE_NAME
    Adds a role to the user
    """
    from main import db
    from bundles.users.models import User

    user = User.by_login(login)
    if not user:
        print 'User `%s` not found.' % login.encode('utf8')
        return
    user.add_role(role)
    db.commit()
    print 'User `%s` has now the `%s` role.' % (login.encode('utf8'),
                                                role.encode('utf8'))
示例#3
0
def update_user(login, **data):
    """[-login] LOGIN [key=value, ...]
    Changes the password of an existing user."""
    from main import db
    from bundles.users.models import User

    user = User.by_login(login)
    if not user:
        print 'User `%s` not found.' % login.encode('utf8')
        return

    for key, val in data.items():
        setattr(user, key, val)
    db.commit()
    print 'User `%s` updated.' % login.encode('utf8')
示例#4
0
文件: manage.py 项目: lucuma/Shake
def remove_role(login, role):
    """[-login] LOGIN [-role] ROLE_NAME
    Remove a role from the user
    """
    from main import db
    from bundles.users.models import User

    user = User.by_login(login)
    if not user:
        print 'User `%s` not found.' % login.encode('utf8')
        return
    user.remove_role(role)
    db.commit()
    print 'User `%s` no longer has the `%s` role.' % (
        login.encode('utf8'), role.encode('utf8'))
示例#5
0
文件: manage.py 项目: lucuma/Shake
def add_role(login, role):
    """[-login] LOGIN [-role] ROLE_NAME
    Adds a role to the user
    """
    from main import db
    from bundles.users.models import User

    user = User.by_login(login)
    if not user:
        print 'User `%s` not found.' % login.encode('utf8')
        return
    user.add_role(role)
    db.commit()
    print 'User `%s` has now the `%s` role.' % (
        login.encode('utf8'), role.encode('utf8'))
示例#6
0
文件: manage.py 项目: lucuma/Shake
def update_user(login, **data):
    """[-login] LOGIN [key=value, ...]
    Changes the password of an existing user."""
    from main import db
    from bundles.users.models import User

    user = User.by_login(login)
    if not user:
        print 'User `%s` not found.' % login.encode('utf8')
        return

    for key, val in data.items():
        setattr(user, key, val)
    db.commit()
    print 'User `%s` updated.' % login.encode('utf8')