コード例 #1
0
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',
                AssetConfig.get_endpoint('download_variation'),
                view_args={
                    'asset': state.asset._id,
                    'variation': state.variation_name
                }))

    # Breadcrumbs
    state.decor['breadcrumbs'] = NavItem()
    state.decor['breadcrumbs'].add(
        NavItem('Assets', AssetConfig.get_endpoint('list')))
    state.decor['breadcrumbs'].add(
        NavItem('Asset details', AssetConfig.get_endpoint('view'),
                {'asset': state.asset._id}))
    state.decor['breadcrumbs'].add(
        NavItem('Variations', AssetConfig.get_endpoint('variations'),
                {'asset': state.asset._id}))
    state.decor['breadcrumbs'].add(NavItem('View'))
コード例 #2
0
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(
        NavItem('Asset details', AssetConfig.get_endpoint('view'),
                {'asset': state.asset._id}))
    state.decor['breadcrumbs'].add(NavItem('Variations'))
コード例 #3
0
ファイル: download.py プロジェクト: GetmeUK/h51
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(
            url_for(
                AssetConfig.get_endpoint('view_variation'),
                asset=state.asset._id,
                variation=state.variation_name
            )
        )

    # Download the file
    store_key = state.variation.get_store_key(
        state.asset,
        state.variation_name
    )
    file = backend.retrieve(store_key)

    # Send the file to the user
    r = send_file(
        io.BytesIO(file),
        mimetype=state.variation.content_type or 'application/octet-stream',
        as_attachment=True,
        attachment_filename=store_key
    )

    return r
コード例 #4
0
ファイル: view.py プロジェクト: GetmeUK/h51
def decorate(state):
    generic.view['get'].super(state)

    # Download
    state.decor['actions'].add(
        NavItem('Download',
                AssetConfig.get_endpoint('download'),
                view_args={'asset': state.asset._id}))
コード例 #5
0
ファイル: delete.py プロジェクト: GetmeUK/h51
"""
Delete a asset.
"""

import time

from manhattan.manage.views import generic
from manhattan.nav import Nav

from blueprints.assets.manage.config import AssetConfig

# Chains
delete_chains = generic.delete.copy()


@delete_chains.link
def delete_document(state):

    # Set the asset to expire now
    state.asset.expires = time.time() - 1
    state.asset.update('expires', 'modified')


# Set URL
AssetConfig.add_view_rule('/assets/delete', 'delete', delete_chains)

# Set nav rules
Nav.apply(AssetConfig.get_endpoint('delete'), ['not_expired'])
コード例 #6
0
# Define the primary menu
menu = Nav.menu('manage')

# Dashboard
menu.add(NavItem('Dashboard', UserConfig.get_endpoint('dashboard')))

# Assets

assets_group = Nav.menu('assets_group')
assets_group.label = 'Assets'
assets_group.data = {'group': True}
menu.add(assets_group)

# Assets > Assets
assets_group.add(NavItem('Assets', AssetConfig.get_endpoint('list')))

# Admin

admin_group = Nav.menu('admin_group')
admin_group.label = 'Admin'
admin_group.data = {'group': True}
menu.add(admin_group)

# Accounts > Accounts
admin_group.add(NavItem('Accounts', AccountConfig.get_endpoint('list')))

# Admin > Users
admin_group.add(NavItem('Users', UserConfig.get_endpoint('list')))

# Define the manage user menu
コード例 #7
0
ファイル: download.py プロジェクト: GetmeUK/h51
    projection={
        'created': True,
        'account': {
            '$ref': Account,
            'public_backend_settings': True,
            'secure_backend_settings': True
        },
        'secure': True,
        'name': True,
        'uid': True,
        'ext': True,
        'type': True,
        'expires': True,
        'variations': {
            '$sub.': Variation
        }
    }
)

# Set URL
AssetConfig.add_view_rule(
    '/assets/variations/download',
    'download_variation',
    download_chains,
    initial_state
)

# Set nav rules
Nav.apply(AssetConfig.get_endpoint('download_variation'), ['not_expired'])

コード例 #8
0
# 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(
        NavItem('Asset details', AssetConfig.get_endpoint('view'),
                {'asset': state.asset._id}))
    state.decor['breadcrumbs'].add(NavItem('Variations'))


# Configure the view
initial_state = dict(projection={'variations': {'$sub.': Variation}})

# Set URL
AssetConfig.add_view_rule('/assets/variations', 'variations', list_chains,
                          initial_state)

# Set nav rules
Nav.apply(AssetConfig.get_endpoint('variations'), ['not_expired'])
コード例 #9
0
ファイル: view.py プロジェクト: GetmeUK/h51
# Custom overrides


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

    # Download
    state.decor['actions'].add(
        NavItem('Download',
                AssetConfig.get_endpoint('download'),
                view_args={'asset': state.asset._id}))


# Configure the view
initial_state = dict(
    projection={
        'account': {
            '$ref': Account,
            'name': True,
            'public_backend_settings': True,
            'secure_backend_settings': True
        }
    })

# Set URL
AssetConfig.add_view_rule('/assets/view', 'view', view_chains, initial_state)

# Set nav rules
Nav.apply(AssetConfig.get_endpoint('view'), ['not_expired'])