def broken_resource_links_by_dataset_for_organisation( self, id, format='json'): result = broken_resource_links_by_dataset_for_organisation(id) if format == 'csv': filename = '%s.csv' % (id) response.headers['Content-Type'] = 'application/csv' response.headers['Content-Disposition'] = str( 'attachment; filename=%s' % (filename)) rows = [] for dataset, resources in result['packages'].items(): for resource in resources: row = [ result['title'], unicode(result['id']), dataset[0], dataset[1], resource.get('url'), unicode(resource.get('openness_score')), resource.get('openness_score_reason'), ] rows.append(row) return make_csv( result, headers, rows, ) else: response.headers['Content-Type'] = 'application/json' return json.dumps(result)
def broken_resource_links(self, id=None): if id is None: c.organisations = organisations_with_broken_resource_links_by_name() return render('ckanext/qa/organisation/broken_resource_links/index.html') else: c.id = id c.organisation = broken_resource_links_by_dataset_for_organisation(organisation_id=id) return render('ckanext/qa/organisation/broken_resource_links/organisation.html')
def broken_resource_links(self, id=None): if id is None: c.organisations = organisations_with_broken_resource_links_by_name( ) return render('qa/organisation_broken_resource_links.html') else: c.id = id c.organisation = broken_resource_links_by_dataset_for_organisation( organisation_id=id) return render('qa/broken_resource_links_for_organisation.html')
def broken_resource_links_by_dataset_for_organisation(self, id, format='json'): result = broken_resource_links_by_dataset_for_organisation(id) if format == 'csv': rows = [] for dataset, resources in result['packages'].items(): for resource in resources: row = [ result['title'], unicode(result['id']), dataset[0], dataset[1], resource.get('url'), unicode(resource.get('openness_score')), resource.get('openness_score_reason'), ] rows.append(row) return self._output_csv_file(self.headers, rows, id) else: 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) if format == 'csv': rows = [] for dataset, resources in result['packages'].items(): for resource in resources: row = [ result['title'], unicode(result['id']), dataset[0], dataset[1], resource.get('url'), unicode(resource.get('openness_score')), resource.get('openness_score_reason'), ] rows.append(row) return self._output_csv_file(self.headers, rows, id) else: 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) if format == "csv": filename = "%s.csv" % (id) response.headers["Content-Type"] = "application/csv" response.headers["Content-Disposition"] = str("attachment; filename=%s" % (filename)) rows = [] for dataset, resources in result["packages"].items(): for resource in resources: row = [ result["title"], unicode(result["id"]), dataset[0], dataset[1], resource.get("url"), unicode(resource.get("openness_score")), resource.get("openness_score_reason"), ] rows.append(row) return make_csv(result, headers, rows) else: response.headers["Content-Type"] = "application/json" return json.dumps(result)