コード例 #1
0
    def delete(self, id):
        """Archive this board.

        :param id: The ID of the board to be archived.

        """
        board = boards_api.get(id)
        user_id = request.current_user_id
        if not boards_api.editable(board, user_id):
            raise exc.NotFound(_("Board %s not found") % id)

        # We use copy here because we only need to check changes
        # to the related objects, just the board's own attributes.
        # Also, deepcopy trips up on the lanes' backrefs.
        original = copy.copy(board)
        updated = boards_api.update(id, {"archived": True})

        post_timeline_events(original, updated)

        for lane in board.lanes:
            original = copy.deepcopy(worklists_api.get(lane.worklist.id))
            worklists_api.update(lane.worklist.id, {"archived": True})

            if not original.archived:
                events_api.worklist_details_changed_event(
                    lane.worklist.id, user_id, 'archived', original.archived,
                    True)
コード例 #2
0
ファイル: boards.py プロジェクト: openstack-infra/storyboard
    def delete(self, id):
        """Archive this board.

        :param id: The ID of the board to be archived.

        """
        board = boards_api.get(id)
        user_id = request.current_user_id
        if not boards_api.editable(board, user_id):
            raise exc.NotFound(_("Board %s not found") % id)

        # We use copy here because we only need to check changes
        # to the related objects, just the board's own attributes.
        # Also, deepcopy trips up on the lanes' backrefs.
        original = copy.copy(board)
        updated = boards_api.update(id, {"archived": True})

        post_timeline_events(original, updated)

        for lane in board.lanes:
            original = copy.deepcopy(worklists_api.get(lane.worklist.id))
            worklists_api.update(lane.worklist.id, {"archived": True})

            if not original.archived:
                events_api.worklist_details_changed_event(
                    lane.worklist.id, user_id, 'archived', original.archived,
                    True)
コード例 #3
0
ファイル: worklists.py プロジェクト: ColdrickSotK/storyboard
    def delete(self, worklist_id):
        """Archive this worklist.

        :param worklist_id: The ID of the worklist to be archived.

        """
        worklist = worklists_api.get(worklist_id)
        user_id = request.current_user_id
        if not worklists_api.editable(worklist, user_id):
            raise exc.NotFound(_("Worklist %s not found") % worklist_id)

        worklists_api.update(worklist_id, {"archived": True})
コード例 #4
0
ファイル: worklists.py プロジェクト: palvarez89/storyboard
    def delete(self, worklist_id):
        """Archive this worklist.

        :param worklist_id: The ID of the worklist to be archived.

        """
        worklist = worklists_api.get(worklist_id)
        user_id = request.current_user_id
        if not worklists_api.editable(worklist, user_id):
            raise exc.NotFound(_("Worklist %s not found") % worklist_id)

        worklists_api.update(worklist_id, {"archived": True})
コード例 #5
0
ファイル: boards.py プロジェクト: palvarez89/storyboard
    def delete(self, id):
        """Archive this board.

        :param id: The ID of the board to be archived.

        """
        board = boards_api.get(id)
        user_id = request.current_user_id
        if not boards_api.editable(board, user_id):
            raise exc.NotFound(_("Board %s not found") % id)

        boards_api.update(id, {"archived": True})

        for lane in board.lanes:
            worklists_api.update(lane.worklist.id, {"archived": True})
コード例 #6
0
ファイル: boards.py プロジェクト: palvarez89/storyboard
    def delete(self, id):
        """Archive this board.

        :param id: The ID of the board to be archived.

        """
        board = boards_api.get(id)
        user_id = request.current_user_id
        if not boards_api.editable(board, user_id):
            raise exc.NotFound(_("Board %s not found") % id)

        boards_api.update(id, {"archived": True})

        for lane in board.lanes:
            worklists_api.update(lane.worklist.id, {"archived": True})
コード例 #7
0
ファイル: worklists.py プロジェクト: ColdrickSotK/storyboard
    def put(self, id, worklist):
        """Modify this worklist.

        :param id: The ID of the worklist.
        :param worklist: A worklist within the request body.

        """
        user_id = request.current_user_id
        if not worklists_api.editable(worklists_api.get(id), user_id):
            raise exc.NotFound(_("Worklist %s not found") % id)

        # We don't use this endpoint to update the worklist's contents
        if worklist.items != wtypes.Unset:
            del worklist.items

        # We don't use this endpoint to update the worklist's filters either
        if worklist.filters != wtypes.Unset:
            del worklist.filters

        worklist_dict = worklist.as_dict(omit_unset=True)

        updated_worklist = worklists_api.update(id, worklist_dict)

        if worklists_api.visible(updated_worklist, user_id):
            worklist_model = wmodels.Worklist.from_db_model(updated_worklist)
            worklist_model.resolve_items(updated_worklist)
            worklist_model.resolve_permissions(updated_worklist)
            return worklist_model
        else:
            raise exc.NotFound(_("Worklist %s not found"))
コード例 #8
0
ファイル: worklists.py プロジェクト: palvarez89/storyboard
    def put(self, id, worklist):
        """Modify this worklist.

        :param id: The ID of the worklist.
        :param worklist: A worklist within the request body.

        """
        user_id = request.current_user_id
        if not worklists_api.editable(worklists_api.get(id), user_id):
            raise exc.NotFound(_("Worklist %s not found") % id)

        # We don't use this endpoint to update the worklist's contents
        if worklist.items != wtypes.Unset:
            del worklist.items

        # We don't use this endpoint to update the worklist's filters either
        if worklist.filters != wtypes.Unset:
            del worklist.filters

        worklist_dict = worklist.as_dict(omit_unset=True)

        updated_worklist = worklists_api.update(id, worklist_dict)

        if worklists_api.visible(updated_worklist, user_id):
            worklist_model = wmodels.Worklist.from_db_model(updated_worklist)
            worklist_model.resolve_items(updated_worklist)
            worklist_model.resolve_permissions(updated_worklist)
            return worklist_model
        else:
            raise exc.NotFound(_("Worklist %s not found"))
コード例 #9
0
    def put(self, id, worklist):
        """Modify this worklist.

        Example::

          TODO

        :param id: The ID of the worklist.
        :param worklist: A worklist within the request body.

        """
        user_id = request.current_user_id
        if not worklists_api.editable(worklists_api.get(id), user_id):
            raise exc.NotFound(_("Worklist %s not found") % id)

        story_cache = {
            story.id: story
            for story in stories_api.story_get_all(worklist_id=id,
                                                   current_user=user_id)
        }
        task_cache = {
            task.id: task
            for task in tasks_api.task_get_all(worklist_id=id,
                                               current_user=user_id)
        }

        # We don't use this endpoint to update the worklist's contents
        if worklist.items != wtypes.Unset:
            del worklist.items

        # We don't use this endpoint to update the worklist's filters either
        if worklist.filters != wtypes.Unset:
            del worklist.filters

        worklist_dict = worklist.as_dict(omit_unset=True)

        original = copy.deepcopy(worklists_api.get(id))
        updated_worklist = worklists_api.update(id, worklist_dict)

        post_timeline_events(original, updated_worklist)
        if worklists_api.visible(updated_worklist, user_id):
            worklist_model = wmodels.Worklist.from_db_model(updated_worklist)
            worklist_model.resolve_items(updated_worklist, story_cache,
                                         task_cache)
            worklist_model.resolve_permissions(updated_worklist)
            return worklist_model
        else:
            raise exc.NotFound(_("Worklist %s not found"))
コード例 #10
0
    def put(self, id, worklist):
        """Modify this worklist.

        Example::

          TODO

        :param id: The ID of the worklist.
        :param worklist: A worklist within the request body.

        """
        user_id = request.current_user_id
        if not worklists_api.editable(worklists_api.get(id), user_id):
            raise exc.NotFound(_("Worklist %s not found") % id)

        story_cache = {story.id: story for story in stories_api.story_get_all(
                       worklist_id=id, current_user=user_id)}
        task_cache = {task.id: task for task in tasks_api.task_get_all(
                      worklist_id=id, current_user=user_id)}

        # We don't use this endpoint to update the worklist's contents
        if worklist.items != wtypes.Unset:
            del worklist.items

        # We don't use this endpoint to update the worklist's filters either
        if worklist.filters != wtypes.Unset:
            del worklist.filters

        worklist_dict = worklist.as_dict(omit_unset=True)

        original = copy.deepcopy(worklists_api.get(id))
        updated_worklist = worklists_api.update(id, worklist_dict)

        post_timeline_events(original, updated_worklist)
        if worklists_api.visible(updated_worklist, user_id):
            worklist_model = wmodels.Worklist.from_db_model(updated_worklist)
            worklist_model.resolve_items(
                updated_worklist, story_cache, task_cache)
            worklist_model.resolve_permissions(updated_worklist)
            return worklist_model
        else:
            raise exc.NotFound(_("Worklist %s not found"))
コード例 #11
0
    def delete(self, worklist_id):
        """Archive this worklist.
           Though this uses the DELETE command, the worklist is not deleted.
           Archived worklists remain viewable at the designated URL, but
           are not returned in search results nor appear on your dashboard.

        Example::

          curl https://my.example.org/api/v1/worklists/30 -X DELETE \\
          -H 'Authorization: Bearer MY_ACCESS_TOKEN'

        :param worklist_id: The ID of the worklist to be archived.

        """
        worklist = worklists_api.get(worklist_id)
        original = copy.deepcopy(worklist)
        user_id = request.current_user_id
        if not worklists_api.editable(worklist, user_id):
            raise exc.NotFound(_("Worklist %s not found") % worklist_id)

        updated = worklists_api.update(worklist_id, {"archived": True})

        post_timeline_events(original, updated)
コード例 #12
0
    def delete(self, worklist_id):
        """Archive this worklist.
           Though this uses the DELETE command, the worklist is not deleted.
           Archived worklists remain viewable at the designated URL, but
           are not returned in search results nor appear on your dashboard.

        Example::

          curl https://my.example.org/api/v1/worklists/30 -X DELETE \\
          -H 'Authorization: Bearer MY_ACCESS_TOKEN'

        :param worklist_id: The ID of the worklist to be archived.

        """
        worklist = worklists_api.get(worklist_id)
        original = copy.deepcopy(worklist)
        user_id = request.current_user_id
        if not worklists_api.editable(worklist, user_id):
            raise exc.NotFound(_("Worklist %s not found") % worklist_id)

        updated = worklists_api.update(worklist_id, {"archived": True})

        post_timeline_events(original, updated)