예제 #1
0
파일: views_tasks_api.py 프로젝트: quru/qis
            raise ParameterError(function_name + " task is not yet supported")

    @add_parameter_error_handler
    def _get_validated_parameters(self, function_name, data_dict):
        # Get the API / URL parameters
        if function_name == "purge_system_stats" or function_name == "purge_image_stats":
            # Purge to date
            params = {"before_time": parse_iso_date(data_dict["date_to"])}
        elif function_name == "purge_deleted_folder_data":
            # Purge folder path
            params = {"path": data_dict["path"].strip()}
            validate_string(params["path"], 0, 1024)
        else:
            raise ParameterError(function_name + " task is not yet supported")
        return params


# Add URL routing and minimum required system permissions

_tapi_task_views = api_permission_required(TaskAPI.as_view("admin.task"))
api_add_url_rules(
    [url_version_prefix + "/admin/tasks/<int:task_id>/", "/admin/tasks/<int:task_id>/"],
    view_func=_tapi_task_views,
    methods=["GET"],
)
api_add_url_rules(
    [url_version_prefix + "/admin/tasks/<function_name>/", "/admin/tasks/<function_name>/"],
    view_func=_tapi_task_views,
    methods=["POST"],
)
예제 #2
0
파일: views_data_api.py 프로젝트: quru/qis
                data_engine.save_object(original_object)
                permissions_engine.reset()
                # Raise API error
                who = 'the \'admin\' user' if user_id == 1 else 'you'
                raise ParameterError(
                    'This change would lock %s out of administration' % who
                )


# Add URL routing and minimum required system permissions
#          (some classes add further permission checking)

_dapi_image_views = api_permission_required(ImageAPI.as_view('admin.image'))
api_add_url_rules(
    [url_version_prefix + '/admin/images/<int:image_id>/',
     '/admin/images/<int:image_id>/'],
    view_func=_dapi_image_views,
    methods=['GET', 'PUT']
)

_dapi_user_views = _user_api_permission_required(UserAPI.as_view('admin.user'))
api_add_url_rules(
    [url_version_prefix + '/admin/users/',
     '/admin/users/'],
    view_func=_dapi_user_views,
    methods=['GET', 'POST']
)
api_add_url_rules(
    [url_version_prefix + '/admin/users/<int:user_id>/',
     '/admin/users/<int:user_id>/'],
    view_func=_dapi_user_views,
    methods=['GET', 'PUT', 'DELETE']