def discussions_csv(org): datasets = Dataset.objects.filter(organization=str(org.id)) discussions = [Discussion.objects.filter(subject=dataset) for dataset in datasets] # Turns a list of lists into a flat list. adapter = IssuesOrDiscussionCsvAdapter(itertools.chain(*discussions)) return csv.stream(adapter, '{0}-discussions'.format(org.slug))
def discussions_csv(org): datasets = Dataset.objects.filter(organization=str(org.id)) discussions = [DatasetDiscussion.objects.filter(subject=dataset) for dataset in datasets] # Turns a list of lists into a flat list. adapter = IssuesOrDiscussionCsvAdapter(itertools.chain(*discussions)) return csv.stream(adapter, '{0}-discussions'.format(org.slug))
def organizations_csv(): params = multi_to_dict(request.args) # redirect to EXPORT_CSV dataset if feature is enabled and no filter is set exported_models = current_app.config.get('EXPORT_CSV_MODELS', []) if not params and 'organization' in exported_models: return redirect(get_export_url('organization')) params['facets'] = False organizations = search.iter(Organization, **params) return csv.stream(OrganizationCsvAdapter(organizations), 'organizations')
def reuses_csv(): params = multi_to_dict(request.args) # redirect to EXPORT_CSV dataset if feature is enabled and no filter is set exported_models = current_app.config.get('EXPORT_CSV_MODELS', []) if not params and 'reuse' in exported_models: return redirect(get_export_url('reuse')) params['facets'] = False reuses = search.iter(Reuse, **params) return csv.stream(ReuseCsvAdapter(reuses), 'reuses')
def datasets_csv(): params = multi_to_dict(request.args) # redirect to EXPORT_CSV dataset if feature is enabled and no filter is set exported_models = current_app.config.get('EXPORT_CSV_MODELS', []) if not params and 'dataset' in exported_models: return redirect(get_export_url('dataset')) params['facets'] = False datasets = search.iter(Dataset, **params) adapter = csv.get_adapter(Dataset) return csv.stream(adapter(datasets), 'datasets')
def datasets_resources_csv(org): datasets = search.iter(Dataset, organization=str(org.id)) adapter = ResourcesCsvAdapter(datasets) return csv.stream(adapter, '{0}-datasets-resources'.format(org.slug))
def from_nested(): qs = Fake.objects return csv.stream(NestedAdapter(qs))
def datasets_csv(): params = multi_to_dict(request.args) params['facets'] = False datasets = search.iter(Dataset, **params) adapter = csv.get_adapter(Dataset) return csv.stream(adapter(datasets), 'datasets')
def organizations_csv(): params = multi_to_dict(request.args) params['facets'] = False organizations = search.iter(Organization, **params) return csv.stream(OrganizationCsvAdapter(organizations), 'organizations')
def from_list(): return csv.stream(list(Fake.objects))
def supplied_datasets_resources_csv(org): datasets = Dataset.objects.filter(supplier=str(org.id)) adapter = ResourcesCsvAdapter(datasets) return csv.stream(adapter, '{0}-supplied-datasets-resources'.format(org.slug))
def from_queryset(): qs = Fake.objects assert isinstance(qs, db.BaseQuerySet) return csv.stream(qs)
def tags_csv(): adapter = TagCsvAdapter(Tag.objects.order_by('-total')) return csv.stream(adapter, 'tags')
def resources_csv(): params = multi_to_dict(request.args) params['facets'] = False datasets = search.iter(Dataset, **params) return csv.stream(ResourcesCsvAdapter(datasets), 'resources')
def with_basename(): cls = csv.get_adapter(Fake) adapter = cls(Fake.objects) return csv.stream(adapter, 'test')
def from_adapter(): cls = csv.get_adapter(Fake) adapter = cls(Fake.objects) return csv.stream(adapter)
def datasets_csv(org): datasets = search.iter(Dataset, organization=str(org.id)) adapter = DatasetCsvAdapter(datasets) return csv.stream(adapter, "{0}-datasets".format(org.slug))
def reuses_csv(): params = multi_to_dict(request.args) params['facets'] = False reuses = search.iter(Reuse, **params) return csv.stream(ReuseCsvAdapter(reuses), 'reuses')
def supplied_datasets_resources_csv(org): datasets = search.iter(Dataset, supplier=str(org.id)) adapter = ResourcesCsvAdapter(datasets) return csv.stream(adapter, '{0}-supplied-datasets-resources'.format(org.slug))