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'))
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'))
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')
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'))
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'))