Produces the DataStore page on a resource.
This page contains details of the resource's ingestion and indexing.
Source code in ckanext/versioned_datastore/routes/datastore.py
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
61
62
63
64
65
66 | @blueprint.route(
'/dataset/<package_name>/resource_data/<resource_id>', methods=['GET', 'POST']
)
def resource_data(package_name, resource_id):
"""
Produces the DataStore page on a resource.
This page contains details of the resource's ingestion and indexing.
"""
try:
# first, check access
toolkit.check_access('resource_update', {}, {'id': resource_id})
# then retrieve the package and resource data
toolkit.c.pkg_dict = toolkit.get_action('package_show')(
{}, {'id': package_name}
)
toolkit.c.resource = toolkit.get_action('resource_show')(
{}, {'id': resource_id}
)
except toolkit.ObjectNotFound:
toolkit.abort(404, toolkit._('Resource not found'))
except toolkit.NotAuthorized:
toolkit.abort(401, toolkit._('Unauthorized to edit this resource'))
if toolkit.request.method == 'POST':
toolkit.get_action('vds_data_sync')({}, {'resource_id': resource_id})
toolkit.h.flash_success(
toolkit._(
'Reindexing submitted, this may take a few minutes. You '
'can monitor progress below'
)
)
# redirect the user back to the page. This ensures they can do things like reload
# without getting a pesky "would you like to resubmit this form" notice
return toolkit.redirect_to(
'datastore.resource_data',
package_name=package_name,
resource_id=resource_id,
_code=303,
)
else:
extra_vars = {
'stats': get_all_stats(resource_id),
'reindex_action': toolkit.url_for(
'datastore.resource_data',
package_name=package_name,
resource_id=resource_id,
),
'pkg_dict': toolkit.c.pkg_dict,
'resource': toolkit.c.resource,
}
return toolkit.render('package/resource_data.html', extra_vars=extra_vars)
|