Skip to content

Commit

Permalink
Addresses GSA/enterprise-data-inventory#51 where we have the server r…
Browse files Browse the repository at this point in the history
…eturning an HTTP 500 error when the datasets does not have a 'public_access_level' extras field. Modified so that if this extra isn't found, we default to public access level.
  • Loading branch information
dwcaraway authored and zr2d2 committed Dec 3, 2014
1 parent 6b4b982 commit a726c00
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ckanext/datajson/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,17 @@ def make_json():
#Create data.json only using public and public-restricted datasets, datasets marked non-public are not exposed
for pkg in packages:
extras = dict([(x['key'], x['value']) for x in pkg['extras']])
if not (re.match(r'[Nn]on-public', extras['public_access_level'])):
output.append(make_datajson_entry(pkg));
if not (re.match(r'[Nn]on-public', extras.get('public_access_level', 'Public'))):
output.append(make_datajson_entry(pkg))
return output

def make_edi(owner_org):
# Build the data.json file.
packages = p.toolkit.get_action("current_package_list_with_resources")(None, {})
output = []
for pkg in packages:
if pkg['owner_org']==owner_org:
output.append(make_datajson_entry(pkg));
if pkg['owner_org'] == owner_org:
output.append(make_datajson_entry(pkg))
return json.dumps(output)

def make_pdl(owner_org):
Expand All @@ -247,8 +247,9 @@ def make_pdl(owner_org):
#Create data.json only using public datasets, datasets marked non-public are not exposed
for pkg in packages:
extras = dict([(x['key'], x['value']) for x in pkg['extras']])
if pkg['owner_org']==owner_org and not (re.match(r'[Nn]on-public', extras['public_access_level'])):
output.append(make_datajson_entry(pkg));
if pkg['owner_org'] == owner_org \
and not (re.match(r'[Nn]on-public', extras.get('public_access_level', 'Public'))):
output.append(make_datajson_entry(pkg))
return json.dumps(output)

# TODO commenting out enterprise data inventory for right now
Expand Down

0 comments on commit a726c00

Please sign in to comment.