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 }
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, 'navigations': get_monitoring_for_company(user), 'context': 'monitoring', 'groups': app.config.get('MONITORING_GROUPS') or app.config.get('WIRE_GROUPS', []), 'ui_config': get_resource_service('ui_config').getSectionConfig('monitoring'), 'saved_items': get_bookmarks_count(user['_id'], 'monitoring'), 'formats': [{ 'format': f['format'], 'name': f['name'] } for f in app.download_formatters.values() if 'monitoring' in f['types']], 'secondary_formats': [{ 'format': f[0], 'name': f[1] } for f in alert_types] }
def bookmark(): """Bookmark an item. Stores user id into item.bookmarks array. Uses mongodb to update the array and then pushes updated array to elastic. """ data = get_json_or_400() assert data.get('items') update_action_list(data.get('items'), 'bookmarks', item_type='items') user_id = get_user_id() push_user_notification('saved_items', count=get_bookmarks_count(user_id, 'media_releases')) return flask.jsonify(), 200
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': [], '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'], 'media_releases'), 'context': 'media_releases', 'ui_config': get_resource_service('ui_config').getSectionConfig('media_releases') }
def get_initial_notifications(): """ Returns the stories that user has notifications for :return: List of stories """ if not session.get('user'): return None saved_notifications = get_user_notifications(session['user']) items = superdesk.get_resource_service('wire_search').get_items([n['item'] for n in saved_notifications]) return { 'user': str(session['user']) if session['user'] else None, 'notifications': list(items), 'bookmarksCount': get_bookmarks_count(session['user']), }
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 }
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' }