diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index 657bd18..fdf0d49 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -178,11 +178,33 @@ class SeminarsController < ApplicationController if !@signup.blank? redirect_to "#{params[:referer_url]}", :notice => 'mail已存在' else - redirect_to "#{params[:referer_url]}", :notice => t('recaptcha.errors.verification_failed') + referer_url = params[:referer_url].to_s + if referer_url.split("/").last.include?("?") + uri_query = referer_url.split("?").last.gsub(/notice=[^&]*/,'') + if uri_query == "" + referer_url = referer_url.split("?")[0...-1].join("?") + "?notice=#{t('recaptcha.errors.verification_failed')}" + else + referer_url = referer_url.split("?")[0...-1].join("?") + "¬ice=#{t('recaptcha.errors.verification_failed')}" + end + else + referer_url = referer_url + "?notice=#{t('recaptcha.errors.verification_failed')}" + end + redirect_to referer_url, :notice => t('recaptcha.errors.verification_failed') end end else - redirect_to "#{params[:referer_url]}", :notice => t('recaptcha.errors.verification_failed') + referer_url = params[:referer_url].to_s + if referer_url.split("/").last.include?("?") + uri_query = referer_url.split("?").last.gsub(/notice=[^&]*/,'') + if uri_query == "" + referer_url = referer_url.split("?")[0...-1].join("?") + "?notice=#{t('recaptcha.errors.verification_failed')}" + else + referer_url = referer_url.split("?")[0...-1].join("?") + "¬ice=#{t('recaptcha.errors.verification_failed')}" + end + else + referer_url = referer_url + "?notice=#{t('recaptcha.errors.verification_failed')}" + end + redirect_to referer_url, :notice => t('recaptcha.errors.verification_failed') end end diff --git a/app/views/seminars/show.html.erb b/app/views/seminars/show.html.erb index ef3d8bd..3fc1494 100644 --- a/app/views/seminars/show.html.erb +++ b/app/views/seminars/show.html.erb @@ -12,12 +12,17 @@ <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> <%= javascript_include_tag "lib/datetimepicker/date.time.picker.js" %> <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> - - +<% notice = flash["notice"] || params[:notice] %> <% flash.each do |key, msg| %> - <%= content_tag :p, msg, :class => [key, "alert alert-error in fade"] %> + <% next if key.to_s == "notice" %> + <%= content_tag :p, msg, :class => [key, "alert alert-error in fade"], :style => "color: red; font-weight: bold;" %> +<% end %> +<% if notice.present? %> + <%= content_tag :p, params[:notice], :class => ["notice alert alert-error in fade"], :style => "color: red; font-weight: bold;" %> + <% end %> - <%= form_for @seminar_signup, url: seminars_path, html: {class: "content form-horizontal" , :id=>"new-seminar-signup"} do |f| %>