Commit 152c4ed698096355e61803ed6d320d841ab11d15
Committed by
Rafael Martins
1 parent
540b2236
Exists in
master
and in
29 other branches
Always shows fields for localization even if not enabled
Showing
2 changed files
with
10 additions
and
19 deletions
Show diff stats
app/controllers/my_profile/maps_controller.rb
@@ -6,18 +6,13 @@ class MapsController < MyProfileController | @@ -6,18 +6,13 @@ class MapsController < MyProfileController | ||
6 | @profile_data = profile | 6 | @profile_data = profile |
7 | if request.post? | 7 | if request.post? |
8 | begin | 8 | begin |
9 | - national_code = nil | ||
10 | - country = params[:profile_data][:country] | ||
11 | - city = params[:profile_data][:city] | ||
12 | - state = params[:profile_data][:state] | ||
13 | - | 9 | + country = params[:profile_data][:country] |
10 | + city = params[:profile_data][:city] | ||
11 | + state = params[:profile_data][:state] | ||
14 | nregion = NationalRegion.validate!(city, state, country) | 12 | nregion = NationalRegion.validate!(city, state, country) |
15 | - | ||
16 | - if nregion != nil | ||
17 | - national_code = nregion.national_region_code | 13 | + unless nregion.blank? |
14 | + params[:profile_data][:national_region_code] = nregion.national_region_code | ||
18 | end | 15 | end |
19 | - | ||
20 | - params[:profile_data]["national_region_code"] = national_code | ||
21 | 16 | ||
22 | Profile.transaction do | 17 | Profile.transaction do |
23 | if profile.update_attributes!(params[:profile_data]) | 18 | if profile.update_attributes!(params[:profile_data]) |
@@ -26,9 +21,7 @@ class MapsController < MyProfileController | @@ -26,9 +21,7 @@ class MapsController < MyProfileController | ||
26 | end | 21 | end |
27 | end | 22 | end |
28 | rescue Exception => exc | 23 | rescue Exception => exc |
29 | - | ||
30 | flash[:error] = exc.message | 24 | flash[:error] = exc.message |
31 | - | ||
32 | end | 25 | end |
33 | end | 26 | end |
34 | end | 27 | end |
app/views/maps/edit_location.rhtml
@@ -5,11 +5,11 @@ | @@ -5,11 +5,11 @@ | ||
5 | <% form_for :profile_data, :url => {:action => 'edit_location'} do |f| %> | 5 | <% form_for :profile_data, :url => {:action => 'edit_location'} do |f| %> |
6 | 6 | ||
7 | <div id='location-fields'> | 7 | <div id='location-fields'> |
8 | - <%= optional_field(profile, 'country', select_country(_('Country'), 'profile_data', 'country', {:class => 'type-select'})) %> | ||
9 | - <%= optional_field(profile, 'state', labelled_form_field(_('State'), f.text_field(:state))) %> | ||
10 | - <%= optional_field(profile, 'city', labelled_form_field(_('City'), f.text_field(:city))) %> | ||
11 | - <%= optional_field(profile, 'zip_code', labelled_form_field(_('ZIP code'), text_field(:profile_data, :zip_code))) %> | ||
12 | - <%= optional_field(profile, 'address', labelled_form_field(_('Address (street and number)'), text_field(:profile_data, :address))) %> | 8 | + <%= select_country _('Country'), 'profile_data', 'country', {:class => 'type-select'} %> |
9 | + <%= labelled_form_field _('State'), f.text_field(:state) %> | ||
10 | + <%= labelled_form_field _('City'), f.text_field(:city) %> | ||
11 | + <%= labelled_form_field _('ZIP code'), text_field(:profile_data, :zip_code) %> | ||
12 | + <%= labelled_form_field _('Address (street and number)'), text_field(:profile_data, :address) %> | ||
13 | <% button_bar do %> | 13 | <% button_bar do %> |
14 | <%= button_to_function :search, _('Locate in the map'), "codeAddress()", :title => _("Locate the address informed above in the map below (note that you'll probably need to adjust the marker to get a precise position)") %> | 14 | <%= button_to_function :search, _('Locate in the map'), "codeAddress()", :title => _("Locate the address informed above in the map below (note that you'll probably need to adjust the marker to get a precise position)") %> |
15 | <%= submit_button 'save', _('Save') %> | 15 | <%= submit_button 'save', _('Save') %> |
@@ -23,14 +23,12 @@ | @@ -23,14 +23,12 @@ | ||
23 | 23 | ||
24 | <%= f.hidden_field(:lat) %> | 24 | <%= f.hidden_field(:lat) %> |
25 | <%= f.hidden_field(:lng) %> | 25 | <%= f.hidden_field(:lng) %> |
26 | - | ||
27 | 26 | ||
28 | <% button_bar do %> | 27 | <% button_bar do %> |
29 | <%= submit_button 'save', _('Save') %> | 28 | <%= submit_button 'save', _('Save') %> |
30 | <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> | 29 | <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> |
31 | <% end %> | 30 | <% end %> |
32 | 31 | ||
33 | - | ||
34 | <% end %> | 32 | <% end %> |
35 | 33 | ||
36 | <%= render :partial => 'google_map'%> | 34 | <%= render :partial => 'google_map'%> |