From 20d8849666eb1f43a6c75e5710bb6acdbdeac271 Mon Sep 17 00:00:00 2001 From: Arthur Del Esposte Date: Tue, 29 Sep 2015 18:14:57 -0300 Subject: [PATCH] Improve insitution edit page --- controllers/gov_user_plugin_myprofile_controller.rb | 14 ++++++++++---- views/gov_user_plugin_myprofile/edit_institution.html.erb | 23 ++++++++++------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/controllers/gov_user_plugin_myprofile_controller.rb b/controllers/gov_user_plugin_myprofile_controller.rb index 4d14d3d..6b4d03e 100644 --- a/controllers/gov_user_plugin_myprofile_controller.rb +++ b/controllers/gov_user_plugin_myprofile_controller.rb @@ -6,9 +6,11 @@ class GovUserPluginMyprofileController < MyProfileController def edit_institution @show_sisp_field = environment.admins.include?(current_user.person) - @state_list = NationalRegion.find(:all, :conditions => - { :national_region_type_id => 2 }, - :order => 'name') + @state_list = NationalRegion.find( + :all, + :conditions => { :national_region_type_id => 2 }, + :order => 'name' + ) @institution = @profile.institution update_institution if request.post? end @@ -26,7 +28,11 @@ class GovUserPluginMyprofileController < MyProfileController _("Could not find Governmental Power or Governmental Sphere")) end end - flash[:errors] = @institution.errors.full_messages unless @institution.valid? + if @institution.valid? + redirect_to :controller => 'profile_editor', :action => 'index', :profile => profile.identifier + else + flash[:errors] = @institution.errors.full_messages + end end def governmental_updates diff --git a/views/gov_user_plugin_myprofile/edit_institution.html.erb b/views/gov_user_plugin_myprofile/edit_institution.html.erb index 06d2c04..7b0f936 100644 --- a/views/gov_user_plugin_myprofile/edit_institution.html.erb +++ b/views/gov_user_plugin_myprofile/edit_institution.html.erb @@ -6,23 +6,20 @@ <%end %> -<% unless flash[:errors].nil? %> -
-

<%= _("Can`t create new Institution: #{flash[:errors].length} errors") %>

- -
+<% unless flash[:errors].blank? %> +
+

<%= _("Can`t create new Institution: #{flash[:errors].length} errors") %>

+ +
<% end %>
-
- <%= _("All fields with (*) are mandatory") %> -
<%= labelled_form_for :community,:html => { :multipart => true, :id=>"institution_form" } do |f| %> <%= hidden_field_tag "edit_institution_page", true %> <%= fields_for :institutions do |inst| %> @@ -61,7 +58,7 @@ <%= required f.text_field(:city, :value => @institution.community.city) %> - +
<%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %> <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field", :value => @institution.cnpj) %> -- libgit2 0.21.2