Ejemplo n.º 1
0
    def post(self, project_pk):
        """
        Move Ticket
        :param project_pk: Project ID
        :return:
        """
        get_project_request(project_pk)
        data = request.get_json(silent=True)
        if not data:
            raise api_errors.InvalidAPIUsage(api_errors.INVALID_JSON_BODY_MSG)

        source = data.get('source')
        destiny = data.get('dest')

        if not source or not destiny:
            raise api_errors.InvalidAPIUsage(payload={
                'source': api_errors.REQUIRED_MSG,
                'dest': api_errors.REQUIRED_MSG
            })

        remove_from_sprint = False
        sprint_id = None
        ticket_id = None

        if source.get('project_id'):
            sprint_id = destiny.get('sprint_id')
            ticket_id = source.get('ticket_id')
        elif source.get('sprint_id') and destiny.get('sprint_id'):
            sprint_id = destiny.get('sprint_id')
            ticket_id = source.get('ticket_id')
        elif source.get('sprint_id') and destiny.get('project_id'):
            sprint_id = source.get('sprint_id')
            ticket_id = source.get('ticket_id')
            remove_from_sprint = True

        sprint = get_sprint_request(sprint_id)
        ticket = get_ticket_request(ticket_id)

        if remove_from_sprint:
            SprintTicketOrder.inactivate_spo(sprint, ticket)
            Ticket.order_items(destiny.get('order'))
        else:
            SprintTicketOrder.inactivate_spo(sprint, ticket)

            tkt_ord_sprint = SprintTicketOrder()
            tkt_ord_sprint.sprint = sprint
            tkt_ord_sprint.ticket = ticket
            tkt_ord_sprint.ticket_repr = ticket.to_dict()
            tkt_ord_sprint.save()

            SprintTicketOrder.order_items(destiny.get('order'), sprint)

        # save activity
        save_notification(project_pk=project_pk,
                          verb='ticket_movement',
                          data=data)

        return data, 200
Ejemplo n.º 2
0
    def post(self, project_pk):
        """
        Update Order
        """
        get_project_request(project_pk)
        data = request.get_json(silent=True)
        if not data:
            raise api_errors.InvalidAPIUsage(api_errors.INVALID_JSON_BODY_MSG)

        Ticket.order_items(data)

        # save activity
        save_notification(project_pk=project_pk,
                          verb='backlog_order',
                          data=data)

        return data, 200