from blueprints.accounts.models import Stats from blueprints.users.manage.config import UserConfig from workers.tasks import AnalyzeTask, GenerateVariationTask from workers.workers import AssetWorker # Chains dashboard_chains = ChainMgr() dashboard_chains['get'] = Chain([ 'authenticate', 'decorate', 'get_activity', 'get_workers_and_tasks', 'render_template' ]) dashboard_chains.set_link(factories.authenticate()) dashboard_chains.set_link(factories.render_template('dashboard.html')) @dashboard_chains.link def decorate(state): state.decor = manage_utils.base_decor(state.manage_config, 'dashboard') state.decor['title'] = 'Dashboard' state.decor['breadcrumbs'].add(NavItem('Dashboard', '')) @dashboard_chains.link def get_activity(state): # Determine the period to view unit = 'days'
from blueprints.assets.manage.config import AssetConfig # Define the chains download_chains = ChainMgr() download_chains['get'] = Chain([ 'config', 'authenticate', 'get_document', 'get_variation', 'download' ]) download_chains.set_link(factories.config(projection=None)) download_chains.set_link(factories.authenticate()) download_chains.set_link(factories.get_document()) @download_chains.link def download(state): # Get the backend required to download the asset backend_type = 'secure' if state.asset.secure else 'public' backend = getattr(state.asset.account, f'{backend_type}_backend', None) # If the backend isn't configured redirect the user to the view page and # notify them of the issue. if not backend: flash('No backend configured for the asset!', 'error') return redirect(
remove_backend_chains = ChainMgr() # GET remove_backend_chains['get'] = Chain([ 'config', 'authenticate', 'get_type', 'get_document', 'decorate', 'render_template' ]) # POST remove_backend_chains['post'] = Chain([ 'config', 'authenticate', 'get_type', 'get_document', 'clear_backend_settings', 'redirect' ]) remove_backend_chains.set_link(factories.config(projection=None)) remove_backend_chains.set_link(factories.authenticate()) remove_backend_chains.set_link(factories.get_document()) remove_backend_chains.set_link( factories.render_template('remove_backend.html')) remove_backend_chains.set_link(factories.redirect('view', include_id=True)) @remove_backend_chains.link def decorate(state): state.decor = manage_utils.base_decor(state.manage_config, 'remove_backend', state.provider) # Title state.decor['title'] = f'Remove {state.type} backend for {state.account}' # Breadcrumbs
'get_document', 'decorate', 'render_template' ]) # POST cycle_api_access_chains['post'] = Chain([ 'config', 'authenticate', 'get_document', 'cycle_api_key', 'redirect' ]) cycle_api_access_chains.set_link(factories.config(projection=None)) cycle_api_access_chains.set_link(factories.authenticate()) cycle_api_access_chains.set_link(factories.get_document()) cycle_api_access_chains.set_link( factories.render_template('cycle_api_key.html') ) cycle_api_access_chains.set_link(factories.redirect('view', include_id=True)) @cycle_api_access_chains.link def decorate(state): state.decor = manage_utils.base_decor( state.manage_config, 'cycle_api_access', state.provider ) # Title