lot of modifications made to make it work

This commit is contained in:
Harry Bomrah 2016-08-04 15:58:35 +08:00
parent 52d3581130
commit df953bda4b
6 changed files with 34 additions and 25 deletions

View File

@ -48,10 +48,10 @@ class Admin::SeminarsController < OrbitAdminController
@seminar = SeminarMain.find(params[:id]) @seminar = SeminarMain.find(params[:id])
@seminar_signups = SeminarSignup.where(:seminar_main_id => params[:id]) @seminar_signups = SeminarSignup.where(:seminar_main_id => params[:id])
filename = @seminar.title.parameterize.underscore + "_export.xlsx"
respond_to do |format| respond_to do |format|
format.xlsx { format.xlsx {
response.headers['Content-Disposition'] = 'attachment; filename="export.xlsx"' response.headers['Content-Disposition'] = 'attachment; filename="' + filename + '"'
} }
end end

View File

@ -2,7 +2,7 @@ class SeminarsController < ApplicationController
helper MemberHelper helper MemberHelper
include Admin::SeminarsHelper include Admin::SeminarsHelper
# include SimpleCaptcha::ControllerHelpers
def index def index
time_now = Time.now time_now = Time.now
@ -21,7 +21,7 @@ class SeminarsController < ApplicationController
params = OrbitHelper.params params = OrbitHelper.params
seminar = SeminarMain.find_by(uid: params[:uid]) seminar = SeminarMain.where(uid: params[:uid]).first
seminar_agreement = SeminarAgreement.first seminar_agreement = SeminarAgreement.first
@ -86,12 +86,11 @@ class SeminarsController < ApplicationController
categories = module_app.categories categories = module_app.categories
seminar = SeminarMain.find_by(uid: params[:uid]) seminar = SeminarMain.where(uid: params[:uid]).first
seminar_signup = SeminarSignup.new seminar_signup = SeminarSignup.new
time_now = Time.now time_now = Time.now
{ {
"seminar" => seminar, "seminar" => seminar,
"seminar_signup" => seminar_signup, "seminar_signup" => seminar_signup,
@ -141,7 +140,7 @@ class SeminarsController < ApplicationController
# if gotcha_valid? && @seminar_signup.save # if gotcha_valid? && @seminar_signup.save
if !params[:seminar_signup_values].nil? 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? 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) @custom_field_value = SeminarSignupValue.put_field_values(@seminar_signup, r.last, r.last[:seminar_signup_field_id], field_value)
end end
@ -314,4 +313,8 @@ class SeminarsController < ApplicationController
params.require(:seminar_signup_contribute).permit! params.require(:seminar_signup_contribute).permit!
end end
def seminar_signup_values_params
params.require(:seminar_signup_values).permit!
end
end end

View File

@ -158,7 +158,7 @@ class SeminarSignupValue
@seminar_signup_field_value.update(field_value_param) rescue nil @seminar_signup_field_value.update(field_value_param) rescue nil
@seminar_signup_field_value.save rescue nil @seminar_signup_field_value.save rescue nil
else 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 @seminar_signup_field_value.save
end end
return @seminar_signup_field_value return @seminar_signup_field_value

View File

@ -23,7 +23,13 @@ wb.add_worksheet(name: @seminar.title) do |sheet|
row << t('seminar_signup.note') row << t('seminar_signup.note')
@seminar.seminar_signup_fields.asc(:_id).each do |rf| @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 end
sheet.add_row row sheet.add_row row
@ -43,7 +49,13 @@ wb.add_worksheet(name: @seminar.title) do |sheet|
row2 << "#{signup.note} " row2 << "#{signup.note} "
@seminar.seminar_signup_fields.asc(:_id).each do |rf| @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 end
sheet.add_row row2 sheet.add_row row2

View File

@ -1,4 +1,3 @@
<% # encoding: utf-8 %>
<% <%
data = action_data data = action_data
@seminar = data["seminar"] @seminar = data["seminar"]
@ -6,7 +5,6 @@
@time_now = data["time_now"] @time_now = data["time_now"]
@form_index = 0 @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 ) %> <% 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" %> <%#= stylesheet_link_tag "lib/main-forms" %>
@ -186,12 +184,12 @@
</div> </div>
</div> </div>
<div class="form-group"> <!-- <div class="form-group">
<label for="note" class="col-sm-2 control-label"><%= t('nkuht_donate.recaptcha') %></label> <label for="note" class="col-sm-2 control-label"><%#= t('nkuht_donate.recaptcha') %></label>
<div class="col-sm-10"> <div class="col-sm-10">
<%= show_simple_captcha %> <%#= show_simple_captcha %>
</div> </div>
</div> </div> -->
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">

View File

@ -7,17 +7,13 @@ require "seminar/version"
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "seminar" s.name = "seminar"
s.version = Seminar::VERSION s.version = Seminar::VERSION
s.authors = ["TODO: Your name"] s.authors = ["Rulingcom"]
s.email = ["TODO: Your email"] s.email = ["orbit@rulingcom.com"]
s.homepage = "TODO" s.homepage = "http://www.rulingcom.com"
s.summary = "TODO: Summary of Seminar." s.summary = "Seminar plugin."
s.description = "TODO: Description of Seminar." s.description = "Seminar plugin."
s.license = "MIT" s.license = "MIT"
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"] s.test_files = Dir["test/**/*"]
s.add_dependency "rails", "~> 4.1.9"
s.add_development_dependency "sqlite3"
end end