示例#1
0
 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)
示例#2
0
 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')
示例#3
0
 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')
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 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)