alphagov/transition — pull request #334 by jennyd (2014-06-27 17:52:31+00:00)
Title: Import mappings

[Giant story](https://www.pivotaltracker.com/n/projects/887836/stories/69025116), giant PR :mount_fuji: :whale: :ocean: :whale2: :elephant: :earth_asia:

__Things to note:__
- rows which don't start with something which can be parsed and canonicalized to a path are ignored silently, This means that we exclude header rows but also possibly data rows which were eg missing a leading slash. This is consistent with bulk add's behaviour.
- detecting whether the input is CSV or TSV is done very simplistically.
- if the second column contains a TNA URL, the mapping is made an archive but the custom URL is not preserved; we're making that behaviour a separate story.
- we haven't done anything special with spaces in the input; URLs could contain unencoded spaces, so trying to ignore or split on them would be incorrect.
- entries are displayed on the preview page in insert order; it's not clear what the expected ordering would otherwise be, bearing in mind that canonicalization and deduplication will have changed the apparent order from the input anyway.
- we don't consider the type of existing mappings when overwriting them; if the option to overwrite is selected, all existing mappings will be overwritten even if they were eg redirects and the import says they should be unresolved. If we want different behaviour, that will be a separate story.

__Things left to change/do:__
- make the validation error messages a bit more specific, eg by including the relevant URL in every case
- test with very large batches