Mike-Heneghan / ALISS

ALISS (A Local Information System for Scotland) is a service to help you find help and support close to you when you need it most.
https://aliss.org
0 stars 0 forks source link

Add a csv export feature. #34

Closed Mike-Heneghan closed 5 years ago

Mike-Heneghan commented 5 years ago

CSV

First as a management command (like digest emails).

We want the following to be filterable by published orgs/services/whatever, for public consumption.

Services

id, name, description, url, phone, email, aliss_url, permalink, last_edited, organisation_id, organisation_name, organisation_permalink, categories, service_areas, location_ids

Locations

id, formatted_address, name, locality, region, postal_code, country, latitude, longitude, organisation_name, organisation_id, organisation_permalink

Services at location

service_id, location_id, service_name, service_permalink, formatted_address, organisation_id

name this services_at_location.csv

Organisations

Default queryset should be: Service.objects.values('organisation_id').distinct(), also with option to include unpublished.

id, name, description, aliss_url, permalink, url, twitter, facebook, phone, email, last_edited, service_names, service_ids, service_permalinks

Notes

String wrap, and comma separate categories and service areas using slugs. For locations comma separate the ids and/or permalinks.

Be careful to escape quotation marks in descriptions. Try testing against quotation mark and comma characters

Mike-Heneghan commented 5 years ago

Django has a csv library for streaming csv from a view https://docs.djangoproject.com/en/2.1/howto/outputting-csv/.

Interesting although I don't think the is the way we want to implement this function.

Mike-Heneghan commented 5 years ago

Using an import/export library and adding it to the admin: https://www.youtube.com/watch?v=vYIuvSwLsMc

Mike-Heneghan commented 5 years ago

Information on CSV export: https://djangotricks.blogspot.com/2013/12/how-to-export-data-as-excel.html

Mike-Heneghan commented 5 years ago

Maybe best approach is to try exporting one model as a csv and work from there.

Further information form a blog post about generating csv files from the backend: http://blog.aeguana.com/2015/12/12/csv-export-data-for-django-model/

Mike-Heneghan commented 5 years ago

Open Referral docs https://openreferral.readthedocs.io/en/latest/

Mike-Heneghan commented 5 years ago
Mike-Heneghan commented 5 years ago

Could create a new term to determine how a variable is handled. Could write methods which generate a permalink for the model record.

Mike-Heneghan commented 5 years ago

To Do List:

Mike-Heneghan commented 5 years ago

To do list:

Mike-Heneghan commented 5 years ago

For making the results of the CSV more accurate we could use .distinct(field to compare against) for the organisations. Although how do we ensure the unique organisation returned is the one we want? We could potentially order_by something like last_edited or only include organisations which have greater than 0 services?

Mike-Heneghan commented 5 years ago

To resolve the issue with dummy data being committed created a new branch and copied the code across.

Mike-Heneghan commented 5 years ago

Merged into master