diff --git a/app/controllers/admin/application_forms_controller.rb b/app/controllers/admin/application_forms_controller.rb index 2d23956..a933d9b 100644 --- a/app/controllers/admin/application_forms_controller.rb +++ b/app/controllers/admin/application_forms_controller.rb @@ -711,6 +711,7 @@ class Admin::ApplicationFormsController < OrbitAdminController page = params[:type] || params[:page] if params[:action] == "application_form_signup" page = params[:type] + page = 'table' if page.blank? end page = nil if page.blank? @application_form_signup_admin_setting = ApplicationFormSignupAdminSetting.where(:application_form_main_id=>params[:id],:page=>page).first @@ -821,14 +822,14 @@ class Admin::ApplicationFormsController < OrbitAdminController i = format_text.scan(/\d+/)[0].to_i - 1 k = custom_fields.keys[i] rescue nil if !k.blank? - text_tp = @application_form_signup.application_form_signup_values.select{|v| v.application_form_signup_field_id==k}[0].get_value_by_locale + text_tp = @application_form_signup.application_form_signup_values.select{|v| v.application_form_signup_field_id==k}[0].get_value_by_locale(I18n.locale) text = text.gsub(format_text,text_tp.to_s) end when /custom\d+/ i = format_text.scan(/\d+/)[0].to_i - 1 k = custom_fields.keys[i] rescue nil if !k.blank? - text_tp = @application_form_signup.application_form_signup_values.select{|v| v.application_form_signup_field_id==k}[0].get_value_by_locale + text_tp = @application_form_signup.application_form_signup_values.select{|v| v.application_form_signup_field_id==k}[0].get_value_by_locale(I18n.locale) text = text.gsub(format_text,text_tp.to_s) end end diff --git a/app/controllers/application_forms_controller.rb b/app/controllers/application_forms_controller.rb index 7c67ec9..496c8e2 100644 --- a/app/controllers/application_forms_controller.rb +++ b/app/controllers/application_forms_controller.rb @@ -407,6 +407,8 @@ class ApplicationFormsController < ApplicationController extra_text += render_to_string("application_forms/signup_email_contents",:locals=>{:application_form=>application_form, :application_form_signup=>signup},:layout=>false) if params[:type] == 'agree' + signup.agree_reviewer_ids[stage_num.to_s] = params[:reviewer] + signup.save if stage_num == application_form.get_max_stage signup.update(:review_status => 2) signup.clean_cipher @@ -427,7 +429,10 @@ class ApplicationFormsController < ApplicationController host_url = request.protocol + request.host_with_port end agree_link = host_url + Rails.application.routes.url_helpers.xhr_application_forms_agree_link_path(:locale=>I18n.locale, :id=>signup.id.to_s, :cipher=>signup.get_cipher_stage(signup.process_stage)) - send_mail('submission', signup.get_reviewer_email, form_params_main_id,extra_text, {'agree_link'=>agree_link}) + id_with_email = signup.get_reviewer_email + id_with_email.each do |id, email| + send_mail('submission', email, form_params_main_id,extra_text, {'agree_link'=>agree_link + "&reviewer=#{id}"}) + end end else mail_to = [signup.email] @@ -449,6 +454,7 @@ class ApplicationFormsController < ApplicationController @application_form = ApplicationFormMain.where(id: form_params_main_id).first @application_form_signup = ApplicationFormSignup.new(application_form_signup_params) + @application_form_signup.application_form_main = @application_form if @application_form.application_form_signup_field_sets.count!=0 flag = @application_form.application_form_signup_field_sets.select{|v| v.field_name=='recaptcha'}[0].disabled else @@ -492,7 +498,10 @@ class ApplicationFormsController < ApplicationController host_url = request.referer.match(/http(s|):\/\/[^\/]+/)[0] end agree_link = host_url + Rails.application.routes.url_helpers.xhr_application_forms_agree_link_path(:locale=>I18n.locale, :id=>@application_form_signup.id.to_s, :cipher=>@application_form_signup.get_cipher_stage(1)) - send_mail('submission', @application_form_signup.get_reviewer_email, form_params_main_id,extra_text, {'agree_link'=>agree_link}) + id_with_email = @application_form_signup.get_reviewer_email + id_with_email.each do |id, email| + send_mail('submission', email , form_params_main_id,extra_text, {'agree_link'=>agree_link + "&reviewer=#{id}"}) + end redirect_to "#{params[:referer_url]}/?method=signup_ok&serial_number=#{@application_form_signup.display_serial_number}" else if !@signup.blank? @@ -756,7 +765,7 @@ class ApplicationFormsController < ApplicationController def application_form_signup_params tmp = params.require(:application_form_signup).permit! - tmp['reviewer_ids_list'] = (0...@application_form.reviewer_enables.length).map{|k| Array((tmp['reviewer_ids_list'][k.to_s] rescue []))} + tmp['reviewer_ids_list'] = (0..@application_form.reviewer_enables.rindex(true)).map{|k| Array((tmp['reviewer_ids_list'][k.to_s] rescue []))} tmp end diff --git a/app/models/application_form_main.rb b/app/models/application_form_main.rb index 2809c32..416c6cf 100644 --- a/app/models/application_form_main.rb +++ b/app/models/application_form_main.rb @@ -17,6 +17,8 @@ class ApplicationFormMain field :speaker, localize: true field :content, localize: true field :act_place, localize: true + field :version + field :confidentiality field :enable_summary_choice, :type => Boolean, :default => false field :summary_chioice_type, :type => String, :default => "checkbox" field :summary_chioices, :type => Array, :default => ["A. Energy Conversion","B. Biocatalysis","C. Electrocatalysis", diff --git a/app/models/application_form_signup.rb b/app/models/application_form_signup.rb index 45e2dde..bdde74d 100644 --- a/app/models/application_form_signup.rb +++ b/app/models/application_form_signup.rb @@ -3,7 +3,7 @@ class ApplicationFormSignup require 'openssl/cipher' include Mongoid::Document include Mongoid::Timestamps - HiddenFields = ['application_form_signup_id', 'password', 'status', 'reviewer_ids_list','_id', 'created_at', 'updated_at','application_form_main_id',"serial_number","final_session","final_sessions","preferred_sessions",'application_form_session_id',"application_form_session_ids","preferred_session","sort_number","abstract_number","presentation_type", "cipher_stage_num", "process_stage", "review_status"] + HiddenFields = ['application_form_signup_id', 'password', 'status', 'reviewer_ids_list','_id', 'created_at', 'updated_at','application_form_main_id',"serial_number","final_session","final_sessions","preferred_sessions",'application_form_session_id',"application_form_session_ids","preferred_session","sort_number","abstract_number","presentation_type", "cipher_stage_num", "process_stage", "review_status", "agree_reviewer_ids"] DefaultEnableFields = ['name','tel','phone','email', 'recaptcha'] field :sort_number , type: Integer, default: 10000 field :process_stage, type: Integer, default: 1 @@ -24,6 +24,7 @@ class ApplicationFormSignup field :final_sessions field :preferred_sessions, type: Array, default: [] field :reviewer_ids_list, type: Array, default: [] + field :agree_reviewer_ids, type: Hash, default: {} def reviewer_ids_list main = self.application_form_main main.reviewer_enables.each_with_index.collect do |e,k| @@ -52,6 +53,10 @@ class ApplicationFormSignup unit = self.unit_translations.values.select{|v| v.present?}.first self.unit_translations = I18n.available_locales.map{|l| [l.to_s,unit]}.to_h self.random_cipher(false) + if self.application_form_main + enable_idx = self.application_form_main.reviewer_enables.index(true) + self.process_stage = enable_idx.nil? ? 0 : (enable_idx + 1) + end if self.serial_number.nil? s = ApplicationFormSetting.first s.last_serial_number += 1 @@ -111,13 +116,17 @@ class ApplicationFormSignup max_stage += 1 " #{I18n.t('application_form.num.'+self.process_stage.to_s)}#{stage_trans} / #{I18n.t('application_form.num.'+max_stage.to_s)}#{stage_trans} : #{I18n.t('application_form.status.'+review_status.to_s)}" end - def get_reviewer_email(stage=self.process_stage, override_reviewer_ids_list=nil) + def get_reviewer_email(stage=self.process_stage, override_reviewer_ids_list=nil, only_email=false) stage = stage - 1 if override_reviewer_ids_list.nil? override_reviewer_ids_list = self.reviewer_ids_list end member_ids = override_reviewer_ids_list[stage] - return MemberProfile.where(:id.in=>member_ids).pluck(:email).select{|s| s.present?}.uniq + if(only_email) + return MemberProfile.where(:id.in=>member_ids).pluck(:email).select{|s| s.present?}.uniq + else + return MemberProfile.where(:id.in=>member_ids).pluck(:id,:email).select{|id,s| s.present?}.uniq{|id,s| s} + end end def get_cipher_stage(stage) self.cipher_stage_num[stage - 1] diff --git a/app/views/admin/application_forms/_form.html.erb b/app/views/admin/application_forms/_form.html.erb index 4c7035c..ebfa705 100644 --- a/app/views/admin/application_forms/_form.html.erb +++ b/app/views/admin/application_forms/_form.html.erb @@ -31,7 +31,7 @@