Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from ckan.lib.plugins import DefaultTranslation, DefaultDatasetForm
import ckan.plugins as plugins
import helpers as collection_helpers
from routes.mapper import SubMapper
class CollectionsPlugin(plugins.SingletonPlugin, DefaultDatasetForm):
plugins.implements(plugins.IDatasetForm, inherit=True)
plugins.implements(plugins.IRoutes, inherit=True)
plugins.implements(plugins.ITemplateHelpers)
# IDataSetForm
def package_types(self):
return ('collection', )
def is_fallback(self):
return False
# IRoutes
def before_map(self, map):
map.connect(
'/collection/{id}/aktuell',
controller='ckanext.odsh.collection.controller:LatestDatasetController',
action='latest_dataset'
)
map.connect(
'/collection/{id}/aktuell.{type}',
controller='ckanext.odsh.collection.controller:LatestRecourcesController',
action='latest_resource'
)
with SubMapper(
map,
controller='ckanext.odsh.collection.controller:LatestDatasetController',
path_prefix='/collection/'
) as m:
m.connect('latest', '{id}/aktuell', action='latest')
m.connect('latest_resource', '{id}/aktuell.{type}', action='latest_resource')
return map
def after_map(self, map):
return map
# ITemplateHelpers
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 {
'collection_get_successor': collection_helpers.get_successor,
'collection_get_predecessor': collection_helpers.get_predecessor,
'collection_get_latest_member':collection_helpers.latest_collection_member_persistent_link,
'collection_get_title': collection_helpers.get_collection_title_by_dataset,
}