Skip to content

Commit

Permalink
[fix][s]: add check for resources without an organization (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolidori committed Dec 9, 2019
1 parent 5260164 commit ee9f5cb
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions ckanext/opendatani/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,15 @@ def check_rows(results, data_dict, rows):

for item in results['results']:
resources = item['resources']
organization = item['organization']
organization = item.get('organization')
organization_name = None
organization_url = None

if organization:
organization_name = organization.get('name')
organization_url = (
config.get('ckan.site_url') + '/organization/{0}'
.format(organization_name))

for resource in resources:

Expand All @@ -234,10 +242,8 @@ def check_rows(results, data_dict, rows):
.format(item.get('name')))),
('resource_name', resource.get('name')),
('resource_url', resource.get('url')),
('dataset_organization', organization.get('name')),
('dataset_organization_url', (
config.get('ckan.site_url') + '/organization/{0}'
.format(organization.get('name')))),
('dataset_organization', organization_name),
('dataset_organization_url', organization_url),
('resource_created', resource.get('created')),
('resource_last_modified', resource.get('last_modified')),
('resource_view_count', resource.get('tracking_summary', 0)),
Expand Down

0 comments on commit ee9f5cb

Please sign in to comment.