Skip to content

Commit

Permalink
cleanup api json output
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Aug 9, 2012
1 parent e76ee02 commit 28137ef
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions ckanext/qa/controllers/qa_api.py
Expand Up @@ -47,11 +47,13 @@ def make_csv(result, headers, rows):
class ApiController(QAController):

def resource_five_stars(self, id):
return json.dumps(resource_five_stars(id))

result = resource_five_stars(id)
return self._output_jsrn(result)

def dataset_five_stars(self, id=None):
return json.dumps(five_stars(id))

result = five_stars(id)
return self._output_jsrn(result)

def broken_resource_links_by_dataset(self, format='json'):
result = broken_resource_links_by_dataset()
if format == 'csv':
Expand All @@ -75,8 +77,7 @@ def broken_resource_links_by_dataset(self, format='json'):
rows,
)
else:
response.headers['Content-Type'] = 'application/json'
return json.dumps(result)
return self._output_json(result)

def organisations_with_broken_resource_links(self, id, format='json'):
result = organisations_with_broken_resource_links()
Expand Down Expand Up @@ -104,8 +105,7 @@ def organisations_with_broken_resource_links(self, id, format='json'):
rows,
)
else:
response.headers['Content-Type'] = 'application/json'
return json.dumps(result)
return self._output_json(result)

def broken_resource_links_by_dataset_for_organisation(self, id, format='json'):
result = broken_resource_links_by_dataset_for_organisation(id)
Expand All @@ -132,6 +132,8 @@ def broken_resource_links_by_dataset_for_organisation(self, id, format='json'):
rows,
)
else:
response.headers['Content-Type'] = 'application/json'
return json.dumps(result)
return self._output_json(result)

def _output_json(self, data):
response.headers['Content-Type'] = 'application/json'
return json.dumps(data)

0 comments on commit 28137ef

Please sign in to comment.