Example #1
0
def get_view_data():
    user = get_user()
    topics = get_user_topics(user['_id']) if user else []
    company = get_user_company(user) or {}
    return {
        'user':
        str(user['_id']) if user else None,
        'company':
        str(user['company']) if user and user.get('company') else None,
        'topics': [t for t in topics if t.get('topic_type') == 'agenda'],
        'formats': [{
            'format': f['format'],
            'name': f['name']
        } for f in app.download_formatters.values() if 'agenda' in f['types']],
        'navigations':
        get_navigations_by_company(
            str(user['company']) if user and user.get('company') else None,
            product_type='agenda',
            events_only=company.get('events_only', False)),
        'saved_items':
        get_resource_service('agenda').get_saved_items_count(),
        'events_only':
        company.get('events_only', False),
        'locators':
        get_vocabulary('locators'),
        'ui_config':
        get_resource_service('ui_config').getSectionConfig('agenda')
    }
Example #2
0
def get_view_data():
    user = get_user()
    topics = get_user_topics(user['_id']) if user else []
    return {
        'user':
        str(user['_id']) if user else None,
        'user_type': (user or {}).get('user_type') or 'public',
        'company':
        str(user['company']) if user and user.get('company') else None,
        'topics': [t for t in topics if t.get('topic_type') == 'wire'],
        'formats': [{
            'format': f['format'],
            'name': f['name'],
            'assets': f['assets']
        } for f in app.download_formatters.values() if 'wire' in f['types']],
        'navigations':
        get_navigations_by_company(
            str(user['company']) if user and user.get('company') else None,
            product_type='wire'),
        'saved_items':
        get_bookmarks_count(user['_id'], 'wire'),
        'context':
        'wire',
        'ui_config':
        get_resource_service('ui_config').getSectionConfig('wire'),
        'groups':
        app.config.get('WIRE_GROUPS', []),
    }
Example #3
0
def get_view_data():
    """Get the view data"""
    user = get_user()
    topics = get_user_topics(user['_id']) if user else []
    navigations = get_navigations_by_company(
        str(user['company']) if user and user.get('company') else None,
        product_type=SECTION_ID)
    get_story_count(navigations, user)
    return {
        'user':
        str(user['_id']) if user else None,
        'user_type': (user or {}).get('user_type') or 'public',
        'company':
        str(user['company']) if user and user.get('company') else None,
        'topics': [t for t in topics if t.get('topic_type') == SECTION_ID],
        'navigations':
        navigations,
        'formats': [{
            'format': f['format'],
            'name': f['name']
        } for f in app.download_formatters.values() if 'wire' in f['types']],
        'saved_items':
        get_bookmarks_count(user['_id'], SECTION_ID),
        'context':
        SECTION_ID,
        'ui_config':
        get_resource_service('ui_config').getSectionConfig(SECTION_ID),
        'home_page':
        False,
        'title':
        SECTION_NAME
    }
Example #4
0
def test_get_agenda_navigations_by_company_returns_ordered(client, app):
    app.data.insert('navigations', [{
        '_id': 'n-1',
        'name': 'Uber',
        'is_enabled': True,
        'product_type': 'agenda',
    }])

    app.data.insert('companies', [{
        '_id': 'c-1',
        'phone': '2132132134',
        'sd_subscriber_id': '12345',
        'name': 'Press Co.',
        'is_enabled': True,
        'contact_name': 'Tom'
    }])

    app.data.insert('products', [{
        '_id': 'p-1',
        'name': 'Top Things',
        'navigations': ['n-1'],
        'companies': ['c-1'],
        'is_enabled': True,
        'query': '_featured',
        'product_type': 'agenda'
    }, {
        '_id': 'p-2',
        'name': 'A News',
        'navigations': ['59b4c5c61d41c8d736852fbf'],
        'companies': ['c-1'],
        'description': 'news product',
        'is_enabled': True,
        'product_type': 'wire',
        'query': 'latest'
    }])

    test_login_succeeds_for_admin(client)
    navigations = get_navigations_by_company('c-1', 'agenda')
    assert navigations[0].get('name') == 'Uber'
    navigations = get_navigations_by_company('c-1', 'wire')
    assert navigations[0].get('name') == 'Sport'
Example #5
0
def get_home_page_data():
    """Get home page data for market place"""
    user = get_user()
    navigations = get_navigations_by_company(str(user['company']) if user and user.get('company') else None,
                                             product_type=SECTION_ID)
    get_resource_service(search_endpoint_name).get_navigation_story_count(navigations)
    return {
        'user': str(user['_id']) if user else None,
        'company': str(user['company']) if user and user.get('company') else None,
        'navigations': navigations,
        'cards': list(query_resource('cards', lookup={'dashboard': SECTION_ID})),
        'saved_items': get_bookmarks_count(user['_id'], SECTION_ID),
        'context': SECTION_ID,
        'home_page': True,
        'title': SECTION_NAME
    }
Example #6
0
def get_view_data():
    user = get_user()
    return {
        'user':
        str(user['_id']) if user else None,
        'company':
        str(user['company']) if user and user.get('company') else None,
        'topics':
        get_user_topics(user['_id']) if user else [],
        'formats': [{
            'format': f['format'],
            'name': f['name']
        } for f in app.download_formatters.values()],
        'navigations':
        get_navigations_by_company(
            str(user['company']) if user and user.get('company') else None),
    }
Example #7
0
def get_view_data():
    """Get the view data"""
    user = get_user()
    return {
        'user':
        str(user['_id']) if user else None,
        'company':
        str(user['company']) if user and user.get('company') else None,
        'navigations':
        get_navigations_by_company(
            str(user['company']) if user and user.get('company') else None,
            product_type='am_news'),
        'formats': [{
            'format': f['format'],
            'name': f['name']
        } for f in app.download_formatters.values() if 'wire' in f['types']],
        'saved_items':
        get_bookmarks_count(user['_id'], 'am_news'),
        'context':
        'am_news'
    }
Example #8
0
def get_view_data():
    user = get_user()
    topics = get_user_topics(user['_id']) if user else []
    return {
        'user':
        str(user['_id']) if user else None,
        'company':
        str(user['company']) if user and user.get('company') else None,
        'topics': [t for t in topics if t.get('topic_type') == 'agenda'],
        'formats': [{
            'format': f['format'],
            'name': f['name']
        } for f in app.download_formatters.values() if 'agenda' in f['types']],
        'navigations':
        get_navigations_by_company(
            str(user['company']) if user and user.get('company') else None,
            product_type='agenda'),
        'saved_items':
        get_resource_service('agenda').get_saved_items_count(),
        'coverage_types':
        app.config['COVERAGE_TYPES'],
    }
Example #9
0
def get_view_data():
    user = get_user()
    topics = get_user_topics(user['_id']) if user else []
    return {
        'user':
        str(user['_id']) if user else None,
        'company':
        str(user['company']) if user and user.get('company') else None,
        'topics': [t for t in topics if t.get('topic_type') != 'agenda'],
        'formats': [{
            'format': f['format'],
            'name': f['name']
        } for f in app.download_formatters.values() if 'wire' in f['types']],
        'navigations':
        get_navigations_by_company(
            str(user['company']) if user and user.get('company') else None,
            product_type='wire'),
        'saved_items':
        get_bookmarks_count(user['_id'], 'wire'),
        'context':
        'wire'
    }