I have created this pull request based on our discussion on issue #213.
I have also added the rake task for data upgrade. (this can be possibly written for faster execution, if needed)
Please examine with care, this request changes the format how ffcrm stores countries.
A bug can cause data loss for users.
If any questions arise, feel free to contact me.
P.S.: The requested, storing preferred countries in settings file, will come in a separate request.
Update COUNTRIES from Wikipedia ISO 3166-1
Add ISO codes to priority countries
Add rake task for country code update to 3166-1
Update demo data load to ISO 3166-1 country codes (USA->US)
Thanks for this. I've merged your changes into a country_select branch ( see https://github.com/fatfreecrm/fat_free_crm/tree/country_select )
I've also added a 'preferred_countries' option to the address helper and settings file.
Now that I'm looking at the script, I'm wondering if there are will be conversion clashes when the rake task is run... e.g. someone chose Australia (incorrectly marked as 'AT') prior to this work, but now it will display as 'Austria' instead. The rake script won't currently auto-migrate this as it's only looking for country names, not bad ISO's.
I think we should fix that by enumerating all the existing errors and then encourage people to update and run the country rake script.
By the way, was the country_select really badly wrong in many cases? Or did they use a different ISO standard?
Also, I'm wondering if, in the near future, we should consider moving to a more first class country model so that addresses can easily extract the country name. Currently there is no way to get at the country list from outside the FormHelper.
Anyway, that's for later.
Thanks again for your work here, it's much appreciated.
Thanks for adding the settings.
I am not sure what you mean by
"I'm wondering if there are will be conversion clashes when the rake task is run... e.g. someone chose Australia (incorrectly marked as 'AT') prior to this work, but now it will display as 'Austria' instead."
The convert_table array in the rake task contains the old and the new code of a country.
Country names are not used while running the task, it is only there for clarity.
so for example
Australia was AS now it will be AU
Austria was AU now it will be AT
The only place where I see problems where the old country codes are the same
"Aland Islands", "FI"
However since Finland was a priority country it was stored as Finland and not as FI
About the ISO codes,
I am not sure where they come in the first place.
Thanks for the help and guidance, it is really appreciated.
My bad, I think all you've done is right. Australia was 'AS' in the old system and in the new it is corrected to "AU" so there won't be a problem. I'm hoping to incorporate this tomorrow.
Great to hear that. :)
Pushed to master as of c805554 Thanks for your help!