Beispiel #1
0
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
    state.decor['breadcrumbs'].add(
        NavItem('Accounts', AccountConfig.get_endpoint('list')))
    state.decor['breadcrumbs'].add(
Beispiel #2
0
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'
    length = 90
Beispiel #3
0
"""

from flask import request
from manhattan.manage.views import factories, generic
from manhattan.utils.chrono import today_tz
from mongoframes import Q

from blueprints.accounts.manage.config import AccountConfig
from blueprints.accounts.models import Stats

# Chains
activity_chains = generic.view.copy()
activity_chains['get'].insert_link('get_document', 'get_metrics', after=True)

# Factory overrides
activity_chains.set_link(factories.render_template('activity.html'))

# Custom overrides


@activity_chains.link
def decorate(state):
    generic.view.chains['get'].get_link('decorate')(state)

    # Remove actions from the page
    state.decor['actions'] = None


@activity_chains.link
def get_metrics(state):
Beispiel #4
0
from datetime import datetime
import json

from flask import abort, current_app, request
from manhattan.manage.views import factories, generic
from manhattan.nav import NavItem

from blueprints.accounts.manage.config import AccountConfig

# Chains
entry_chains = generic.view.copy()
entry_chains.insert_link('get_document', 'get_api_log_entry', after=True)

# Factory overrides
entry_chains.set_link(factories.render_template('api_log/entry.html'))

# Custom overrides


@entry_chains.link
def decorate(state):
    generic.view.chains['get'].get_link('decorate')(state)

    state.decor['title'] = f'View API log entry for {state.account}'
    state.decor['actions'] = None

    # Breadcrumbs
    state.decor['breadcrumbs'] = NavItem()
    state.decor['breadcrumbs'].add(
        NavItem('Accounts', AccountConfig.get_endpoint('list')))
Beispiel #5
0
])

# 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
    state.decor['title'] = f'Cycle API key for {state.account}'

    # Breadcrumbs
Beispiel #6
0
"""
View variations for an asset.
"""

from manhattan.manage.views import factories, generic
from manhattan.nav import Nav, NavItem

from blueprints.assets.manage.config import AssetConfig
from blueprints.assets.models import Variation

# Chains
list_chains = generic.view.copy()

# Factory overrides
list_chains.set_link(factories.render_template('variations/list.html'))

# Custom overrides


@list_chains.link
def decorate(state):
    generic.view['get'].super(state)

    # Remove actions
    state.decor['actions'] = None

    # Breadcrumbs
    state.decor['breadcrumbs'] = NavItem()
    state.decor['breadcrumbs'].add(
        NavItem('Assets', AssetConfig.get_endpoint('list')))
    state.decor['breadcrumbs'].add(
Beispiel #7
0
View a variation for an asset.
"""

from flask import abort, request
from manhattan.manage.views import factories, generic
from manhattan.nav import Nav, NavItem

from blueprints.assets.manage.config import AssetConfig
from blueprints.assets.models import Variation

# Chains
view_chains = generic.view.copy()
view_chains['get'].insert_link('get_document', 'get_variation', after=True)

# Factory overrides
view_chains.set_link(factories.render_template('variations/view.html'))

# Custom overrides


@view_chains.link
def decorate(state):
    generic.view['get'].super(state)

    state.decor['title'] = state.variation.get_store_key(
        state.asset, state.variation_name)

    # Download
    state.decor['actions'] = NavItem()
    state.decor['actions'].add(
        NavItem('Download',
Beispiel #8
0
        log_entry['call_time'] = f'{log_entry["call_time"] * 1000:.1f}ms'
        log_entry['called'] = datetime.utcfromtimestamp(log_entry['called'])

    return log_entries

# Chains
log_chains = generic.view.copy()
log_chains.insert_link(
    'get_document',
    'get_api_log',
    after=True
)

# Factory overrides
log_chains.set_link(
    factories.render_template('api_log/log.html')
)

# Custom overrides

@log_chains.link
def decorate(state):
    generic.view.chains['get'].get_link('decorate')(state)
    state.decor['actions'] = None

    # Breadcrumbs
    state.decor['breadcrumbs'] = NavItem()
    state.decor['breadcrumbs'].add(
        NavItem('Accounts', AccountConfig.get_endpoint('list'))
    )
    state.decor['breadcrumbs'].add(
Beispiel #9
0
        '',
        choices=BackendList(),
        validators=[validators.Required()],
        default=lambda: current_app.config['DEFAULT_BACKEND'])


# Chains
update_backend_settings_chains = generic.update.copy()
update_backend_settings_chains.insert_link('get_document', 'get_type')
update_backend_settings_chains.insert_link('get_document',
                                           'get_backend',
                                           after=True)

# Factory overrides
update_backend_settings_chains.set_link(
    factories.render_template('update_backend_settings.html'))

# Custom overrides


@update_backend_settings_chains.link
def decorate(state):
    generic.update.chains['get'].get_link('decorate')(state)

    if state.backend:
        state.decor['title'] = \
                f'Update {state.type} backend for {state.account}'
        state.decor['breadcrumbs'].children[-1].label \
            = f'Update {state.type} backend settings'

    else: