Exemplo n.º 1
0
def outlet_from_row(row, unused_index=None):
    medium_dict = {
        '__SEARCH_BY__': 'scienceFeedbackIdentifier',
        'name': row['Name'],
        'scienceFeedbackIdentifier': row['airtableId']
    }

    return Medium.create_or_modify(medium_dict)
Exemplo n.º 2
0
def create_or_modify_sf_organization_and_media():

    organization = Organization.create_or_modify({
        '__SEARCH_BY__': 'name',
        'name': 'Science Feedback',
    })

    ApiHandler.save(organization)

    climate_medium = Medium.create_or_modify({
        '__SEARCH_BY__': 'name',
        'logoUrl': 'https://climatefeedback.org/wp-content/themes/wordpress-theme/dist/images/Climate_Feedback_logo_s.png',
        'name': 'Climate Feedback',
        'organization': organization,
        'url': 'https://climatefeedback.org',
    })

    health_medium = Medium.create_or_modify({
        '__SEARCH_BY__': 'name',
        'logoUrl': 'https://healthfeedback.org/wp-content/themes/wordpress-theme/dist/images/healthfeedback_logo.png',
        'name': 'Health Feedback',
        'organization': organization,
        'url': 'https://healthfeedback.org',
    })

    science_medium = Medium.create_or_modify({
        '__SEARCH_BY__': 'name',
        'logoUrl': 'https://sciencefeedback.co/wp-content/themes/SF-wordpress/dist/images/sciencefeedback_logo.png',
        'name': 'Science Feedback',
        'organization': organization,
        'url': 'https://sciencefeedback.co',
    })

    ApiHandler.save(climate_medium,
                    health_medium,
                    science_medium)
Exemplo n.º 3
0
def attach_crowdtangle_entities_from_content(content, request_start_date):

    # create a "CrowdTangle" user to testify that these Facebook posts are connected to the url
    crowdtangle_user = User.create_or_modify({
        '__SEARCH_BY__': 'email',
        'email': "*****@*****.**",
        'password': "******",
        'firstName': "Crowd",
        'lastName': "Tangle"
    })

    # create the Facebook platform so we can link our Facebook posts media to it:
    facebook_platform = Platform.create_or_modify({
        '__SEARCH_BY__': 'name',
        'name': 'Facebook'
    })

    shares = shares_from_url(content.url, request_start_date)

    for share in shares:
        medium_group = Medium.create_or_modify({
            '__SEARCH_BY__': 'name',
            'platform': facebook_platform,
            **share['account']
        })

        content_post = Content.create_or_modify({
            '__SEARCH_BY__': 'url',
            'medium': medium_group,
            'type': ContentType.POST,
            **share['post']
        })

        crowdtangle_identifier = '{}_{}_{}'.format(
            content.id, content_post.crowdtangleIdentifier,
            crowdtangle_user.id)

        appearance = Appearance.create_or_modify({
            '__SEARCH_BY__': 'crowdtangleIdentifier',
            'crowdtangleIdentifier': crowdtangle_identifier,
            'quotedContent': content,
            'quotingContent': content_post,
            'testifier': crowdtangle_user
        })
Exemplo n.º 4
0
def social_from_row(row, unused_index=None):
    if row.get('url') is None:
        return None

    organization_name = row['url'].replace('https://www.', '') \
                                  .split('/')[0] \
                                  .split('.')[0] \
                                  .title()
    organization = Organization.create_or_modify({
        '__SEARCH_BY__': 'name',
        'name': organization_name
    })

    medium_dict = {
        '__SEARCH_BY__': 'scienceFeedbackIdentifier',
        'name': row['Name'],
        'organization': organization,
        'scienceFeedbackIdentifier': row['airtableId'],
        'url': row['url']
    }

    return Medium.create_or_modify(medium_dict)