示例#1
0
    def add_role(name):
        """Add New Role"""
        r = Role()
        r.name = name
        r.save()

        print(f'{r.name} | added.')
示例#2
0
 def test_roles(self):
     """Add a role to a user."""
     role = Role(name="admin")
     role.save()
     user = UserFactory()
     user.roles.append(role)
     user.save()
     assert role in user.roles
示例#3
0
def add_role(name):
    """ Add New User Role """
    try:
        r = Role()
        r.set_name(name)
        r.description = 'Default Description'
        r.save()
    except Exception as exp:
        print(exp)
    else:
        print(r.__repr__())
        del r