From 28b824f0184f141062f3f3cc53425be34fee4074 Mon Sep 17 00:00:00 2001 From: chiu Date: Thu, 28 Nov 2019 12:39:36 +0800 Subject: [PATCH] fix error --- app/controllers/admin/seminars_controller.rb | 1 - app/controllers/seminars_controller.rb | 9 ++++- app/models/seminar_signup_contribute.rb | 3 +- app/views/admin/seminar_signups/edit.html.erb | 4 +-- .../admin/seminars/seminar_signup.html.erb | 36 ++++++++++++------- 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb index 619ad7e..7139650 100644 --- a/app/controllers/admin/seminars_controller.rb +++ b/app/controllers/admin/seminars_controller.rb @@ -145,7 +145,6 @@ class Admin::SeminarsController < OrbitAdminController end flash.now[:notice] = "Updated Fields" @seminar.seminar_submission_fields.each{|t| t.destroy if t["to_delete"] == true} - redirect_to admin_seminars_path else diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index 03a4cbe..e18c63f 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -171,10 +171,17 @@ class SeminarsController < ApplicationController update_params = seminar_signup_contribute_params.merge('seminar_submission_values'=>params['seminar_submission_values']) flag = true update_params.permit! - update_params['seminar_submission_values']['0']['value'].each do |key,value| + if update_params['seminar_submission_values']['0']['value'].class==String + value = update_params['seminar_submission_values']['0']['value'] if !value.to_s.blank? flag = false end + else + update_params['seminar_submission_values']['0']['value'].each do |key,value| + if !value.to_s.blank? + flag = false + end + end end if flag update_params['seminar_submission_values']['0']['value']['en'] = ' ' diff --git a/app/models/seminar_signup_contribute.rb b/app/models/seminar_signup_contribute.rb index bae17c3..b282142 100644 --- a/app/models/seminar_signup_contribute.rb +++ b/app/models/seminar_signup_contribute.rb @@ -4,8 +4,9 @@ class SeminarSignupContribute include Mongoid::Timestamps field :title - field :description mount_uploader :file, AssetUploader + field :description + belongs_to :seminar_signup has_many :seminar_submission_values, autosave: true, dependent: :destroy accepts_nested_attributes_for :seminar_submission_values, :allow_destroy => true diff --git a/app/views/admin/seminar_signups/edit.html.erb b/app/views/admin/seminar_signups/edit.html.erb index ec29d8e..0e50a48 100644 --- a/app/views/admin/seminar_signups/edit.html.erb +++ b/app/views/admin/seminar_signups/edit.html.erb @@ -41,12 +41,12 @@
<% if @seminar.registration_status.include?('G') %> <% end %> <% if @seminar.registration_status.include?('C') %> <% end %>
diff --git a/app/views/admin/seminars/seminar_signup.html.erb b/app/views/admin/seminars/seminar_signup.html.erb index 301dce6..67ad79f 100644 --- a/app/views/admin/seminars/seminar_signup.html.erb +++ b/app/views/admin/seminars/seminar_signup.html.erb @@ -36,14 +36,24 @@ <% end %> <% end %> <% if @seminar.seminar_submission_field_sets.count != 0 %> - <% @seminar.seminar_submission_field_sets.each do |field_set| %> - <% if !(field_set.hidden) %> - <%= field_set.name[I18n.locale] %> - <% end %> - <% end %> + <% show1 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='title'}[0].hidden) + show2 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='file'}[0].hidden) + show3 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0].hidden) + %> <% else %> - <%= t('seminar_signup.file_note')%> - <%= t('seminar_signup.uploads')%> + <% show1 = true + show2 = true + show3 = true + %> + <% end %> + <% if show1 %> + <%= t('seminar_signup.title')%> + <% end %> + <% if show2 %> + <%= t('seminar_signup.file')%> + <% end %> + <% if show3 %> + <%= t('seminar_signup.description')%> <% end %> <% @seminar.seminar_submission_fields.each do |submission_field| %> <%= submission_field.title %> @@ -115,8 +125,8 @@ <% count_set = 0 %> <% if @seminar.seminar_submission_field_sets.count != 0 %> <% show1 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='title'}[0].hidden) - show2 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0].hidden) - show3 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='file'}[0].hidden) + show2 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='file'}[0].hidden) + show3 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0].hidden) %> <% @seminar.seminar_submission_field_sets.each do |field_set| %> <% if !(field_set.hidden) %> @@ -151,14 +161,14 @@ <% end %> <% if show2 %> -
  • <%= seminar_signup_contribute.description.to_s.html_safe %>
  • +
  • + <%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(seminar_signup_contribute.description).text} if seminar_signup_contribute.file.file %> +
  • <% end %> <% if show3 %> -
  • - <%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(seminar_signup_contribute.description).text} if seminar_signup_contribute.file.file %> -
  • +
  • <%= seminar_signup_contribute.description.to_s.html_safe %>
  • <% end %> <%