Beispiel #1
0
 def admin_user(self):
     role = Role()
     role.role_id = 1
     role.name = 'Admin'
     user = User()
     user.username = '******'
     user.auth_system = 'builtin'
     user.roles = [role]
     self.admin_jwt = generate_jwt_token(user, 'builtin')
     return user
Beispiel #2
0
def _add_default_roles():
    roles = {'Admin': '#BD0000', 'NOC': '#5B5BFF', 'User': '******'}

    for name, color in roles.items():
        if not Role.get(name):
            role = Role()
            role.name = name
            role.color = color
            db.session.add(role)
            logger.info('Added standard role {} ({})'.format(name, color))
Beispiel #3
0
    def post(self):
        """Create a new role"""
        self.reqparse.add_argument('name', type=str, required=True)
        self.reqparse.add_argument('color', type=str, required=True)
        args = self.reqparse.parse_args()
        AuditLog.log('role.create', session['user'].username, args)

        role = Role()
        role.name = args['name']
        role.color = args['color']

        db.session.add(role)
        db.session.commit()

        return self.make_response(
            'Role {} has been created'.format(role.role_id), HTTP.CREATED)