コード例 #1
0
def get_event(event_id, with_records=True, with_name=True):
    event = inner.get_event(event_id)

    if not event:
        raise_user_exc(CS_EVENT_NOT_EXIST, event_id=event_id)

    event = event.to_dict()
    if with_records:
        records = get_records(event['id'], with_name=with_name)
        event['records'] = records

    return event
コード例 #2
0
def update_event(event_id, compensation=None, user_id=None, content=None):
    event = inner.get_event(event_id)

    if not event:
        raise_user_exc(CS_EVENT_NOT_EXIST, event_id=event_id)

    if compensation is not None:
        event.update(compensation=compensation)

    if user_id and content:
        inner.add_record(event_id, user_id, content, event.status)

    return True
コード例 #3
0
def process_event(event_id, status, handler_id=None):
    if status is None:
        return False

    if status == CSEvent.STATUS_FORWARD and handler_id is None:
        raise_dev_exc(DEV_BAD_REQUEST_ERROR, arg='handler_id')

    event = inner.get_event(event_id)

    if not event:
        raise_user_exc(CS_EVENT_NOT_EXIST, event_id=event_id)

    if event.status == CSEvent.STATUS_DONE:
        raise_dev_exc(CS_EVENT_PROCESS_STATUS_INVALID, event_id=event_id,
                      status=event.status)

    event.update(status=status, handler_id=handler_id)
    return True