Example #1
0
def update_lanes(board_dict, board_id):
    if 'lanes' not in board_dict:
        return
    board = boards_api.get(board_id)
    new_list_ids = [lane.list_id for lane in board_dict['lanes']]
    existing_list_ids = [lane.list_id for lane in board.lanes]
    for lane in board.lanes:
        if lane.list_id in new_list_ids:
            new_lane = get_lane(lane.list_id, board_dict)
            if lane.position != new_lane.position:
                del new_lane.worklist
                original = copy.deepcopy(lane)
                boards_api.update_lane(
                    board, lane, new_lane.as_dict(omit_unset=True))
                updated = {
                    "old": serialize_lane(original),
                    "new": serialize_lane(new_lane)
                }

                events_api.board_lanes_changed_event(board_id,
                                                     request.current_user_id,
                                                     updated=updated)

    for lane in board_dict['lanes']:
        if lane.list_id not in existing_list_ids:
            del lane.worklist
            boards_api.add_lane(board, lane.as_dict(omit_unset=True))
            events_api.board_lanes_changed_event(board_id,
                                                 request.current_user_id,
                                                 added=serialize_lane(lane))

    board = boards_api.get(board_id)
    del board_dict['lanes']
Example #2
0
def update_lanes(board_dict, board_id):
    if 'lanes' not in board_dict:
        return
    board = boards_api.get(board_id)
    new_list_ids = [lane.list_id for lane in board_dict['lanes']]
    existing_list_ids = [lane.list_id for lane in board.lanes]
    for lane in board.lanes:
        if lane.list_id in new_list_ids:
            new_lane = get_lane(lane.list_id, board_dict)
            if lane.position != new_lane.position:
                del new_lane.worklist
                original = copy.deepcopy(lane)
                boards_api.update_lane(board, lane,
                                       new_lane.as_dict(omit_unset=True))
                updated = {
                    "old": serialize_lane(original),
                    "new": serialize_lane(new_lane)
                }

                events_api.board_lanes_changed_event(board_id,
                                                     request.current_user_id,
                                                     updated=updated)

    for lane in board_dict['lanes']:
        if lane.list_id not in existing_list_ids:
            lane.worklist = None
            boards_api.add_lane(board, lane.as_dict(omit_unset=True))
            events_api.board_lanes_changed_event(board_id,
                                                 request.current_user_id,
                                                 added=serialize_lane(lane))

    board = boards_api.get(board_id)
    del board_dict['lanes']
Example #3
0
    def post(self, board):
        """Create a new board.

        :param board: A board within the request body.

        """
        board_dict = board.as_dict()
        user_id = request.current_user_id

        if board.creator_id and board.creator_id != user_id:
            abort(400, _("You can't select the creator of a board."))
        board_dict.update({"creator_id": user_id})
        lanes = board_dict.pop('lanes') or []
        owners = board_dict.pop('owners')
        users = board_dict.pop('users')
        if not owners:
            owners = [user_id]
        if not users:
            users = []

        # We can't set due dates when creating boards at the moment.
        if 'due_dates' in board_dict:
            del board_dict['due_dates']

        created_board = boards_api.create(board_dict)
        events_api.board_created_event(created_board.id, user_id,
                                       created_board.title,
                                       created_board.description)
        for lane in lanes:
            del lane.worklist
            boards_api.add_lane(created_board, lane.as_dict(omit_unset=True))
            events_api.board_lanes_changed_event(created_board.id,
                                                 user_id,
                                                 added=serialize_lane(lane))

        edit_permission = {
            'name': 'edit_board_%d' % created_board.id,
            'codename': 'edit_board',
            'users': owners
        }
        move_permission = {
            'name': 'move_cards_%d' % created_board.id,
            'codename': 'move_cards',
            'users': users
        }
        edit = boards_api.create_permission(created_board.id, edit_permission)
        move = boards_api.create_permission(created_board.id, move_permission)
        event_owners = [{
            id: users_api.user_get(id).full_name
        } for id in owners]
        event_users = [{id: users_api.user_get(id).full_name} for id in users]
        events_api.board_permission_created_event(created_board.id, user_id,
                                                  edit.id, edit.codename,
                                                  event_owners)
        events_api.board_permission_created_event(created_board.id, user_id,
                                                  move.id, move.codename,
                                                  event_users)

        return wmodels.Board.from_db_model(created_board)
Example #4
0
    def post(self, board):
        """Create a new board.

        :param board: A board within the request body.

        """
        board_dict = board.as_dict()
        user_id = request.current_user_id

        if board.creator_id and board.creator_id != user_id:
            abort(400, _("You can't select the creator of a board."))
        board_dict.update({"creator_id": user_id})
        lanes = board_dict.pop('lanes')
        owners = board_dict.pop('owners')
        users = board_dict.pop('users')
        if not owners:
            owners = [user_id]
        if not users:
            users = []

        # We can't set due dates when creating boards at the moment.
        if 'due_dates' in board_dict:
            del board_dict['due_dates']

        created_board = boards_api.create(board_dict)
        for lane in lanes:
            boards_api.add_lane(created_board, lane.as_dict())

        edit_permission = {
            'name': 'edit_board_%d' % created_board.id,
            'codename': 'edit_board',
            'users': owners
        }
        move_permission = {
            'name': 'move_cards_%d' % created_board.id,
            'codename': 'move_cards',
            'users': users
        }
        boards_api.create_permission(created_board.id, edit_permission)
        boards_api.create_permission(created_board.id, move_permission)

        return wmodels.Board.from_db_model(created_board)
Example #5
0
    def post(self, board):
        """Create a new board.

        :param board: A board within the request body.

        """
        board_dict = board.as_dict()
        user_id = request.current_user_id

        if board.creator_id and board.creator_id != user_id:
            abort(400, _("You can't select the creator of a board."))
        board_dict.update({"creator_id": user_id})
        lanes = board_dict.pop('lanes')
        owners = board_dict.pop('owners')
        users = board_dict.pop('users')
        if not owners:
            owners = [user_id]
        if not users:
            users = []

        # We can't set due dates when creating boards at the moment.
        if 'due_dates' in board_dict:
            del board_dict['due_dates']

        created_board = boards_api.create(board_dict)
        for lane in lanes:
            boards_api.add_lane(created_board, lane.as_dict())

        edit_permission = {
            'name': 'edit_board_%d' % created_board.id,
            'codename': 'edit_board',
            'users': owners
        }
        move_permission = {
            'name': 'move_cards_%d' % created_board.id,
            'codename': 'move_cards',
            'users': users
        }
        boards_api.create_permission(created_board.id, edit_permission)
        boards_api.create_permission(created_board.id, move_permission)

        return wmodels.Board.from_db_model(created_board)
Example #6
0
def update_lanes(board_dict, board_id):
    if 'lanes' not in board_dict:
        return
    board = boards_api.get(board_id)
    new_list_ids = [lane.list_id for lane in board_dict['lanes']]
    existing_list_ids = [lane.list_id for lane in board.lanes]
    for lane in board.lanes:
        if lane.list_id in new_list_ids:
            new_lane = get_lane(lane.list_id, board_dict)
            if lane.position != new_lane.position:
                del new_lane.worklist
                boards_api.update_lane(
                    board, lane, new_lane.as_dict(omit_unset=True))
    for lane in board_dict['lanes']:
        if lane.list_id not in existing_list_ids:
            lane.worklist = None
            boards_api.add_lane(board, lane.as_dict(omit_unset=True))

    board = boards_api.get(board_id)
    del board_dict['lanes']
Example #7
0
def update_lanes(board_dict, board_id):
    if 'lanes' not in board_dict:
        return
    board = boards_api.get(board_id)
    new_list_ids = [lane.list_id for lane in board_dict['lanes']]
    existing_list_ids = [lane.list_id for lane in board.lanes]
    for lane in board.lanes:
        if lane.list_id in new_list_ids:
            new_lane = get_lane(lane.list_id, board_dict)
            if lane.position != new_lane.position:
                del new_lane.worklist
                boards_api.update_lane(board, lane,
                                       new_lane.as_dict(omit_unset=True))
    for lane in board_dict['lanes']:
        if lane.list_id not in existing_list_ids:
            lane.worklist = None
            boards_api.add_lane(board, lane.as_dict(omit_unset=True))

    board = boards_api.get(board_id)
    del board_dict['lanes']
Example #8
0
    def post(self, board):
        """Create a new board.

        :param board: A board within the request body.

        """
        board_dict = board.as_dict()
        user_id = request.current_user_id

        if board.creator_id and board.creator_id != user_id:
            abort(400, _("You can't select the creator of a board."))
        board_dict.update({"creator_id": user_id})
        lanes = board_dict.pop('lanes') or []
        owners = board_dict.pop('owners')
        users = board_dict.pop('users')
        if not owners:
            owners = [user_id]
        if not users:
            users = []

        # We can't set due dates when creating boards at the moment.
        if 'due_dates' in board_dict:
            del board_dict['due_dates']

        created_board = boards_api.create(board_dict)
        events_api.board_created_event(created_board.id,
                                       user_id,
                                       created_board.title,
                                       created_board.description)
        for lane in lanes:
            del lane.worklist
            boards_api.add_lane(created_board, lane.as_dict(omit_unset=True))
            events_api.board_lanes_changed_event(created_board.id,
                                                 user_id,
                                                 added=serialize_lane(lane))

        edit_permission = {
            'name': 'edit_board_%d' % created_board.id,
            'codename': 'edit_board',
            'users': owners
        }
        move_permission = {
            'name': 'move_cards_%d' % created_board.id,
            'codename': 'move_cards',
            'users': users
        }
        edit = boards_api.create_permission(created_board.id, edit_permission)
        move = boards_api.create_permission(created_board.id, move_permission)
        event_owners = [{id: users_api.user_get(id).full_name}
                        for id in owners]
        event_users = [{id: users_api.user_get(id).full_name}
                       for id in users]
        events_api.board_permission_created_event(created_board.id,
                                                  user_id,
                                                  edit.id,
                                                  edit.codename,
                                                  event_owners)
        events_api.board_permission_created_event(created_board.id,
                                                  user_id,
                                                  move.id,
                                                  move.codename,
                                                  event_users)

        return wmodels.Board.from_db_model(created_board)