From 42391816238fb472a8ffdc6aa67fff3059daf696 Mon Sep 17 00:00:00 2001 From: Bohung Date: Tue, 30 Nov 2021 09:57:52 +0800 Subject: [PATCH] Add participant_list page. --- app/controllers/admin/seminars_controller.rb | 6 +-- app/controllers/seminars_controller.rb | 18 +++++--- app/models/seminar_template_setting.rb | 25 ++++++++--- .../seminars/_get_display_fields.html.erb | 3 ++ .../seminars/registered_participants.html.erb | 44 +++++++++++++++++++ config/locales/en.yml | 4 +- config/locales/zh_tw.yml | 4 +- 7 files changed, 86 insertions(+), 18 deletions(-) create mode 100644 app/views/seminars/registered_participants.html.erb diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb index 2fc0f2f..852f9fd 100644 --- a/app/controllers/admin/seminars_controller.rb +++ b/app/controllers/admin/seminars_controller.rb @@ -81,11 +81,7 @@ class Admin::SeminarsController < OrbitAdminController else @seminar_page_root.update(:name_translations=>@seminar.title_translations,:module=>"seminars_home",:url=>"/home",:page_id=>"home",:enabled_for=>available_locales,:bind_uid=>@seminar.uid,:bind_module_app=>"seminar",:bind_model=>"SeminarMain",:menu_enabled_for=>available_locales) end - pages_info = {"introduction" => "seminars_page", - "news" => "custom_announcement", - "registration" => "seminar_registration", - "submission" => "seminar_submission", - "album" => "custom_gallery"} + pages_info = SeminarTemplateSetting::PagesInfo relation_model = {"news" => "CustomBulletin","album"=>"CustomAlbum"} pages_info.each do |page_id , page_module| seminar_page = @seminar_page_root.child_page.where(:page_id=>page_id).first diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index 2193d88..332446c 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -75,6 +75,7 @@ class SeminarsController < ApplicationController @seminar = seminar @site_in_use_locales = Site.first.in_use_locales rescue I18n.available_locales seminar_template_setting = seminar.seminar_template_setting + @seminar_template_setting = seminar_template_setting home_page = Page.where(:parent_page_id=>seminar.id).first prefix_url = OrbitHelper.request.path.split("-").first + "-#{params[:uid]}" @prefix_url = prefix_url @@ -200,12 +201,8 @@ class SeminarsController < ApplicationController main_content = render_to_string("seminars/show_data",:locals=>{:action_data=>data, :request=>OrbitHelper.request,:flash=>OrbitHelper.request.flash, :params=>params,:session=>OrbitHelper.request.session},:layout=>false) - elsif params[:current_page_module] == "seminar_registration" - main_content = render_seminar_registration - elsif params[:current_page_module] == "seminar_submission" - main_content = render_seminar_submission else - main_content = nil + main_content = render_other_method("render_"+params[:current_page_module]) rescue nil end custom_datapp_data = {} if custom_banner @@ -236,8 +233,19 @@ class SeminarsController < ApplicationController :request=>OrbitHelper.request,:flash=>OrbitHelper.request.flash, :params=>params,:session=>OrbitHelper.request.session},:layout=>false) end + def render_seminar_registered_participants + action_data = {"seminar"=>@seminar, "seminar_template_setting"=>@seminar_template_setting} + @_request = OrbitHelper.request + action_data["prefix_url"] = @prefix_url + render_to_string("seminars/registered_participants",:locals=>{:action_data=>action_data, + :request=>OrbitHelper.request,:flash=>OrbitHelper.request.flash, + :params=>params,:session=>OrbitHelper.request.session},:layout=>false) + end def render_other_method(render_method=nil,render_template=nil) params = OrbitHelper.params + if render_method && render_template.nil? + return eval(render_method) + end render_method = render_method || params[:method] render_template = render_template || render_method params = OrbitHelper.params diff --git a/app/models/seminar_template_setting.rb b/app/models/seminar_template_setting.rb index 77c1052..87fcb35 100644 --- a/app/models/seminar_template_setting.rb +++ b/app/models/seminar_template_setting.rb @@ -1,7 +1,13 @@ class SeminarTemplateSetting include Mongoid::Document include Mongoid::Timestamps - DefaultMenu = ["introduction","news","registration","submission","album"] + DefaultMenu = ["introduction","news","registration","registered_participants","submission","album"] + PagesInfo = {"introduction" => "seminars_page", + "news" => "custom_announcement", + "registration" => "seminar_registration", + "registered_participants" => "seminar_registered_participants", + "submission" => "seminar_submission", + "album" => "custom_gallery"} belongs_to :seminar_main field :enable_custom_template, type: Boolean, default: false field :display_menu, type: Array, default: ["introduction","news","registration","submission","album"] @@ -56,16 +62,23 @@ class SeminarTemplateSetting display_menu = self.display_menu available_locales = Site.first.in_use_locales rescue I18n.available_locales available_locales = available_locales.map{|l| l.to_s} + pages_info = self.class::PagesInfo if @seminar_page_root default_display_menu = self.class::DefaultMenu default_display_menu.each do |page_id| page = @seminar_page_root.child_page.where(:page_id=>page_id).first if page - if display_menu.include?(page_id) - page.update(:enabled_for=>available_locales,:menu_enabled_for=>available_locales) - else - page.update(:enabled_for=>[],:menu_enabled_for=>[]) - end + if display_menu.include?(page_id) + page.update(:enabled_for=>available_locales,:menu_enabled_for=>available_locales) + else + page.update(:enabled_for=>[],:menu_enabled_for=>[]) + end + else + page_module = pages_info[page_id] + seminar_page = @seminar_page_root.child_page.where(:page_id=>page_id).first + page_trans = available_locales.map{|l| [l,I18n.with_locale(l){I18n.t("seminar.menu.#{page_id}")}]}.to_h + available_locales_tmp = available_locales.clone + @seminar_page_root.child_page.create(:name_translations=>page_trans,:page_id=>page_id,:url=>"/home/#{page_id}",:enabled_for=>available_locales_tmp,:module=>page_module,:menu_enabled_for=>available_locales_tmp) end end end diff --git a/app/views/admin/seminars/_get_display_fields.html.erb b/app/views/admin/seminars/_get_display_fields.html.erb index 8c4ebb9..c1e9005 100644 --- a/app/views/admin/seminars/_get_display_fields.html.erb +++ b/app/views/admin/seminars/_get_display_fields.html.erb @@ -11,6 +11,7 @@ <% if @seminar.present? %> <% if @seminar.seminar_signup_field_sets.count != 0 %> <% @seminar.seminar_signup_field_sets.each do |field_set| %> + <% next if field_set.field_name == "password" %> <% default_hidden << "seminar_signup_field_set.#{field_set.field_name}" if (field_set.hidden) %> <% @field_names << "seminar_signup_field_set.#{field_set.field_name}" %> <% @field_name_translations << field_set.name[I18n.locale] %> @@ -91,6 +92,7 @@ <% seminar_signup_field_sets = SeminarSignupFieldSet.all.uniq{|s| s.field_name} %> <% if seminar_signup_field_sets.count != 0 %> <% seminar_signup_field_sets.each do |field_set| %> + <% next if field_set.field_name == "password" %> <% default_show << "seminar_signup_field_set.#{field_set.field_name}" if !(field_set.hidden) %> <% @field_names << "seminar_signup_field_set.#{field_set.field_name}" %> <% @field_name_translations << field_set.name[I18n.locale] %> @@ -137,6 +139,7 @@ <% @field_name_translations << s.title %> <% end %> <% @display_field = @seminar_signup_admin_setting.display_field %> + <% @display_field.delete("seminar_signup_field_set.password") %> <% if @display_field.blank? @display_field = default_show end %> diff --git a/app/views/seminars/registered_participants.html.erb b/app/views/seminars/registered_participants.html.erb new file mode 100644 index 0000000..8f14d8e --- /dev/null +++ b/app/views/seminars/registered_participants.html.erb @@ -0,0 +1,44 @@ +<% + data = action_data + seminar = data["seminar"] + seminar_template_setting = data["seminar_template_setting"] + display_unit = (!seminar.seminar_signup_field_sets.select{|v| v.field_name=='unit'}[0].disabled rescue false) +%> + +

<%= I18n.t("seminar.participant_list") %>

+ + + + + <% if display_unit %> + + <% end %> + + + + <% if display_unit %> + <% seminar.seminar_signups.each do |ss| %> + + + + + <% end %> + <% else %> + <% seminar.seminar_signups.each do |ss| %> + + + + <% end %> + <% end %> + +
<%= I18n.t("seminar_signup.name") %><%= I18n.t("seminar_signup.unit") %>
<%= ss.name %><%= ss.unit %>
<%= ss.name %>
\ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 4abea3a..c75eaf3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -27,6 +27,7 @@ en: abstract_number: Abstract number presentation_type: Presentation seminar: + participant_list: Participant list back: Back please_login_first: "Please login first!" out_of_date: Out of date @@ -47,6 +48,7 @@ en: introduction: Introduction news: News registration: Registration + registered_participants: Registered Participants submission: Submission album: Album introduction: Introduction @@ -173,7 +175,7 @@ en: file: Files signup_time: Sign Up Time #報名時間 name: Name - unit: Unit #單位 + unit: Institute #單位 tel: Tel phone: Mobile telephone fax: Fax diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 9d6d5a5..bbb5d8d 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -28,6 +28,7 @@ zh_tw: abstract_number: 摘要編號 presentation_type: 發表方式 seminar: + participant_list: 參加者名單 back: 回上一頁 please_login_first: "請先登入!" out_of_date: 已截止 @@ -48,6 +49,7 @@ zh_tw: introduction: 介紹 news: 公告 registration: 註冊 + registered_participants: 註冊參與者 submission: 投稿 album: 相簿 introduction: 介紹 @@ -144,7 +146,7 @@ zh_tw: export: 匯出 set_seminar_items: 項目 set_seminar_submission_field: 上傳介面欄位設定 - set_seminar_signup_field: 圈選設定 + set_seminar_signup_field: 報名欄位設定 set_seminar_item_content: 項目設定 set_seminar_agreements: 個資宣告設定 seminar_agreements_content: 個資宣告內容