From 79b3cc8939ada552f1f8906c0f5d6e8b9492832c Mon Sep 17 00:00:00 2001 From: Gabriela Navarro Date: Tue, 28 Oct 2014 11:41:29 -0200 Subject: [PATCH] Save and redirects successfully. --- controllers/mpog_software_plugin_controller.rb | 21 ++++++++++++++++++--- views/mpog_software_plugin/_institution.html.erb | 13 +++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/controllers/mpog_software_plugin_controller.rb b/controllers/mpog_software_plugin_controller.rb index 7124a36..eac8386 100644 --- a/controllers/mpog_software_plugin_controller.rb +++ b/controllers/mpog_software_plugin_controller.rb @@ -47,13 +47,27 @@ class MpogSoftwarePluginController < ApplicationController end def create_institution_admin - + @url_token = split_http_referer request.original_url() + + if request.post? + governmental = {} + juridical = {} + governmental[:power] = params[:institutions][:governmental_power] + governmental[:sphere] = params[:institutions][:governmental_sphere] + juridical[:nature] = params[:institutions][:juridical_nature] + params[:community][:country] = "BR" + params[:institutions].delete :governmental_power + params[:institutions].delete :governmental_sphere + params[:institutions].delete :juridical_nature + redirect_to :action => "new_institution", :community => params[:community], :institution => params[:institutions], :governmental => governmental, :juridical => juridical + end end def split_http_referer http_referer split_list = [] split_list = http_referer.split("/") - return split_list.last + @url_token = split_list.last + return @url_token end @@ -71,7 +85,8 @@ class MpogSoftwarePluginController < ApplicationController if request.xhr? and (split_http_referer(request.referer()) != "create_institution_admin") render :json => response_message.to_json else - session[:notice] = response_message # consume the notice + session[:notice] = response_message[:message] # consume the notice + redirect_to :controller => "/admin_panel", :action => "index" end else redirect_to "/" diff --git a/views/mpog_software_plugin/_institution.html.erb b/views/mpog_software_plugin/_institution.html.erb index 399c05e..cc542e8 100644 --- a/views/mpog_software_plugin/_institution.html.erb +++ b/views/mpog_software_plugin/_institution.html.erb @@ -91,10 +91,15 @@
-
- <%= link_to(_('Save'), '#', :id=>'save_institution_button', :class=>'button with-text icon-add') %> -
- <%= hidden_field_tag :institution_error_message, _("Could not send the form data to the server") %> + <% if @url_token == "create_institution_admin" %> + <%= submit_button :save, _('Save') %> + <%else%> +
+ <%= link_to(_('Save'), '#', :id=>'save_institution_button', :class=>'button with-text icon-add') %> +
+ <%= hidden_field_tag :institution_error_message, _("Could not send the form data to the server") %> + <%end%> + <% end %> <% end %> -- libgit2 0.21.2