action.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:cerberus-core 作者: ovh 项目源码 文件源码
def apply_action(ticket_id=None, action_id=None, ip_addr=None, user_id=None):
    """
        Apply given action on customer service

        :param int ticket_id: The id of the Cerberus `Ticket`
        :param int action_id: The id of the Cerberus `ServiceAction`
        :param int user_id: The id of the Cerberus `User`
        :rtype: bool
        :return: if action has been applied
    """
    current_job = get_current_job()

    ticket = Ticket.objects.get(id=ticket_id)
    user = User.objects.get(id=user_id)

    if ticket.status in ('Closed', 'Answered'):
        _cancel_by_status(ticket)
        common.set_ticket_status(
            ticket,
            'ActionError',
            user=user
        )
        return False

    # Call action service
    try:
        result = implementations.instance.get_singleton_of(
            'ActionServiceBase'
        ).apply_action_on_service(
            ticket_id,
            action_id,
            ip_addr,
            user.id
        )
        _update_job(
            current_job.id,
            todo_id=result.todo_id,
            status=result.status,
            comment=result.comment
        )
        return True
    except ActionServiceException as ex:
        _update_job(current_job.id, status='actionError', comment=str(ex))
        common.set_ticket_status(
            ticket,
            'ActionError',
            user=user
        )
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号