Beispiel #1
0
    def tabs(cls, view_type, document=None):
        tabs = Nav.local_menu()

        if view_type in ['api_log', 'change_log', 'activity', 'view']:

            tabs.add(
                NavItem('Details',
                        endpoint=AccountConfig.get_endpoint('view'),
                        view_args={'account': document._id}))

            tabs.add(
                NavItem('Activity',
                        endpoint=AccountConfig.get_endpoint('activity'),
                        view_args={'account': document._id}))

            tabs.add(
                NavItem('API log',
                        endpoint=AccountConfig.get_endpoint('api_log'),
                        view_args={'account': document._id}))

            tabs.add(
                NavItem('Change log',
                        endpoint=AccountConfig.get_endpoint('change_log'),
                        view_args={'account': document._id}))

        return tabs
Beispiel #2
0
    def tabs(cls, view_type, document=None):
        tabs = Nav.local_menu()

        if view_type in ['variations', 'view']:

            tabs.add(
                NavItem('Details',
                        endpoint=AssetConfig.get_endpoint('view'),
                        view_args={'asset': document._id}))

            tabs.add(
                NavItem(f'Variations ({len(document.variations or {})})',
                        endpoint=AssetConfig.get_endpoint('variations'),
                        view_args={'asset': document._id}))

        return tabs
Beispiel #3
0
"""
Disable multi-factor authentication (MFA) for the user.
"""

from manhattan.nav import Nav
from manhattan.users import views

from blueprints.users.manage.config import UserConfig

# Chains
disable_chains = views.mfa.disable_chains.copy()

# Set the URL
UserConfig.add_view_rule('/security/mfa/disable', 'mfa_disable',
                         disable_chains)

# Set the nav rules
Nav.apply(UserConfig.get_endpoint('mfa_disable'), ['mfa_enabled'])
Beispiel #4
0
"""
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'])
Beispiel #5
0
"""
Regenerate the user's list of recovery codes.
"""

from manhattan.nav import Nav
from manhattan.users import views

from blueprints.users.manage.config import UserConfig

# Chains
regenerate_recovery_codes_chains \
        = views.mfa.regenerate_recovery_codes_chains.copy()

# Set URL
UserConfig.add_view_rule('/security/mfa/regenerate-recovery-codes',
                         'mfa_regenerate_recovery_codes',
                         regenerate_recovery_codes_chains)

# Set nav rules
Nav.apply(UserConfig.get_endpoint('mfa_regenerate_recovery_codes'),
          ['mfa_enabled'])
Beispiel #6
0
"""
Delete a user.
"""

from manhattan.nav import Nav
from manhattan.users import views

from blueprints.users.manage.config import UserConfig

# Chains
delete_chains = views.delete_chains.copy()

# Set the URL
UserConfig.add_view_rule('/users/delete', 'delete', delete_chains)

# Set the nav rules
Nav.apply(UserConfig.get_endpoint('delete'), ['not_me'])
Beispiel #7
0
"""
Primary navigation menu for the manage area.
"""

from manhattan.nav import Nav, NavItem
from mongoframes import Q

from blueprints.accounts.manage.config import AccountConfig
from blueprints.assets.manage.config import AssetConfig
from blueprints.users.manage.config import UserConfig

# 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'
Beispiel #8
0
"""
Download a text file containing the user's recovery codes.
"""

from manhattan.nav import Nav
from manhattan.users import views

from blueprints.users.manage.config import UserConfig

# Chains
download_recovery_codes_chains \
        = views.mfa.download_recovery_codes_chains.copy()

# Set the URL
UserConfig.add_view_rule('/security/mfa/download-recovery-codes',
                         'mfa_download_recovery_codes',
                         download_recovery_codes_chains)

# Set nav rules
Nav.apply(UserConfig.get_endpoint('mfa_download_recovery_codes'),
          ['mfa_enabled'])
Beispiel #9
0
    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'])

Beispiel #10
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'])
Beispiel #11
0
# 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'])