Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class PieChart(BaseChart):
CHART_TYPE = 'pie'
GROUP_BY_IS_REQUIRED = True
def info(self):
info = super(PieChart, self).info()
info['name'] = 'piechart'
info['title'] = 'Pie Chart'
return info
class BasicGrid(p.SingletonPlugin):
p.implements(p.IConfigurer, inherit=True)
p.implements(p.IResourceView, inherit=True)
p.implements(p.ITemplateHelpers)
def get_helpers(self):
return {'view_data': _view_data}
def update_config(self, config):
here = os.path.dirname(__file__)
rootdir = os.path.dirname(os.path.dirname(here))
extra_template_paths = config.get('extra_template_paths', '')
template_dir = os.path.join(rootdir, 'ckanext', 'basiccharts',
'basicgrid', 'templates')
config['extra_template_paths'] = ','.join([template_dir,
extra_template_paths])
* Created On: April 3, 2014
* Copyright: (c) Brigham Young University 2014
* License: BSD 2-Clause
********************************************************************************
'''
import ckan.plugins as p
import ckan.model as model
from ckanext.tethys_apps.lib.app_harvester import SingletonAppHarvester
from ckanext.tethys_apps.lib import get_session_global, get_app_definition, jsonify
class AppsExtension(p.SingletonPlugin):
p.implements(p.IRoutes, inherit=True)
p.implements(p.IConfigurer, inherit=True)
p.implements(p.IAuthFunctions, inherit=True)
p.implements(p.ITemplateHelpers, inherit=True)
p.implements(p.IMiddleware, inherit=True)
#: Instantiate SingletonAppHarvester
harvester = SingletonAppHarvester()
harvester.harvest_apps()
def after_map(self, map):
# Controller for the apps plugin
map.connect('apps', '/apps',
controller='ckanext.tethys_apps.controllers.apps_main:AppsController',
action='index')
# Controller for secret snippets showcase page
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from ckan import plugins
from routes.mapper import SubMapper
import os.path
from ckanext.cloudstorage import storage
from ckanext.cloudstorage import helpers
import ckanext.cloudstorage.logic.action.multipart as m_action
import ckanext.cloudstorage.logic.auth.multipart as m_auth
class CloudStoragePlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IUploader)
plugins.implements(plugins.IRoutes, inherit=True)
plugins.implements(plugins.IConfigurable)
plugins.implements(plugins.IConfigurer)
plugins.implements(plugins.IActions)
plugins.implements(plugins.ITemplateHelpers)
plugins.implements(plugins.IAuthFunctions)
plugins.implements(plugins.IResourceController, inherit=True)
# IConfigurer
def update_config(self, config):
plugins.toolkit.add_template_directory(config, 'templates')
plugins.toolkit.add_resource('fanstatic/scripts', 'cloudstorage-js')
# ITemplateHelpers
def get_helpers(self):
return dict(
is_relative = (parsed_url.netloc == '')
is_in_same_domain = (parsed_url.netloc == site_url.netloc)
if not (is_relative or is_in_same_domain):
message = _('Must be a relative URL or in the same domain as CKAN')
raise Invalid(message)
return url
class NavigableMap(p.SingletonPlugin):
'''Creates a map view'''
p.implements(p.IConfigurer, inherit=True)
p.implements(p.IResourceView, inherit=True)
def update_config(self, config):
p.toolkit.add_template_directory(config, 'theme/templates')
p.toolkit.add_resource('theme/public', 'mapviews')
def info(self):
schema = {
'geojson_url': [not_empty, url_is_relative_or_in_same_domain],
'geojson_key_field': [not_empty],
'resource_key_field': [not_empty],
'resource_label_field': [not_empty],
'redirect_to_url': [ignore_missing],
#'filter_fields': [ignore_missing],
}
return {'name': 'navigable-map',
# -*- coding: utf-8 -*-
from ckan import plugins
from routes.mapper import SubMapper
import os.path
from ckanext.cloudstorage import storage
from ckanext.cloudstorage import helpers
import ckanext.cloudstorage.logic.action.multipart as m_action
import ckanext.cloudstorage.logic.auth.multipart as m_auth
class CloudStoragePlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IUploader)
plugins.implements(plugins.IRoutes, inherit=True)
plugins.implements(plugins.IConfigurable)
plugins.implements(plugins.IConfigurer)
plugins.implements(plugins.IActions)
plugins.implements(plugins.ITemplateHelpers)
plugins.implements(plugins.IAuthFunctions)
plugins.implements(plugins.IResourceController, inherit=True)
# IConfigurer
def update_config(self, config):
plugins.toolkit.add_template_directory(config, 'templates')
plugins.toolkit.add_resource('fanstatic/scripts', 'cloudstorage-js')
# ITemplateHelpers
def get_helpers(self):
return dict(
cloudstorage_use_secure_urls=helpers.use_secure_urls
)
from ckanext.datadotworld.model.credentials import Credentials
import ckan.model as model
import logging
import ckanext.datadotworld.tasks as tasks
import ckanext.datadotworld.api as api
import ckanext.datadotworld.helpers as dh
import os
from pylons import config
log = logging.getLogger(__name__)
class DatadotworldPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IConfigurer)
plugins.implements(plugins.IRoutes, inherit=True)
plugins.implements(plugins.IPackageController, inherit=True)
plugins.implements(plugins.ITemplateHelpers)
# ITemplateHelpers
def get_helpers(self):
return {
'datadotworld_link': api.API.generate_link,
'datadotworld_creds': api.API.creds_from_id,
'datadotworld_admin_in_orgs': dh.admin_in_orgs
}
# IConfigurer
def update_config(self, config_):
toolkit.add_template_directory(config_, 'templates')
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from ckan import plugins
from routes.mapper import SubMapper
import os.path
from ckanext.cloudstorage import storage
from ckanext.cloudstorage import helpers
import ckanext.cloudstorage.logic.action.multipart as m_action
import ckanext.cloudstorage.logic.auth.multipart as m_auth
class CloudStoragePlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IUploader)
plugins.implements(plugins.IRoutes, inherit=True)
plugins.implements(plugins.IConfigurable)
plugins.implements(plugins.IConfigurer)
plugins.implements(plugins.IActions)
plugins.implements(plugins.ITemplateHelpers)
plugins.implements(plugins.IAuthFunctions)
plugins.implements(plugins.IResourceController, inherit=True)
# IConfigurer
def update_config(self, config):
plugins.toolkit.add_template_directory(config, 'templates')
plugins.toolkit.add_resource('fanstatic/scripts', 'cloudstorage-js')
# ITemplateHelpers
def get_helpers(self):
import ckan.lib.helpers as helpers
import json
import collections
ignore_empty = toolkit.get_validator('ignore_empty')
ignore = toolkit.get_validator('ignore')
not_empty = toolkit.get_validator('not_empty')
ignore_missing = toolkit.get_validator('ignore_missing')
aslist = toolkit.aslist
log = logging.getLogger(__name__)
class DashboardView(p.SingletonPlugin):
'''This extenstion makes dashboard views'''
p.implements(p.IConfigurer, inherit=True)
p.implements(p.IResourceView, inherit=True)
p.implements(p.IPackageController, inherit=True)
p.implements(p.ITemplateHelpers)
p.implements(p.IConfigurable, inherit=True)
def update_config(self, config):
p.toolkit.add_template_directory(config, 'templates')
toolkit.add_resource('resources', 'dashboard-view')
def configure(self, config):
self.size = int(config.get('ckan.dashboard.size', 130))
def get_size(self):
return self.size
def get_helpers(self):
# Spanish (Argentina) = es_AR
# Spanish (Mexico) = es_MX
# Spanish (Spain) = es_ES
# Swedish = sv_SE
log = logging.getLogger(__name__)
class Disqus(p.SingletonPlugin):
'''
Insert javascript fragments into package pages and the home page to allow
users to view and create comments on any package.
'''
p.implements(p.IConfigurable)
p.implements(p.IConfigurer)
p.implements(p.ITemplateHelpers)
def configure(self, config):
'''
Called upon CKAN setup, will pass current configuration dict to the
plugin to read custom options. To implement Disqus Single Sign On,
you must have your secret and public key in the ckan config file. For
more info on Disqus SSO see:
https://help.disqus.com/customer/portal/articles/236206-integrating-single-sign-on
'''
disqus_name = config.get('disqus.name', None)
disqus_secret_key = config.get('disqus.secret_key', None)
disqus_public_key = config.get('disqus.public_key', None)
disqus_url = config.get('disqus.disqus_url', None)
site_url = config.get('ckan.site_url', None)
site_title = config.get('ckan.site_title', None)
if disqus_name is None:
def get_actions(self):
"""
publish dataset schemas
"""
return {
'scheming_dataset_schema_list': logic.scheming_dataset_schema_list,
'scheming_dataset_schema_show': logic.scheming_dataset_schema_show,
}
class SchemingGroupsPlugin(p.SingletonPlugin, _GroupOrganizationMixin,
DefaultGroupForm, _SchemingMixin):
p.implements(p.IConfigurer)
p.implements(p.ITemplateHelpers)
p.implements(p.IGroupForm, inherit=True)
p.implements(p.IActions)
p.implements(p.IValidators)
SCHEMA_OPTION = 'scheming.group_schemas'
FALLBACK_OPTION = 'scheming.group_fallback'
SCHEMA_TYPE_FIELD = 'group_type'
UNSPECIFIED_GROUP_TYPE = 'group'
@classmethod
def _store_instance(cls, self):
SchemingGroupsPlugin.instance = self
def about_template(self):
return 'scheming/group/about.html'
def group_form(group_type=None):