Exemplo n.º 1
0
    def home(self):
        if not c.user:
            h.redirect_to(controller='user', action='login')

        is_new = not h.check_access('package_create')

        if is_new:
            return h.redirect_to(controller='package', action='search')
        return h.redirect_to(
            controller='ckanext.canada.controller:CanadaController',
            action='links')
Exemplo n.º 2
0
def notice_no_access():
    '''flash_notice if logged-in user can't actually do anything yet'''
    if h.check_access('package_create'):
        return

    h.flash_notice(
        '<strong>' + _('Account Created') +
        '</strong><br>' +
        _('Thank you for creating your account for the Open '
          'Government registry. Although your account is active, '
          'it has not yet been linked to your department. Until '
          'the account is linked to your department you will not '
          'be able to create or modify datasets in the '
          'registry.') +
        '<br><br>' +
        _('You should receive an email within the next business '
          'day once the account activation process has been '
          'completed. If you require faster processing of the '
          'account, please send the request directly to: '
          '<a href="mailto:[email protected]">'
          '[email protected]</a>'), True)
Exemplo n.º 3
0
def kata_build_nav_main(*args):
    '''
    Fix active links in main navigation. Basically merges build_main_nav and _make_menu_item. The latter especially is
    modified.

    :param args: (menu_item, title)
    :return: <li><a href="..."></i> title</a></li>
    '''

    output = ''
    routers = {
        'home': ['ckanext.kata.controllers:KataHomeController'],
        'search': ['ckanext.kata.controllers:KataPackageController', 'package'],
        'organizations_index': ['ckanext.kata.controllers:KataOrganizationController', 'organization'],
        'about': ['home']
    }

    for item in args:
        menu_item, title = item[:2]
        if len(item) == 3 and not h.check_access(item[2]):
            continue

        _menu_items = config['routes.named_routes']
        _menu_item = copy.copy(_menu_items[menu_item])
        link = h._link_to(title, menu_item, suppress_active_class=True)
        active = h._link_active(_menu_item)

        if not active:
            # Ensure the reply is iterable: needed if variable routers is not consistent
            active = c.controller in routers.get(item[0], list())
        if active:
            output += literal('<li class="active">') + link + literal('</li>')
        else:
            output += literal('<li>') + link + literal('</li>')

    return output
Exemplo n.º 4
0
def kata_build_nav_main(*args):
    '''
    Fix active links in main navigation. Basically merges build_main_nav and _make_menu_item. The latter especially is
    modified.

    :param args: (menu_item, title)
    :return: <li><a href="..."></i> title</a></li>
    '''

    output = ''
    routers = {
        'home': ['ckanext.kata.controllers:KataHomeController'],
        'search': ['ckanext.kata.controllers:KataPackageController', 'package'],
        'organizations_index': ['ckanext.kata.controllers:KataOrganizationController', 'organization'],
        'about': ['home']
    }

    for item in args:
        menu_item, title = item[:2]
        if len(item) == 3 and not h.check_access(item[2]):
            continue

        _menu_items = config['routes.named_routes']
        _menu_item = copy.copy(_menu_items[menu_item])
        link = h._link_to(title, menu_item, suppress_active_class=True)
        active = h._link_active(_menu_item)

        if not active:
            # Ensure the reply is iterable: needed if variable routers is not consistent
            active = c.controller in routers.get(item[0], list())
        if active:
            output += literal('<li class="active">') + link + literal('</li>')
        else:
            output += literal('<li>') + link + literal('</li>')

    return output