From 152c4ed698096355e61803ed6d320d841ab11d15 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Tue, 14 Feb 2012 21:40:45 -0200 Subject: [PATCH] Always shows fields for localization even if not enabled --- app/controllers/my_profile/maps_controller.rb | 17 +++++------------ app/views/maps/edit_location.rhtml | 12 +++++------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/app/controllers/my_profile/maps_controller.rb b/app/controllers/my_profile/maps_controller.rb index 1ecac1a..6eb8ed6 100644 --- a/app/controllers/my_profile/maps_controller.rb +++ b/app/controllers/my_profile/maps_controller.rb @@ -6,18 +6,13 @@ class MapsController < MyProfileController @profile_data = profile if request.post? begin - national_code = nil - country = params[:profile_data][:country] - city = params[:profile_data][:city] - state = params[:profile_data][:state] - + country = params[:profile_data][:country] + city = params[:profile_data][:city] + state = params[:profile_data][:state] nregion = NationalRegion.validate!(city, state, country) - - if nregion != nil - national_code = nregion.national_region_code + unless nregion.blank? + params[:profile_data][:national_region_code] = nregion.national_region_code end - - params[:profile_data]["national_region_code"] = national_code Profile.transaction do if profile.update_attributes!(params[:profile_data]) @@ -26,9 +21,7 @@ class MapsController < MyProfileController end end rescue Exception => exc - flash[:error] = exc.message - end end end diff --git a/app/views/maps/edit_location.rhtml b/app/views/maps/edit_location.rhtml index 6ddce29..488598e 100644 --- a/app/views/maps/edit_location.rhtml +++ b/app/views/maps/edit_location.rhtml @@ -5,11 +5,11 @@ <% form_for :profile_data, :url => {:action => 'edit_location'} do |f| %>
- <%= optional_field(profile, 'country', select_country(_('Country'), 'profile_data', 'country', {:class => 'type-select'})) %> - <%= optional_field(profile, 'state', labelled_form_field(_('State'), f.text_field(:state))) %> - <%= optional_field(profile, 'city', labelled_form_field(_('City'), f.text_field(:city))) %> - <%= optional_field(profile, 'zip_code', labelled_form_field(_('ZIP code'), text_field(:profile_data, :zip_code))) %> - <%= optional_field(profile, 'address', labelled_form_field(_('Address (street and number)'), text_field(:profile_data, :address))) %> + <%= select_country _('Country'), 'profile_data', 'country', {:class => 'type-select'} %> + <%= labelled_form_field _('State'), f.text_field(:state) %> + <%= labelled_form_field _('City'), f.text_field(:city) %> + <%= labelled_form_field _('ZIP code'), text_field(:profile_data, :zip_code) %> + <%= labelled_form_field _('Address (street and number)'), text_field(:profile_data, :address) %> <% button_bar do %> <%= 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)") %> <%= submit_button 'save', _('Save') %> @@ -23,14 +23,12 @@ <%= f.hidden_field(:lat) %> <%= f.hidden_field(:lng) %> - <% button_bar do %> <%= submit_button 'save', _('Save') %> <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> <% end %> - <% end %> <%= render :partial => 'google_map'%> -- libgit2 0.21.2