From 64a8077e5b02285fb83681b3e4fbbaef4269871a Mon Sep 17 00:00:00 2001 From: Bomrah Harry Date: Thu, 5 Oct 2023 19:40:03 +0800 Subject: [PATCH] new changes for forms and various other things --- app/controllers/admin/seminars_controller.rb | 12 ++++ app/controllers/seminars_controller.rb | 20 +++--- app/models/seminar_main.rb | 13 ++-- app/views/admin/seminar_signups/edit.html.erb | 2 +- app/views/admin/seminars/_index.html.erb | 1 + .../seminars/seminar_signup_success.html.erb | 63 +++++++++++++++++++ app/views/email/signup_email.html.erb | 4 +- .../seminars/confirm_email_page.html.erb | 4 +- app/views/seminars/show.html.erb | 6 +- app/views/seminars/signup_ok.html.erb | 3 +- config/locales/en.yml | 3 +- config/locales/zh_tw.yml | 3 +- config/routes.rb | 2 + 13 files changed, 114 insertions(+), 22 deletions(-) create mode 100644 app/views/admin/seminars/seminar_signup_success.html.erb diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb index d00a22e..483f4bd 100644 --- a/app/controllers/admin/seminars_controller.rb +++ b/app/controllers/admin/seminars_controller.rb @@ -687,6 +687,18 @@ class Admin::SeminarsController < OrbitAdminController redirect_to "/admin/seminars/#{params[:id]}/edit" end + def seminar_signup_success + @seminar = SeminarMain.find(params[:id]) + end + + def seminar_signup_success_save + @seminar = SeminarMain.find(params[:id]) + params.require(:seminar_main).permit! + @seminar.update_attributes(params[:seminar_main]) + @seminar.save + redirect_to admin_seminars_path + end + private def set_seminar diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index 7b4c933..3f68848 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -486,19 +486,21 @@ class SeminarsController < ApplicationController @seminar.save end extra_text = "
#{I18n.t('seminar_signup.serial_number')}: #{@seminar_signup.display_serial_number}" - extra_text += render_to_string("seminars/signup_email_contents",:locals=>{:seminar=>@seminar, - :seminar_signup=>@seminar_signup},:layout=>false) + # extra_text += render_to_string("seminars/signup_email_contents",:locals=>{:seminar=>@seminar, :seminar_signup=>@seminar_signup},:layout=>false) if params['seminar_signup']['status']=='C' status_param = '&status=' if(@seminar.seminar_email_sets.where(:field_name => "signup").first.is_confirmation) extra_text += "
" + t("seminar.click_here_to_confirm") + "
" end - send_mail('submission',params[:seminar_signup][:email],params[:seminar_signup][:seminar_main_id],extra_text) + send_mail('signup',params[:seminar_signup][:email],params[:seminar_signup][:seminar_main_id],extra_text) else status_param = '' + if(@seminar.seminar_email_sets.where(:field_name => "signup").first.is_confirmation) + extra_text += "
" + t("seminar.click_here_to_confirm") + "
" + end send_mail('signup',params[:seminar_signup][:email],params[:seminar_signup][:seminar_main_id],extra_text) end - redirect_to "#{params[:referer_url].to_s.chomp('/').gsub(/\/([^\/?#]+)(|[^\/]+)$/){|f| '/'+$1}}?method=signup_ok#{status_param}&serial_number=#{@seminar_signup.display_serial_number}" + redirect_to "#{params[:referer_url].to_s.chomp('/').gsub(/\/([^\/?#]+)(|[^\/]+)$/){|f| '/'+$1}}?method=signup_ok#{status_param}&serial_number=#{@seminar_signup.display_serial_number}&seminar=#{@seminar.uid}" else if has_counter OrbitHelper::SharedMutex.synchronize do @@ -520,7 +522,11 @@ class SeminarsController < ApplicationController def signup_ok params = OrbitHelper.params - {"serial_number"=> params[:serial_number]} + msg = SeminarMain.where(:uid => params[:seminar]).first.signup_success + { + "serial_number"=> params[:serial_number], + "message" => msg + } end def add_file_proc @@ -813,7 +819,7 @@ class SeminarsController < ApplicationController seminar_signup = SeminarSignup.where(:status=>'C', :email=> params[:user_name], :seminar_main_id => params[:seminar_signup][:seminar_main_id]).first if !seminar_signup.blank? token = seminar_signup.generate_token - extra_text = "
#{t("seminar_signup.click_on_link")}" + extra_text = "
#{t("seminar.click_here_to_confirm")}" send_mail('reset_password', seminar_signup.email, @seminar.id.to_s, extra_text) redirect_to "#{params[:referer_url].to_s.chomp('/')}/?method=reset_email", :notice => t('seminar_signup.reset_email_sent') else @@ -836,7 +842,7 @@ class SeminarsController < ApplicationController extra_text = "

#{params[:text]}

" if params[:type] == "reset_password" token = seminar_signup.generate_token - extra_text += "
#{t("seminar_signup.click_on_link")}" + extra_text += "
#{t("seminar.click_here_to_confirm")}" end send_mail(params[:type], seminar_signup.email, @seminar.id.to_s, extra_text) end diff --git a/app/models/seminar_main.rb b/app/models/seminar_main.rb index 369aaf6..6f092da 100644 --- a/app/models/seminar_main.rb +++ b/app/models/seminar_main.rb @@ -18,6 +18,7 @@ class SeminarMain field :title, as: :slug_title, type: String, localize: true field :speaker, localize: true field :content, localize: true + field :signup_success, localize: true field :act_place, localize: true field :enable_summary_choice, :type => Boolean, :default => false field :summary_chioice_type, :type => String, :default => "checkbox" @@ -34,7 +35,7 @@ class SeminarMain field :contribute_start_date, :type => Date field :contribute_end_date, :type => Date - + field :contribute_file_count, type: String field :registration_status , :type => Array #C: 投稿者 G:一般 @@ -311,7 +312,7 @@ class SeminarMain r = "#{date1.strftime('%Y-%m-%d')}" if date2 - r += " - #{date2.strftime('%Y-%m-%d')}" + r += " - #{date2.strftime('%Y-%m-%d')}" else r += " - #{I18n.t(:no_deadline)}" end @@ -401,7 +402,7 @@ class SeminarMain def get_attribute_values(attribute_type=nil) @attribute_values = attribute_type.seminar_signup_values rescue nil end - + def get_value_from_field_id(field_id,attribute_type=nil) values = get_attribute_values(attribute_type) value = values.detect {|value| value.seminar_signup_field_id == field_id} rescue nil @@ -436,7 +437,7 @@ class SeminarMain seminar_signup = need_change_seminar_signups[i] if seminar_signup.seminar_session_ids.present? seminar_signup.seminar_session_ids = seminar_signup.seminar_session_ids.map{|id| @records_all["seminar_session_ids"][id]} rescue [] - end + end end count_array = (0...self.seminar_reviews.to_a.count).to_a change_fields = [:seminar_signup_ids, :remove_seminar_signup_ids, :default_seminar_signup_ids] @@ -515,7 +516,7 @@ class SeminarMain tmp_relations_fields << k else org_k = k.to_s - result = other_has_many_class.map do |k| + result = other_has_many_class.map do |k| belongs_to_class = k.classify.constantize.relations.select{|kk,v| v.macro == :belongs_to}.keys has_many_class = k.classify.constantize.relations.select{|kk,v| v.macro.to_s.start_with?('has') }.keys if (belongs_to_class - tmp_singularize_relations_fields - [org_k]).count == 0 @@ -693,4 +694,4 @@ class SeminarMain def enable_review_result self.assign_mode == 2 end -end \ No newline at end of file +end diff --git a/app/views/admin/seminar_signups/edit.html.erb b/app/views/admin/seminar_signups/edit.html.erb index fc97a23..1928537 100644 --- a/app/views/admin/seminar_signups/edit.html.erb +++ b/app/views/admin/seminar_signups/edit.html.erb @@ -201,7 +201,7 @@
- <%= rf.block_helper(@seminar,@form_index,false,"seminar_signup",@seminar_signup, rf.to_require) %> + <%= rf.block_helper(@seminar,@form_index,false,"seminar_signup",@seminar_signup, rf.markup == "file_field" ? false : rf.to_require) %>
diff --git a/app/views/admin/seminars/_index.html.erb b/app/views/admin/seminars/_index.html.erb index d3da35d..2d90c4a 100644 --- a/app/views/admin/seminars/_index.html.erb +++ b/app/views/admin/seminars/_index.html.erb @@ -28,6 +28,7 @@
  • <%= t('seminar.set_seminar_item_content') %>
  • <%= t('seminar.set_seminar_signup_field') %>
  • <%= t('seminar.set_seminar_submission_field') %>
  • +
  • <%= t('seminar.seminar_signup_success') %>
  • <%= t('seminar.reviewer_setting') %>
  • <%= t('seminar.template_setting') %>
  • <%= t('seminar.sub_page_setting') %>
  • diff --git a/app/views/admin/seminars/seminar_signup_success.html.erb b/app/views/admin/seminars/seminar_signup_success.html.erb new file mode 100644 index 0000000..7b9b198 --- /dev/null +++ b/app/views/admin/seminars/seminar_signup_success.html.erb @@ -0,0 +1,63 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + +

    <%= t('seminar.seminar') %>

    + +<%= form_for @seminar, url: "/admin/seminars/#{@seminar.id.to_s}/seminar_signup_success_save", html: {class: "form-horizontal main-forms"} do |f| %> +
    + + +
    + + + + + + +
    + + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
    "> + +
    + +
    +
    + <%= f.fields_for :signup_success_translations do |f| %> + <%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@seminar.signup_success_translations[locale] rescue nil) %> + <% end %> +
    +
    +
    + +
    + + <% end %> + +
    + +
    + + +
    + <%= get_referer_url[:action] rescue "" %> + <%= f.submit t('submit'), class: 'btn btn-primary' %> + + <%= link_to t('cancel'), admin_seminars_path, :class=>"btn" %> +
    + +
    + +<% end %> diff --git a/app/views/email/signup_email.html.erb b/app/views/email/signup_email.html.erb index 9a0583d..bcbfcdd 100644 --- a/app/views/email/signup_email.html.erb +++ b/app/views/email/signup_email.html.erb @@ -1,9 +1,9 @@ <% email_set = SeminarMain.where(id:@data['seminar_id']).first.seminar_email_sets.select{|v| v.field_name == 'signup'} %> +<%= (@data['extra_text'] rescue "").to_s.html_safe %> <% if email_set.length != 0 %> <% if !(email_set[0].content.nil?) %> <%= email_set[0].content[@data['locale']].html_safe %> <% end %> <% else %> <%= t('seminar.email_signup_content') %> -<% end %> -<%= (@data['extra_text'] rescue "").to_s.html_safe %> \ No newline at end of file +<% end %> \ No newline at end of file diff --git a/app/views/seminars/confirm_email_page.html.erb b/app/views/seminars/confirm_email_page.html.erb index 9a78014..64cfc9c 100644 --- a/app/views/seminars/confirm_email_page.html.erb +++ b/app/views/seminars/confirm_email_page.html.erb @@ -9,13 +9,13 @@ <% if (data['confirm'] == true) %> <%= t('seminar_signup.confirm_ok') %>
    - + <%= t('seminar.click_to_contribute') %> <% else %> <%= t('seminar_signup.confirm_not_ok') %>
    - + <%= t('seminar.back') %> <% end %> diff --git a/app/views/seminars/show.html.erb b/app/views/seminars/show.html.erb index cc5b2b1..3f33675 100644 --- a/app/views/seminars/show.html.erb +++ b/app/views/seminars/show.html.erb @@ -340,7 +340,11 @@ alert("1ssss2"); }) - + $(".upload").on("change",function(){ + let filenamedom = $(this).parent().parent().find(".filename"); + let filenameA = $(this).val().split('\\'); + filenamedom.text(filenameA[filenameA.length - 1]); + }) })(); diff --git a/app/views/seminars/signup_ok.html.erb b/app/views/seminars/signup_ok.html.erb index 0ddbf29..50bd212 100644 --- a/app/views/seminars/signup_ok.html.erb +++ b/app/views/seminars/signup_ok.html.erb @@ -8,7 +8,8 @@ end %> -<%= t('seminar_signup.success_message') %> +<%#= t('seminar_signup.success_message') %> +<%= data["message"].html_safe %>
    <%=t('seminar_signup.serial_number') %>: <%=data["serial_number"] rescue ""%> <% if !params['status'].nil? %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 4292f4e..e7a598e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -113,7 +113,7 @@ en: send_email_text: Additional text to send send_email_button: Send email predefined_text: Predifined email text - click_here_to_confirm: Click this link to confirm + click_here_to_confirm: Please click this link / 請點選此連結 confirm_ok: Email confirmed confirm_not_ok: Email cannot be confirmed validator: Validator @@ -172,6 +172,7 @@ en: sign_up_is_full: "Sign up is FULL!" sign_up_failed: "Sign up failed!" contribute_file_count: Count of Contribute Files #投稿檔案數 + seminar_signup_success: Signup Success Message frontend: seminar: Semianr #研討會前台 diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 976f073..974b3f5 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -110,7 +110,7 @@ zh_tw: email_special_reminder_content: 特殊通知 email_special_reminder_success: 特殊通知 is_confirmation: 認證Email - click_here_to_confirm: 點選此確認連結 + click_here_to_confirm: Please click this link / 請點選此連結 confirm_ok: Email已認證 confirm_not_ok: Email未認證 select_email_type: 選擇Email種類 @@ -173,6 +173,7 @@ zh_tw: sign_up_is_full: "報名已額滿!" sign_up_failed: "報名失敗" contribute_file_count: 投稿檔案數 + seminar_signup_success: Signup Success Message frontend: seminar: 研討會前台 diff --git a/config/routes.rb b/config/routes.rb index 18976dd..455e63e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -64,6 +64,8 @@ Rails.application.routes.draw do get 'seminar_signup' get 'seminar_item_content' get 'seminar_signup_field' + get 'seminar_signup_success' + patch 'seminar_signup_success_save' get 'seminar_submission_field' get 'seminar_signup_admin_setting' post 'update_seminar_signup_admin_setting'