예제 #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')