Generate workflow information of the assigned workflows

    :param brain_or_object: A single catalog brain or content object
    :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
    :param endpoint: The named URL endpoint for the root of the items
    :type endpoint: str/unicode
    :returns: Workflows info
    :rtype: dict

def get_workflow_info(brain_or_object, endpoint=None):
    """Generate workflow information of the assigned workflows

    :param brain_or_object: A single catalog brain or content object
    :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
    :param endpoint: The named URL endpoint for the root of the items
    :type endpoint: str/unicode
    :returns: Workflows info
    :rtype: dict
    """

    # ensure we have a full content object
    obj = get_object(brain_or_object)

    # get the portal workflow tool
    wf_tool = get_tool("portal_workflow")

    # the assigned workflows of this object
    workflows = wf_tool.getWorkflowsFor(obj)

    # no worfkflows assigned -> return
    if not workflows:
        return []

    def to_transition_info(transition):
        """ return the transition information
        """
        return {
            "title": transition["title"],
            "value": transition["id"],
            "display": transition["description"],
            "url": transition["url"],
        }

    def to_review_history_info(review_history):
        """ return the transition information
        """
        converted = DT2dt(review_history.get('time')).\
            strftime("%Y-%m-%d %H:%M:%S")
        review_history['time'] = converted
        return review_history

    out = []

    for workflow in workflows:

        # get the status info of the current state (dictionary)
        info = wf_tool.getStatusOf(workflow.getId(), obj)
        if info is None:
            continue

        # get the current review_status
        review_state = info.get("review_state", None)
        inactive_state = info.get("inactive_state", None)
        cancellation_state = info.get("cancellation_state", None)
        worksheetanalysis_review_state = info.get("worksheetanalysis_review_state", None)

        state = review_state or \
            inactive_state or \
            cancellation_state or \
            worksheetanalysis_review_state

        if state is None:
            logger.warn("No state variable found for {} -> {}".format(
                repr(obj), info))
            continue

        # get the wf status object
        status_info = workflow.states[state]

        # get the title of the current status
        status = status_info.title

        # get the transition informations
        transitions = map(to_transition_info, wf_tool.getTransitionsFor(obj))

        # get the review history
        rh = map(to_review_history_info,
                 workflow.getInfoFor(obj, 'review_history', ''))

        out.append({
            "workflow": workflow.getId(),
            "status": status,
            "review_state": state,
            "transitions": transitions,
            "review_history": rh,
        })

    return {"workflow_info": out}