Allow uploading CSVs to CSV supporting Tasks through the UI #308
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #202
Allows files to be uploaded for CSV Tasks in the UI. I've modified any of the action partials that allow a Task to be run to use the form_helper so that we can allow files to be submitted via a file input upload tag. The views call a new method
TaskData#csv_task?
to determine whether to render the file upload element.I've also modified the TasksController show action to only set
@refresh
if there is an active run - this avoids unnecessarily refreshing when nothing is happening, which is particularly important for CSV Tasks, since the form might get refreshed before it is submitted with the current refresh behaviour (wiping the uploaded file).We may want to look into allowing CSV tasks to run from the command line, but this is out of scope for this PR.
🎩
You can tophat the success case using
Maintenance::ImportPostsTask
and uploadingsample.csv
from the fixturesFailing to upload a CSV:
Uploading a non-CSV file:
(Most scenarios where the CSV is invalid / not a CSV / does not conform to what is expected by
CSvTask#process
will simply be rescued and cause the Run to becomeerrored
, and don't need special treatment)