コード例 #1
0
ファイル: services.py プロジェクト: ndjido/taiga-back
def analize_object_for_watchers(obj:object, comment:str, user:object):
    """
    Generic implementation for analize model objects and
    extract mentions from it and add it to watchers.
    """

    if not hasattr(obj, "get_project"):
        return

    if not hasattr(obj, "add_watcher"):
        return

    from taiga import mdrender as mdr

    texts = (getattr(obj, "description", ""),
             getattr(obj, "content", ""),
             comment,)

    _, data = mdr.render_and_extract(obj.get_project(), "\n".join(texts))

    if data["mentions"]:
        for user in data["mentions"]:
            obj.add_watcher(user)

    # Adding the person who edited the object to the watchers
    if comment and not user.is_system:
        obj.add_watcher(user)
コード例 #2
0
ファイル: services.py プロジェクト: testmana2/taiga-back
def analize_object_for_watchers(obj: object, comment: str, user: object):
    """
    Generic implementation for analize model objects and
    extract mentions from it and add it to watchers.
    """

    if not hasattr(obj, "get_project"):
        return

    if not hasattr(obj, "add_watcher"):
        return

    from taiga import mdrender as mdr

    texts = (
        getattr(obj, "description", ""),
        getattr(obj, "content", ""),
        comment,
    )

    _, data = mdr.render_and_extract(obj.get_project(), "\n".join(texts))

    if data["mentions"]:
        for user in data["mentions"]:
            obj.add_watcher(user)

    # Adding the person who edited the object to the watchers
    if comment and not user.is_system:
        obj.add_watcher(user)
コード例 #3
0
ファイル: services.py プロジェクト: lanphan/taiga-back
def analize_object_for_watchers(obj:object, history:object):
    """
    Generic implementation for analize model objects and
    extract mentions from it and add it to watchers.
    """
    from taiga import mdrender as mdr

    texts = (getattr(obj, "description", ""),
             getattr(obj, "content", ""),
             getattr(history, "comment", ""),)

    _, data = mdr.render_and_extract(obj.get_project(), "\n".join(texts))

    if data["mentions"]:
        for user in data["mentions"]:
            obj.watchers.add(user)