Skip to content
Snippets Groups Projects
plugin.py 985 B
Newer Older
  • Learn to ignore specific revisions
  • anonymous's avatar
    anonymous committed
    import ckan.plugins as plugins
    import ckan.plugins.toolkit as toolkit
    
    
    def odsh_main_groups():
        '''Return a list of the groups to be shown on the start page.'''
    
        # Get a list of all the site's groups from CKAN, sorted by number of
        # datasets.
        groups = toolkit.get_action('group_list')(
            data_dict={'all_fields': True})
    
        return groups
    
    anonymous's avatar
    anonymous committed
    
    class OdshPlugin(plugins.SingletonPlugin):
        plugins.implements(plugins.IConfigurer)
    
        plugins.implements(plugins.ITemplateHelpers)
    
    anonymous's avatar
    anonymous committed
    
        # IConfigurer
    
        def update_config(self, config_):
            toolkit.add_template_directory(config_, 'templates')
            toolkit.add_public_directory(config_, 'public')
    
            toolkit.add_resource('fanstatic', 'odsh')
        
        def get_helpers(self):
            # Template helper function names should begin with the name of the
            # extension they belong to, to avoid clashing with functions from
            # other extensions.
            return {'odsh_main_groups': odsh_main_groups}