213 select country #214

Closed
wants to merge 4 commits into
from

Projects

None yet

2 participants

@balazstar
Contributor

Hi,

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.

Cheers,
Balázs

P.S.: The requested, storing preferred countries in settings file, will come in a separate request.

@steveyken
Member

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.

@balazstar
Contributor

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
like:
"Finland", "FI",
"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.
Neither does
https://github.com/rails/country_select/blob/master/lib/country_select.rb
or
https://github.com/jamesds/country-select/blob/master/lib/country-select.rb
have them.

Thanks for the help and guidance, it is really appreciated.

@steveyken
Member

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.

@balazstar
Contributor

Great to hear that. :)

@steveyken
Member

Pushed to master as of c805554 Thanks for your help!

@steveyken steveyken closed this Dec 21, 2012
@balazstar balazstar deleted the balazstar:213_select_country branch Dec 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment