18F/peacecorps-site — pull request #99 by cmc333333 (2014-11-17 23:10:51+00:00)
Title: Updates to import script

Now that we've seen an example data file, the import script has been updated to account for issues found. I apologize for the size of the pull request -- it accounts for a lot of small issues.

* For the time being, accept datetimes in `%d-%b-%y` until the data can be cleaned up
* Previously, we had a manual mapping of "sector" values to campaign names. This takes a different strategy; whenever a sector fund is imported, an entry is added to the SectorMapping table. Determining the campaign associated with a given project using the "sector" field, then, is simply a lookup in that table
* `create_account_pcpp` has been split into a function for creating the account and campaign and a function for creation the project. Previously, we assumed that the list would only contain projects, so the logic needed to be altered to accommodate country, memorial, sector, and general funds.
* Added code to account for non-unique account names (the fund code is concatenated)
* Added code to account for non-unique project slugs (an integer is tacked on)
* Campaigns and Projects now automatically set their slug when saving.
* Multiple expected field names (as seen in the CSV) have been updated
* Description/summary is now imported
* The CSV does not include the current fund amount, but does include the fund's goal and "balance", so the logic is now a subtraction
* Determine if we're creating a project, country fund, memorial fund, etc. through heuristics (which match the provided data). See `account_type()`
* Assume a non-utf8 encoding to the import file