From df953bda4bd0c0f5878f6c351d9394017f527124 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 4 Aug 2016 15:58:35 +0800 Subject: [PATCH] lot of modifications made to make it work --- app/controllers/admin/seminars_controller.rb | 4 ++-- app/controllers/seminars_controller.rb | 13 ++++++++----- app/models/seminar_signup_value.rb | 2 +- app/views/admin/seminars/export.xlsx.axlsx | 16 ++++++++++++++-- app/views/seminars/show.html.erb | 10 ++++------ seminar.gemspec | 14 +++++--------- 6 files changed, 34 insertions(+), 25 deletions(-) diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb index ed71378..800e67a 100644 --- a/app/controllers/admin/seminars_controller.rb +++ b/app/controllers/admin/seminars_controller.rb @@ -48,10 +48,10 @@ class Admin::SeminarsController < OrbitAdminController @seminar = SeminarMain.find(params[:id]) @seminar_signups = SeminarSignup.where(:seminar_main_id => params[:id]) - + filename = @seminar.title.parameterize.underscore + "_export.xlsx" respond_to do |format| format.xlsx { - response.headers['Content-Disposition'] = 'attachment; filename="export.xlsx"' + response.headers['Content-Disposition'] = 'attachment; filename="' + filename + '"' } end diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index 99d62e3..6a577b7 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -2,7 +2,7 @@ class SeminarsController < ApplicationController helper MemberHelper include Admin::SeminarsHelper - + # include SimpleCaptcha::ControllerHelpers def index time_now = Time.now @@ -21,7 +21,7 @@ class SeminarsController < ApplicationController params = OrbitHelper.params - seminar = SeminarMain.find_by(uid: params[:uid]) + seminar = SeminarMain.where(uid: params[:uid]).first seminar_agreement = SeminarAgreement.first @@ -86,12 +86,11 @@ class SeminarsController < ApplicationController categories = module_app.categories - seminar = SeminarMain.find_by(uid: params[:uid]) + seminar = SeminarMain.where(uid: params[:uid]).first seminar_signup = SeminarSignup.new time_now = Time.now - { "seminar" => seminar, "seminar_signup" => seminar_signup, @@ -141,7 +140,7 @@ class SeminarsController < ApplicationController # if gotcha_valid? && @seminar_signup.save if !params[:seminar_signup_values].nil? - params[:seminar_signup_values].each_with_index do |r,i| + seminar_signup_values_params.each_with_index do |r,i| field_value = r.last[:id].present? @custom_field_value = SeminarSignupValue.put_field_values(@seminar_signup, r.last, r.last[:seminar_signup_field_id], field_value) end @@ -314,4 +313,8 @@ class SeminarsController < ApplicationController params.require(:seminar_signup_contribute).permit! end + def seminar_signup_values_params + params.require(:seminar_signup_values).permit! + end + end \ No newline at end of file diff --git a/app/models/seminar_signup_value.rb b/app/models/seminar_signup_value.rb index 9175137..c1a648f 100644 --- a/app/models/seminar_signup_value.rb +++ b/app/models/seminar_signup_value.rb @@ -158,7 +158,7 @@ class SeminarSignupValue @seminar_signup_field_value.update(field_value_param) rescue nil @seminar_signup_field_value.save rescue nil else - @seminar_signup_field_value = member.seminar_signup_values.build(field_value_param) rescue nil + @seminar_signup_field_value = member.seminar_signup_values.build(field_value_param) #rescue nil @seminar_signup_field_value.save end return @seminar_signup_field_value diff --git a/app/views/admin/seminars/export.xlsx.axlsx b/app/views/admin/seminars/export.xlsx.axlsx index 2291e44..5aff95b 100644 --- a/app/views/admin/seminars/export.xlsx.axlsx +++ b/app/views/admin/seminars/export.xlsx.axlsx @@ -23,7 +23,13 @@ wb.add_worksheet(name: @seminar.title) do |sheet| row << t('seminar_signup.note') @seminar.seminar_signup_fields.asc(:_id).each do |rf| - row << rf.title + if rf.can_muti_lang_input? + @site_in_use_locales.each do |l| + row << rf.title + " (#{t(l.to_s)})" + end + else + row << rf.title + end end sheet.add_row row @@ -43,7 +49,13 @@ wb.add_worksheet(name: @seminar.title) do |sheet| row2 << "#{signup.note} " @seminar.seminar_signup_fields.asc(:_id).each do |rf| - row2 << nl2br(show_attribute_value(@seminar.get_attribute_value(rf,signup.id).get_value_by_locale(I18n.locale))) rescue ' ' + if rf.can_muti_lang_input? + @site_in_use_locales.each do |l| + row2 << nl2br(show_attribute_value(@seminar.get_attribute_value(rf,signup.id).get_value_by_locale(l))) rescue ' ' + end + else + row2 << nl2br(show_attribute_value(@seminar.get_attribute_value(rf,signup.id).get_value_by_locale(I18n.locale))) rescue ' ' + end end sheet.add_row row2 diff --git a/app/views/seminars/show.html.erb b/app/views/seminars/show.html.erb index 6e64ab5..b567742 100644 --- a/app/views/seminars/show.html.erb +++ b/app/views/seminars/show.html.erb @@ -1,4 +1,3 @@ -<% # encoding: utf-8 %> <% data = action_data @seminar = data["seminar"] @@ -6,7 +5,6 @@ @time_now = data["time_now"] @form_index = 0 %> - <% if !@seminar.registration_status.blank? and @seminar.signup_start_date < @time_now and ( @seminar.signup_end_date.nil? or @seminar.signup_end_date+1 > @time_now ) %> <%#= stylesheet_link_tag "lib/main-forms" %> @@ -186,12 +184,12 @@ -
- +
diff --git a/seminar.gemspec b/seminar.gemspec index 1963deb..668fec3 100644 --- a/seminar.gemspec +++ b/seminar.gemspec @@ -7,17 +7,13 @@ require "seminar/version" Gem::Specification.new do |s| s.name = "seminar" s.version = Seminar::VERSION - s.authors = ["TODO: Your name"] - s.email = ["TODO: Your email"] - s.homepage = "TODO" - s.summary = "TODO: Summary of Seminar." - s.description = "TODO: Description of Seminar." + s.authors = ["Rulingcom"] + s.email = ["orbit@rulingcom.com"] + s.homepage = "http://www.rulingcom.com" + s.summary = "Seminar plugin." + s.description = "Seminar plugin." s.license = "MIT" s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] s.test_files = Dir["test/**/*"] - - s.add_dependency "rails", "~> 4.1.9" - - s.add_development_dependency "sqlite3" end