Commit 79b3cc8939ada552f1f8906c0f5d6e8b9492832c
1 parent
72f615dd
Exists in
master
and in
5 other branches
Save and redirects successfully.
Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
2 changed files
with
27 additions
and
7 deletions
Show diff stats
controllers/mpog_software_plugin_controller.rb
| ... | ... | @@ -47,13 +47,27 @@ class MpogSoftwarePluginController < ApplicationController |
| 47 | 47 | end |
| 48 | 48 | |
| 49 | 49 | def create_institution_admin |
| 50 | - | |
| 50 | + @url_token = split_http_referer request.original_url() | |
| 51 | + | |
| 52 | + if request.post? | |
| 53 | + governmental = {} | |
| 54 | + juridical = {} | |
| 55 | + governmental[:power] = params[:institutions][:governmental_power] | |
| 56 | + governmental[:sphere] = params[:institutions][:governmental_sphere] | |
| 57 | + juridical[:nature] = params[:institutions][:juridical_nature] | |
| 58 | + params[:community][:country] = "BR" | |
| 59 | + params[:institutions].delete :governmental_power | |
| 60 | + params[:institutions].delete :governmental_sphere | |
| 61 | + params[:institutions].delete :juridical_nature | |
| 62 | + redirect_to :action => "new_institution", :community => params[:community], :institution => params[:institutions], :governmental => governmental, :juridical => juridical | |
| 63 | + end | |
| 51 | 64 | end |
| 52 | 65 | |
| 53 | 66 | def split_http_referer http_referer |
| 54 | 67 | split_list = [] |
| 55 | 68 | split_list = http_referer.split("/") |
| 56 | - return split_list.last | |
| 69 | + @url_token = split_list.last | |
| 70 | + return @url_token | |
| 57 | 71 | end |
| 58 | 72 | |
| 59 | 73 | |
| ... | ... | @@ -71,7 +85,8 @@ class MpogSoftwarePluginController < ApplicationController |
| 71 | 85 | if request.xhr? and (split_http_referer(request.referer()) != "create_institution_admin") |
| 72 | 86 | render :json => response_message.to_json |
| 73 | 87 | else |
| 74 | - session[:notice] = response_message # consume the notice | |
| 88 | + session[:notice] = response_message[:message] # consume the notice | |
| 89 | + redirect_to :controller => "/admin_panel", :action => "index" | |
| 75 | 90 | end |
| 76 | 91 | else |
| 77 | 92 | redirect_to "/" | ... | ... |
views/mpog_software_plugin/_institution.html.erb
| ... | ... | @@ -91,10 +91,15 @@ |
| 91 | 91 | </span> |
| 92 | 92 | <br /> |
| 93 | 93 | |
| 94 | - <div> | |
| 95 | - <%= link_to(_('Save'), '#', :id=>'save_institution_button', :class=>'button with-text icon-add') %> | |
| 96 | - </div> | |
| 97 | - <%= hidden_field_tag :institution_error_message, _("Could not send the form data to the server") %> | |
| 94 | + <% if @url_token == "create_institution_admin" %> | |
| 95 | + <%= submit_button :save, _('Save') %> | |
| 96 | + <%else%> | |
| 97 | + <div> | |
| 98 | + <%= link_to(_('Save'), '#', :id=>'save_institution_button', :class=>'button with-text icon-add') %> | |
| 99 | + </div> | |
| 100 | + <%= hidden_field_tag :institution_error_message, _("Could not send the form data to the server") %> | |
| 101 | + <%end%> | |
| 102 | + | |
| 98 | 103 | <% end %> |
| 99 | 104 | |
| 100 | 105 | <% end %> | ... | ... |