-
Notifications
You must be signed in to change notification settings - Fork 45
Export Tool File Formats
Adding new export tasks to the service entails a number of steps and requires making changes to the code in several places. The two main packages involved are tasks and utils. The tasks package defines the interfaces with the Celery task queue. The utils package defines the actual work done to create the export. An ExportTask, in the tasks package, essentially wraps the corresponding utility in the utils package.
New export tasks should extend the abstract class ExportTask. The new export task should define a run method that returns a dictionary containing a 'result' key with the value being the path to the resulting export file. The new export task should also define a 'name' attribute. See the other subclasses of ExportTask for examples of how this should be done. The new export task will be picked up automatically when the celery workers are restarted (which should be done whenever any of the export tasks are changed or new tasks added).
A utility should be added to the utils package which does the work of creating the new export files. See example utilities in the utils package.
Once the new export task has been defined and the new utility added, the EXPORT_TASKS setting in the project settings file should be updated to add the fully qualified path to the new export task. The setting is a dictionary mapping a 'slug' for the export task to the export task class.
The UI must then be updated to reflect the fact that a new export format is available. This can be done by adding a new ExportFormat object in the admin interface. The 'slug' in the ExportFormat should map to the 'slug' in the settings. Ideally the insert_export_formats migration should be updated to add the new format.
Finally, the UI needs to be updated to report the status of pending, running and completed export tasks. Three methods in the detail.js file need to be updated to report the status of the export task.