Example #1
0
 def post(self, username):
     """disable user account"""
     utils.check_user_enabled()
     utils.validate_permissions(
         required_permission=UserRolesEnum.user_all.value)
     qh.enable_user(username, False)
     return {}, 200
Example #2
0
 def delete(self, role):
     """Delete a user role"""
     utils.check_user_enabled()
     utils.validate_permissions(
         required_permission=UserRolesEnum.role.value)
     qh.delete_user_role(role)
     return {}, 200
Example #3
0
 def get(self, username, name):
     """Get user timezone by id"""
     utils.check_user_enabled()
     utils.validate_permissions(
         required_permission=UserRolesEnum.record_all.value,
         username=username)
     return qh.get_user_timezone(username, name)
Example #4
0
 def delete(self, username, name):
     """Delete user timezone"""
     utils.check_user_enabled()
     utils.validate_permissions(
         required_permission=UserRolesEnum.record_all.value,
         username=username)
     qh.delete_user_timezone(username, name)
     return {}, 200
Example #5
0
 def get(self):
     """Get all user roles"""
     utils.check_user_enabled()
     utils.validate_permissions(
         required_permission=UserRolesEnum.role.value)
     roles = qh.get_user_roles()
     if not roles["data"]:
         return {}, 404
     return roles
Example #6
0
 def get(self, username):
     """Get all timezones for a user"""
     utils.check_user_enabled()
     utils.validate_permissions(
         required_permission=UserRolesEnum.record_all.value,
         username=username)
     data = qh.get_user_timezone_all(username)
     if not data["data"]:
         return {}, 404
     return data
Example #7
0
 def get(self, role):
     """Get user role"""
     utils.check_user_enabled()
     utils.validate_permissions(
         required_permission=UserRolesEnum.role.value)
     user_role = qh.get_user_role(role)
     if not user_role:
         return {}, 404
     else:
         return user_role
Example #8
0
 def post(self):
     """Creates a new user role"""
     utils.check_user_enabled()
     utils.validate_permissions(
         required_permission=UserRolesEnum.role.value)
     args = request.get_json(force=True)
     try:
         return qh.create_user_role(role=args['role'],
                                    permissions=args['permissions'])
     except KeyError:
         raise ValueError('missing required input parameter')
Example #9
0
 def post(self, username):
     """Creates a new timezone for a user"""
     utils.check_user_enabled()
     utils.validate_permissions(
         required_permission=UserRolesEnum.record_all.value,
         username=username)
     args = request.get_json(force=True)
     try:
         return qh.create_user_timezone(username,
                                        name=args['name'],
                                        timezone_id=args['timezone_id'])
     except KeyError:
         raise ValueError('missing required input parameter')
Example #10
0
    def put(self, username, name):
        """Update user timezone"""
        utils.check_user_enabled()
        utils.validate_permissions(
            required_permission=UserRolesEnum.record_all.value,
            username=username)
        args = request.get_json(force=True)

        update = {}
        for key in ['name', 'timezone_id']:
            try:
                val = args[key]
                if not val:
                    raise ValueError('invalid input')
                update[key] = val
            except KeyError:
                pass

        if not update:
            return {}, 200

        qh.update_user_timezone(username, tz_name=name, **update)
        return {}, 200