def check_for_software_updates(): """Check software updates.""" from flask import get_flashed_messages from invenio.ext.script import check_for_software_updates print(">>> Going to check software updates ...") result = check_for_software_updates() messages = list(get_flashed_messages(with_categories=True)) if len(messages) > 0: print('\n'.join(map(lambda t, msg: '[%s]: %s' % (t.upper(), msg), messages))) print('>>> ' + ('Invenio is up to date.' if result else 'Please consider updating your Invenio installation.'))
def index(): """Index.""" # load plugins plugins = filter(lambda x: x.is_authorized and x.widget, map(lambda x: x(), _USER_SETTINGS.values())) closed_plugins = [] plugin_sort = (lambda w, x: x.index(w.name) if w.name in x else len(x)) dashboard_settings = current_user.get('dashboard_settings', {}) if current_user.is_super_admin: # Check for a new release of Invenio from invenio.ext.script import check_for_software_updates check_for_software_updates(flash_message=True) if dashboard_settings: order_left = dashboard_settings.get('orderLeft', []) or [] order_middle = dashboard_settings.get('orderMiddle', []) or [] order_right = dashboard_settings.get('orderRight', []) or [] def extract_plugins(x): return [p for p in plugins if p.name in x if p] plugins_left = sorted(extract_plugins(order_left), key=lambda w: plugin_sort(w, order_left)) plugins_middle = sorted(extract_plugins(order_middle), key=lambda w: plugin_sort(w, order_middle)) plugins_right = sorted(extract_plugins(order_right), key=lambda w: plugin_sort(w, order_right)) closed_plugins = [ p for p in plugins if p not in plugins_left and p not in plugins_middle and p not in plugins_right ] plugins = [plugins_left, plugins_middle, plugins_right] else: plugins = sorted(plugins, key=lambda w: plugin_sort(w, plugins)) plugins = [plugins[i:i + 3] for i in range(0, len(plugins), 3)] return render_template('accounts/index.html', plugins=plugins, closed_plugins=closed_plugins)
def index(): """Index.""" # load plugins plugins = filter(lambda x: x.is_authorized and x.widget, map(lambda x: x(), _USER_SETTINGS.values())) closed_plugins = [] plugin_sort = (lambda w, x: x.index(w.name) if w.name in x else len(x)) dashboard_settings = current_user.get('dashboard_settings', {}) if current_user.is_super_admin: # Check for a new release of Invenio from invenio.ext.script import check_for_software_updates check_for_software_updates(flash_message=True) if dashboard_settings: order_left = dashboard_settings.get('orderLeft', []) or [] order_middle = dashboard_settings.get('orderMiddle', []) or [] order_right = dashboard_settings.get('orderRight', []) or [] def extract_plugins(x): return [p for p in plugins if p.name in x if p] plugins_left = sorted(extract_plugins(order_left), key=lambda w: plugin_sort(w, order_left)) plugins_middle = sorted(extract_plugins(order_middle), key=lambda w: plugin_sort(w, order_middle)) plugins_right = sorted(extract_plugins(order_right), key=lambda w: plugin_sort(w, order_right)) closed_plugins = [p for p in plugins if p not in plugins_left and p not in plugins_middle and p not in plugins_right] plugins = [plugins_left, plugins_middle, plugins_right] else: plugins = sorted(plugins, key=lambda w: plugin_sort(w, plugins)) plugins = [plugins[i:i+3] for i in range(0, len(plugins), 3)] return render_template('accounts/index.html', plugins=plugins, closed_plugins=closed_plugins)