Skip to content

Services

hypha.apply.activity.services

get_related_actions_for_user(obj, user)

Return Activity objects related to an object, esp. useful with ApplicationSubmission and Project.

Parameters:

  • obj

    instance of a model class

  • user

    user who these actions are visible to.

Returns:

  • Activity queryset

Source code in hypha/apply/activity/services.py
def get_related_actions_for_user(obj, user):
    """Return Activity objects related to an object, esp. useful with
    ApplicationSubmission and Project.

    Args:
        obj: instance of a model class
        user: user who these actions are visible to.

    Returns:
        `Activity` queryset
    """
    related_query = type(obj).activities.rel.related_query_name

    return (
        Activity.actions.filter(**{related_query: obj})
        .select_related("user")
        .prefetch_related(
            "related_object",
        )
        .visible_to(user)
    )
get_related_comments_for_user(obj, user)

Return comments/communications related to an object, esp. useful with ApplicationSubmission and Project.

Parameters:

  • obj

    instance of a model class

  • user

    user who these actions are visible to.

Returns:

  • Activity queryset

Source code in hypha/apply/activity/services.py
def get_related_comments_for_user(obj, user):
    """Return comments/communications related to an object, esp. useful with
    ApplicationSubmission and Project.

    Args:
        obj: instance of a model class
        user: user who these actions are visible to.

    Returns:
        `Activity` queryset
    """
    related_query = type(obj).activities.rel.related_query_name

    return (
        Activity.comments.filter(**{related_query: obj})
        .select_related("user")
        .prefetch_related(
            "related_object",
        )
        .visible_to(user)
    )