예제 #1
0
def get_sponsored_editions(user):
    """
    Gets a list of books from the civi API which internet archive
    @archive_username has sponsored

    :param user user: infogami user
    :rtype: list
    :return: list of editions sponsored by user
    """
    archive_id = get_internet_archive_id(user.key if 'key' in user else user._key)
    contact_id = get_contact_id_by_username(archive_id)
    return get_sponsorships_by_contact_id(contact_id) if contact_id else []
예제 #2
0
def get_sponsored_editions(user):
    """
    Gets a list of books from the civi API which internet archive
    @archive_username has sponsored

    :param user user: infogami user
    :rtype: list
    :return: list of editions sponsored by user
    """
    archive_id = get_internet_archive_id(user.key if 'key' in
                                         user else user._key)
    # MyBooks page breaking on local environments without archive_id check
    contact_id = get_contact_id_by_username(archive_id) if archive_id else None
    return get_sponsorships_by_contact_id(contact_id) if contact_id else []
예제 #3
0
def get_sponsored_editions_civi(user):
    """
    Deprecated by get_sponsored_editions but worth maintaining as we
    may periodically have to programmatically access data from civi
    since it is the ground-truth of this data.

    Gets a list of books from the civi API which internet archive
    @archive_username has sponsored

    :param user user: infogami user
    :rtype: list
    :return: list of archive.org items sponsored by user
    """
    archive_id = get_internet_archive_id(user.key if 'key' in user else user._key)
    # MyBooks page breaking on local environments without archive_id check
    if archive_id:
        contact_id = get_contact_id_by_username(archive_id) if archive_id else None
        return get_sponsorships_by_contact_id(contact_id) if contact_id else []
    return []