Example #1
0
    def __init__(self, route_map):
        self.route_map = route_map

        self.home_controller = 'ckanext.gobar_theme.controller:GobArHomeController'
        self.home_routes = SubMapper(self.route_map, controller=self.home_controller)
        self.api_controller = 'ckanext.gobar_theme.controller:GobArApiController'
        self.package_controller = 'ckanext.gobar_theme.package_controller:GobArPackageController'
Example #2
0
    def before_map(self, map):
        with SubMapper(
                map,
                controller='ckanext.collection.controller:CollectionController'
        ) as m:
            m.connect('collection.index', '/collection', action='index')

            m.connect('collection.new', '/collection/new', action='new')

            m.connect('collection.read', '/collection/:id', action='read')

            m.connect('collection.members',
                      '/collection/:id/members',
                      action='members')

            m.connect('collection.edit', '/collection/edit/:id', action='edit')

            m.connect('collection.delete',
                      '/collection/delete/:id',
                      action='delete')

            m.connect('collection.about',
                      '/collection/about/:id',
                      action='about')

            m.connect('dataset_collection_list',
                      '/dataset/collections/{id}',
                      action='dataset_collection_list',
                      ckan_icon='picture')

        map.redirect('/collections', '/collection')

        return map
Example #3
0
 def after_map(self, map):
     with SubMapper(
             map,
             controller='ckanext.canada.controller:CanadaController') as m:
         m.connect('/guidelines', action='view_guidelines')
         m.connect('/help', action='view_help')
         m.connect('/newuser', action='view_new_user')
     return map
Example #4
0
    def before_map(self, map):
        with SubMapper(
                map,
                controller='ckanext.welive_authentication.controller:WeliveAuthenticationController') as m:
            m.connect('login', '/user/login',
                      action='login', ckan_icon='cogs')

        return map
Example #5
0
 def connect_api(self):
     with SubMapper(self.route_map,
                    controller=self.api_controller,
                    path_prefix='/api{ver:/3|}',
                    ver='/3') as m:
         m.connect('/action/{logic_function}',
                   action='action',
                   conditions=dict(method=['GET', 'POST']))
Example #6
0
 def after_map(self, mapping):
     GA_CONTROLLER = """
         ckanext.datagovro_theme.controllers.gacontroller:GAController"""
     with SubMapper(mapping, controller=GA_CONTROLLER) as m:
         m.connect('ga_index',
                   '/datagovro_theme/ga',
                   action='index')
     return mapping
Example #7
0
 def connect_spatial(self):
     with SubMapper(self.route_map, controller=self.spatial_controller) as m:
         m.connect('countries', '/spatial/paises', action='paises'),
         m.connect('provinces', '/spatial/provincias', action='provincias'),
         m.connect('districts', '/spatial/localidades', action='localidades'),
         m.connect('districts', '/spatial/localidades/{province_id}', action='localidades'),
         m.connect('districts', '/spatial/municipios', action='municipios'),
         m.connect('districts', '/spatial/municipios/{province_id}', action='municipios'),
Example #8
0
    def before_map(self, map):

        rss_controller = 'ckanext.edc_rss.controllers.rss:RSSController'

        with SubMapper(map, controller=rss_controller) as m:
            m.connect('/feeds/recent.rss', action='recent')

        return map
Example #9
0
 def before_map(self, map):
     controller = 'ckanext.yammer.controller:YammerController'
     with SubMapper(map, controller=controller) as m:
         m.connect('ckanext_yammer_config',
                   '/organization/yammer_config/{id}',
                   action='yammer_config',
                   ckan_icon='bullhorn',
                   id='{id}')
     return map
Example #10
0
    def before_map(self, map):
        GET = dict(method=['GET'])

        # /api/util ver 1, 2 or none
        with SubMapper(map, controller='ckanext.dcatapit.controllers.api:DCATAPITApiController', path_prefix='/api{ver:/1|/2|}',
                       ver='/1') as m:
            m.connect('/util/vocabulary/autocomplete', action='vocabulary_autocomplete',
                      conditions=GET)
        return map
Example #11
0
    def before_map(self, map):
        # These named routes are used for custom dataset forms which will use
        # the names below based on the dataset.type ('dataset' is the default
        # type)
        with SubMapper(map, controller='ckanext.lacounts.controller:BlogController') as m: # noqa
            m.connect('blog_search', '/blog', action='search')
            m.connect('blog_read', '/blog/{id}', action='read')

        with SubMapper(map, controller='ckanext.lacounts.controller:StaticController') as m: # noqa
            m.connect('privacypolicy', '/privacy', action='privacypolicy')
            m.connect('termsofservice', '/terms', action='termsofservice')
            m.connect('faqs', '/faqs', action='faqs')
            m.connect('aboutus', '/about', action='aboutus')
            m.connect('resources', '/resources', action='resources')

        with SubMapper(map, controller='ckanext.lacounts.controller:GetInvolvedController') as m: # noqa
            m.connect('getinvolved', '/getinvolved', action='index')
            m.connect('getinvolved_admin', '/ckan-admin/get_involved_admin',
                      action='manage_get_involved'),
            m.connect('getinvolved_event_remove',
                      '/ckan-admin/getinvolved_remove_event',
                      action='remove_event')
            m.connect('getinvolved_new_event',
                      '/ckan-admin/getinvolved_new_event',
                      action='new_event')
            m.connect('getinvolved_edit_event',
                      '/ckan-admin/getinvolved_edit_event',
                      action='edit_event')
            m.connect('getinvolved_volunteering_remove',
                      '/ckan-admin/getinvolved_remove_volunteering',
                      action='remove_volunteering')
            m.connect('getinvolved_new_volunteering',
                      '/ckan-admin/getinvolved_new_volunteering',
                      action='new_volunteering')
            m.connect('getinvolved_edit_volunteering',
                      '/ckan-admin/getinvolved_edit_volunteering',
                      action='edit_volunteering')

        with SubMapper(map, controller='ckanext.lacounts.controller:AdminController') as m: # noqa
            m.connect('download_terms_sources_csv', '/ckan-admin/terms-sources-csv', action='download_terms_sources_csv')

        map.redirect('/why-la-counts', '/about',
                     _redirect_code='301 Moved Permanently')
        return map
    def before_map(self, map):
        from routes.mapper import SubMapper

        package_controller = 'ckanext.surrey.controller:SurreyPackageController'
        api_controller = 'ckanext.surrey.controller:SurreyAPIController'

        GET = dict(method=['GET'])
        map.connect('home', '/', controller='home', action='index')

        with SubMapper(map,
                       controller=package_controller,
                       path_prefix='/dataset') as m:
            m.connect('search',
                      '/',
                      action='search',
                      highlight_actions='index search')
            m.connect('add dataset', '/new', action='new')
            m.connect('request access',
                      '/{id}/access',
                      action='request_access')
            m.connect('download resource',
                      '/{id}/resource/{resource_id}/download/{filename}',
                      action='resource_download')
            m.connect('/{id}/resource/{resource_id}', action='resource_read')
            m.connect('dataset read',
                      '/{id}',
                      action='read',
                      ckan_icon='sitemap')
            m.connect('resources', '/resources/{id}', action='resources')

        with SubMapper(map,
                       controller=api_controller,
                       path_prefix='/api{ver:/1|/2|/3|}',
                       ver='/3') as m:
            m.connect('/action/package_list',
                      action='restricted_package_list',
                      conditions=GET)
            m.connect('/action/current_package_list_with_resources',
                      action='restricted_package_list_with_resources',
                      conditions=GET)
            m.connect('/action/package_show',
                      action='restricted_package_show',
                      conditions=GET)
        return map
Example #13
0
    def before_map(self, map):
        with SubMapper(
                map,
                controller=
                "ckanext.excelimport.controller.excelimport:ExcelImportController",
                path_prefix='/dashboard') as m:
            m.connect('import_from_zip',
                      '/import-from-zip',
                      action='import_from_zip')
        with SubMapper(
                map,
                controller=
                "ckanext.excelimport.controller.excelupdate:ExcelUpdateController",
                path_prefix='/dataset') as m:
            m.connect('dataset_update_zip',
                      '/update-from-zip/{id}',
                      action='update_from_zip')

        return map
Example #14
0
    def after_map(self, map):
        mapper = SubMapper(
            map, controller='ckanext.canada.controller:CanadaController')

        with mapper as m:
            m.connect('/guidelines', action='view_guidelines')
            m.connect('/help', action='view_help')
            m.connect('/datatable/{resource_name}/{resource_id}',
                      action='datatable')
        return map
    def before_map(self, map):
        '''Add new routes that this extension's controllers handle.
        '''
        from routes.mapper import SubMapper
        # /api ver 3 or none
        with SubMapper(map, controller='ckanext.data_qld.google_analytics.controller:GoogleAnalyticsApiController',
                       path_prefix='/api{ver:/3|}', ver='/3') as m:
            m.connect('/action/{api_action}', action='action', conditions={'method': ['GET', 'POST']})

        return map
Example #16
0
 def before_map(self, map):
     with SubMapper(
             map,
             controller='ckanext.fiwaredemo.controller:FiwaredemoController'
     ) as m:
         m.connect('ckanext_fiwaredemo_users',
                   '/organization/users/{id}',
                   action='users',
                   ckan_icon='users')
     return map
Example #17
0
    def before_map(self, map):
        static_controller = 'ckanext.iati.controllers.static:StaticController'

        with SubMapper(map, controller=static_controller) as m:
            map.redirect('/about-2', '/about',
                     _redirect_code='301 Moved Permanently')
            m.connect('help_csv-import', '/help_csv-import', action='help_csv')
            m.connect('help_delete', '/help_delete', action='help_delete')

        return map
def ga_enabled_routes_before_map(map):
    # Helpers to reduce code clutter
    GET = dict(method=['GET'])
    PUT = dict(method=['PUT'])
    POST = dict(method=['POST'])
    DELETE = dict(method=['DELETE'])
    GET_POST = dict(method=['GET', 'POST'])
    # intercept API calls that we want to capture analytics on
    register_list = [
        'package', 'dataset', 'resource', 'tag', 'group', 'related',
        'revision', 'licenses', 'rating', 'user', 'activity'
    ]
    register_list_str = '|'.join(register_list)
    # /api ver 3 or none
    with SubMapper(map,
                   controller=GA_API_CTRL,
                   path_prefix='/api{ver:/3|}',
                   ver='/3') as m:
        m.connect('/action/{logic_function}',
                  action='action',
                  conditions=GET_POST)

    # /api ver 1, 2, 3 or none
    with SubMapper(map,
                   controller=GA_API_CTRL,
                   path_prefix='/api{ver:/1|/2|/3|}',
                   ver='/1') as m:
        m.connect('/search/{register}', action='search')

    # /api/rest ver 1, 2 or none
    with SubMapper(map,
                   controller=GA_API_CTRL,
                   path_prefix='/api{ver:/1|/2|}',
                   ver='/1',
                   requirements=dict(register=register_list_str)) as m:

        m.connect('/rest/{register}', action='list', conditions=GET)
        m.connect('/rest/{register}', action='create', conditions=POST)
        m.connect('/rest/{register}/{id}', action='show', conditions=GET)
        m.connect('/rest/{register}/{id}', action='update', conditions=PUT)
        m.connect('/rest/{register}/{id}', action='update', conditions=POST)
        m.connect('/rest/{register}/{id}', action='delete', conditions=DELETE)
Example #19
0
 def before_map(self, map):
     '''Connect our package controller to resource download action'''
     m = SubMapper(
         map,
         controller='ckanext.datagovsg_s3_resources.controllers.package:\
             S3ResourcesPackageController')
     # Connect routes for resource download
     m.connect('resource_download',
               '/dataset/{id}/resource/{resource_id}/download',
               action="resource_download")
     return map
Example #20
0
    def __init__(self, route_map):
        self.route_map = route_map

        self.home_controller = 'ckanext.gobar_theme.controller:GobArHomeController'
        self.home_routes = SubMapper(self.route_map, controller=self.home_controller)
        self.api_controller = 'ckanext.gobar_theme.controller:GobArApiController'
        self.package_controller = 'ckanext.gobar_theme.package_controller:GobArPackageController'
        self.config_controller = 'ckanext.gobar_theme.config_controller:GobArConfigController'
        self.user_controller = 'ckanext.gobar_theme.user_controller:GobArUserController'
        self.google_analytics_controller = 'ckanext.gobar_theme.google_analytics_controller:GobArGAController'
        self.spatial_controller = 'ckanext.gobar_theme.spatial_controller:GobArSpatialController'
Example #21
0
    def before_map(self, map):
        ctrl = 'ckanext.edsnews.controllers.edsnews:EdsnewsController'
        with SubMapper(map, controller=ctrl) as m:
            m.connect('news_index', '/news', action='news_index')

            m.connect('news_create', '/news/create', action='news_create')
            m.connect('news_delete', '/news/delete/{id}', action='news_delete')
            m.connect('news_show', '/news/{id}', action='news_show')
            m.connect('news_update', '/news/update/{id}', action='news_update')

        return map
Example #22
0
def mapper_mixin(map, group_type, controller=None):
    """ Mixin for group types

    :map: TODO
    :group_type: TODO
    :returns: TODO

    """
    GET = dict(method=['GET'])
    with SubMapper(map, controller='api', path_prefix='/api{ver:/1|/2|}',
                ver='/1') as m:
        m.connect('/util/%s/autocomplete' % (group_type,), action='%s_autocomplete' % (group_type,),
                conditions=GET)

    with SubMapper(map, controller=controller) as m:
        m.connect('%s_about' % (group_type,), '/%s/about/{id}' % (group_type,),
                  action='about', ckan_icon='info-sign')
        m.connect('%s_bulk_process' % (group_type,),
                  '/%s/bulk_process/{id}' % (group_type,),
                  action='bulk_process', ckan_icon='sitemap')
    return map
Example #23
0
    def before_map(self, map):
        # These named routes are used for custom dataset forms which will use
        # the names below based on the dataset.type ('dataset' is the default
        # type)

        # Font Awesome was upgraded to v4 in CKAN 2.7
        is_fontawesome_v4 = tk.check_ckan_version(min_version='2.7')

        if is_fontawesome_v4:
            ckan_picture_icon = 'handshake-o'
        else:
            ckan_picture_icon = 'handshake'

        with SubMapper(
                map,
                controller='ckanext.experience.controller:ExperienceController'
        ) as m:
            m.connect('ckanext_experience_index',
                      '/experience',
                      action='search',
                      highlight_actions='index search')
            m.connect('ckanext_experience_new',
                      '/experience/new',
                      action='new')
            m.connect('ckanext_experience_delete',
                      '/experience/delete/{id}',
                      action='delete')
            m.connect('ckanext_experience_read',
                      '/experience/{id}',
                      action='read',
                      ckan_icon=ckan_picture_icon)
            m.connect('ckanext_experience_edit',
                      '/experience/edit/{id}',
                      action='edit',
                      ckan_icon='edit')
            m.connect('ckanext_experience_manage_datasets',
                      '/experience/manage_datasets/{id}',
                      action="manage_datasets",
                      ckan_icon="sitemap")
            m.connect('dataset_experience_list',
                      '/dataset/experiences/{id}',
                      action='dataset_experience_list',
                      ckan_icon=ckan_picture_icon)
            m.connect('ckanext_experience_admins',
                      '/ckan-admin/experience_admins',
                      action='manage_experience_admins',
                      ckan_icon=ckan_picture_icon),
            m.connect('ckanext_experience_admin_remove',
                      '/ckan-admin/experience_admin_remove',
                      action='remove_experience_admin')
        map.redirect('/experiences', '/experience')
        map.redirect('/experiences/{url:.*}', '/experience/{url}')
        return map
Example #24
0
 def before_map(self, route_map):
     """ Add some custom routes for Queensland Government portals.
     """
     controller = 'ckanext.qgov.common.controller:QGOVController'
     with SubMapper(route_map, controller=controller) as mapper:
         mapper.connect('article',
                        '/article/{path:[-_a-zA-Z0-9/]+}',
                        action='static_content')
         mapper.connect('submit_feedback',
                        '/api/action/submit_feedback',
                        action='submit_feedback')
         return route_map
Example #25
0
 def before_map(self, map):
     org_controller = 'ckan.controllers.organization:OrganizationController'
     with SubMapper(map, controller=org_controller) as m:
         m.connect('organization_activity',
                   '/organization/activity/{id}/{offset}',
                   action='activity',
                   ckan_icon='time')
     map.connect('crs',
                 '/autocomplete/crs',
                 controller='ckanext.gspfdataset.GspfDatasetPlugin',
                 action='crs_json')
     return map
Example #26
0
    def before_map(self, map):
        """Add few routes."""
        with SubMapper(map,
                       controller='ckanext.saml2.plugin:Saml2Controller') as m:
            m.connect('saml2_unauthorized',
                      '/saml2_unauthorized',
                      action='saml2_unauthorized')
            m.connect('saml2_slo', '/slo', action='slo')
            m.connect('staff_login', '/service/login', action='staff_login')
            m.connect('acs', '/acs', action='acs')

        return map
Example #27
0
 def connect_datasets(self):
     with SubMapper(self.route_map, controller=self.package_controller) as m:
         m.connect('search', '/dataset', action='search', highlight_actions='index search')
         m.connect('add dataset', '/dataset/new', action='new')
     self.route_map.connect('/dataset/{id}/archivo/{resource_id}', action='resource_read', controller='package')
     self.redirect(
         ('/dataset/history/{id:.*?}', '/dataset/{id}'),
         ('/dataset/activity/{id:.*?}', '/dataset/{id}'),
         ('/dataset/groups/{id:.*?}', '/dataset/{id}'),
         ('/dataset/followers/{id:.*?}', '/dataset/{id}'),
         ('/dataset/{id}/resource/{resource_id}', '/dataset/{id}/archivo/{resource_id}')
     )
Example #28
0
 def before_map(self, map):
     report_ctlr = 'ckanext.statsresources.controllers:StatsresourcesController'
     with SubMapper(map, controller=report_ctlr,
                    action='recheck_access') as m:
         m.connect('reports', '/report', original_action='index')
         m.connect('report', '/report/:report_name', original_action='view')
         m.connect('report-org',
                   '/report/:report_name/:organization',
                   original_action='view')
     map.connect('/data/report/{url:.*}',
                 controller=report_ctlr,
                 action='data_redirect')
     return map
Example #29
0
    def before_map(self, map):
        ctrl = 'ckanext.calendar.controllers.calendar:CalendarController'
        with SubMapper(map, controller=ctrl) as m:
            m.connect('event_index', '/events', action='event_index')
            m.connect('event_create', '/events/create',
                      action='event_create')
            m.connect('event_delete', '/events/delete/{id}',
                      action='event_delete')
            m.connect('event_show', '/events/{id}',
                      action='event_show')
            m.connect('event_update', '/events/update/{id}',
                      action='event_update')

        return map
Example #30
0
    def before_map(self, map):

        map.redirect('/organization', '/country',
                     _redirect_code='301 Moved Permanently')
        
        map.redirect('/group', '/theme',
                     _redirect_code='301 Moved Permanently')
        map.redirect('/group/{url:.*}', '/theme/{url}',
                     _redirect_code='301 Moved Permanently')

        
        ctrls = ['ckanext.montrose.controllers.country:CountryController', 
                 'ckanext.montrose.controllers.theme:ThemeController']
        keys = ['country', 'theme']
        for ctrl, v in zip(ctrls, keys):
            with SubMapper(map, controller=ctrl) as m:
                m.connect('%s_index' % v, '/{}'.format(v), action='index')
                m.connect('/{}/list'.format(v), action='list')
                m.connect('/{}/new'.format(v), action='new')
                m.connect('/delete/{}'.format(v), action='delete')
                m.connect('{}_read'.format(v), '/%s/{id}' % v, action='read')
                m.connect('{}_edit'.format(v), '/%s/edit/{id}' % v,
                          action='edit', ckan_icon='edit')
                
                m.connect('/%s/{action}/{id}' % v,
                          requirements=dict(action='|'.join([
                              'admins',
                              'member_new',
                              'member_delete',
                              'history'
                              'followers',
                              'follow',
                              'unfollow',
                          ])))
                
                m.connect('{}_activity'.format(v), '/%s/activity/{id}' % v,
                          action='activity', ckan_icon='time')
                m.connect('{}_read'.format(v), '/%s/{id}' % v, action='read')
                m.connect('{}_about'.format(v), '/%s/about/{id}' % v,
                          action='about', ckan_icon='info-sign')
                m.connect('{}_read'.format(v), '/%s/{id}' % v, action='read',
                          ckan_icon='sitemap')
    
                m.connect('{}_members'.format(v), '/%s/members/{id}' % v,
                          action='members', ckan_icon='group')
                m.connect('{}_bulk_process'.format(v),
                          '/%s/bulk_process/{id}' % v,
                          action='bulk_process', ckan_icon='sitemap')

        return map