Beispiel #1
0
    def post(self, request):
        """
        post:
        Post actions

        Perform an action with the selected items from a specific view.
        """
        pk = int_from_request(request.GET, "project", None)
        project = get_object_with_check_and_log(request, Project, pk=pk)
        self.check_object_permissions(request, project)

        queryset = get_prepared_queryset(request, project)

        # no selected items on tab
        if not queryset.exists():
            response = {'detail': 'No selected items for specified view'}
            return Response(response, status=404)

        # wrong action id
        action_id = request.GET.get('id', None)
        if action_id is None:
            response = {
                'detail':
                'No action id "' + str(action_id) + '", use ?id=<action-id>'
            }
            return Response(response, status=422)

        # perform action and return the result dict
        kwargs = {'request': request}  # pass advanced params to actions
        result = perform_action(action_id, project, queryset, **kwargs)
        code = result.pop('response_code', 200)

        return Response(result, status=code)
Beispiel #2
0
    def post(self, request):
        pk = int_from_request(request.GET, "project", None)
        project = get_object_with_check_and_log(request, Project, pk=pk)
        self.check_object_permissions(request, project)

        queryset = get_prepared_queryset(request, project)

        # wrong action id
        action_id = request.GET.get('id', None)
        if action_id is None:
            response = {'detail': 'No action id "' + str(action_id) + '", use ?id=<action-id>'}
            return Response(response, status=422)

        # perform action and return the result dict
        kwargs = {'request': request}  # pass advanced params to actions
        result = perform_action(action_id, project, queryset, request.user, **kwargs)
        code = result.pop('response_code', 200)

        return Response(result, status=code)