<%= @seminar.title %>
+<%= t('seminar_signup.forgot_password') %>
++ "> + + + <% end %> +
+
diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb index 5c2216b..df06b99 100644 --- a/app/controllers/admin/seminars_controller.rb +++ b/app/controllers/admin/seminars_controller.rb @@ -556,6 +556,13 @@ class Admin::SeminarsController < OrbitAdminController render action: :edit and return end end + Rails.logger.info "&&&&&&&&&&&&&&" + if @seminar_params[:seminar_email_sets_attributes] + Rails.logger.info "*********************" + Rails.logger.info @seminar_params[:seminar_email_sets_attributes] + @seminar.update_attributes(@seminar_params[:seminar_email_sets_attributes]) + flash.now[:notice] = "Updated Fields" + end end redirect_to admin_seminars_path end diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index 50bae30..9a1acd1 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -8,13 +8,13 @@ class SeminarsController < ApplicationController def index time_now = Time.now - + seminars = SeminarMain.all.desc(:seminar_start_date).filter_by_categories { "seminars" => seminars, 'time_now' => time_now, "total_pages" => seminars.total_pages - } + } end def widget @@ -85,7 +85,7 @@ class SeminarsController < ApplicationController prefix_url = OrbitHelper.request.path.split("-").first + "-#{params[:uid]}" @prefix_url = prefix_url @registration_postfix = "/home/registration" - header_data = "Home | " + + header_data = "Home | " + "Main Site" content_style = seminar_template_setting.content_style background_style = seminar_template_setting.background_style @@ -295,7 +295,7 @@ class SeminarsController < ApplicationController if last_path.include?("?") referer_url = split_path[0...-1].join('/') + '/' + last_path.split('?')[0] uri_query = last_path.split("?")[1..-1].join('?') - uri_query.gsub!(/notice=[^&]*/,'').gsub!(/&+$/,'') + uri_query.gsub!(/notice=[^&]*/,'').gsub!(/&+$/,'') #rescue nil if uri_query.blank? referer_url = referer_url + "?notice=#{notice_words}" else @@ -391,18 +391,18 @@ class SeminarsController < ApplicationController def check_email params = OrbitHelper.params - - if !params[:email].blank? + success = true + if !params[:email].blank? count = SeminarSignup.where(:email => params[:email], :seminar_main_id => params[:no]).count result = count > 0 ? t('seminar.already_used') : t('seminar.available') - else - result = t('seminar.please_enter_email') + success = count > 0 ? false : true end - { - "result" => result - } + render :json => { + "result" => result, + "success" => success + }.to_json end @@ -733,6 +733,12 @@ class SeminarsController < ApplicationController end + def reset_email + end + + def reset_password_page + end + def con_login_proc seminar = SeminarMain.find_by(id: params[:seminar_signup][:seminar_main_id]) @@ -746,11 +752,43 @@ class SeminarsController < ApplicationController redirect_to "#{params[:referer_url].to_s.chomp('/')}/?method=con_upload" else - redirect_to "#{params[:referer_url].to_s.chomp('/')}/?method=con_login", :notice => '登入失敗' + redirect_to "#{params[:referer_url].to_s.chomp('/')}/?method=con_login", :notice => t('seminar_signup.login_failed') end end + def reset_confirm_password_proc + seminar_signup = SeminarSignup.where(:status=>'C', :reset_token=> params[:token], :seminar_main_id => params[:seminar_signup][:seminar_main_id]).first + if !seminar_signup.blank? + params.permit! + seminar_signup.password = params[:password] + seminar_signup.reset_token = "" + seminar_signup.save + redirect_to "#{params[:referer_url].to_s.chomp('/')}/?method=con_login", :notice => t('seminar_signup.password_changed') + else + redirect_to "#{params[:referer_url].to_s.chomp('/')}/?method=con_login" + end + end + + def reset_password_proc + # seminar = SeminarMain.find_by(id: params[:seminar_signup][:seminar_main_id]) + 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_reset_token + + mail = Email.create(mail_to:params[:user_name], + module_app_key:"seminar", + template:"email/reset_password_email.html.erb", + mail_sentdate:Time.current, + mail_subject: t("seminar_signup.email_reset_password_success"), + template_data:{'url'=> request.protocol + request.host_with_port + "#{params[:referer_url].to_s.chomp('/')}/?method=reset_password_page&token=#{token}",'locale'=>I18n.locale}) + # mail.deliver + redirect_to "#{params[:referer_url].to_s.chomp('/')}/?method=reset_email", :notice => t('seminar_signup.reset_email_sent') + else + redirect_to "#{params[:referer_url].to_s.chomp('/')}/?method=reset_email", :notice => t('seminar_signup.email_not_found') + end + end + def seminar_signup_params params.require(:seminar_signup).permit! end @@ -778,6 +816,6 @@ class SeminarsController < ApplicationController mail_sentdate:Time.current, mail_subject: email_set[0].title[I18n.locale], template_data:{'seminar_id'=>seminar_id,'locale'=>I18n.locale,'extra_text'=> extra_text}) - end + end end end diff --git a/app/helpers/admin/seminars_field_helper.rb b/app/helpers/admin/seminars_field_helper.rb index 21ffe5c..a2ffd29 100644 --- a/app/helpers/admin/seminars_field_helper.rb +++ b/app/helpers/admin/seminars_field_helper.rb @@ -50,14 +50,14 @@ module Admin::SeminarsFieldHelper def render_checkbox @prefiled_value ||=[] - control_group_wrapper_for_sm do + control_group_wrapper_for_sm do a = self.typeE[:option_list].collect do |key,value| label_tag("#{get_basic_field_name_org}_#{self.id}_#{key}",check_box_tag(get_field_name_base+"[#{key}]", true , (@prefiled_value.include?(key) ? true : false), { :id=>"#{get_basic_field_name_org}_#{self.id}_#{key}"})+value[I18n.locale.to_s],@markup_options.merge(:class=>"checkbox inline")) end.join.html_safe rescue "" end end - def render_date + def render_date d = DateTime.now() if date_is_range? @@ -81,13 +81,13 @@ module Admin::SeminarsFieldHelper when 'format3' fill_from = (@prefiled_value && @prefiled_value["from"] ) ? @prefiled_value["from"] : d.strftime("%Y/%m") fill_to = (@prefiled_value && @prefiled_value["to"] ) ? @prefiled_value["to"] : d.strftime("%Y/%m/") - buf = datetime_picker(get_field_name_base+'[from]', fill_from, 'yyyy/MM') + buf = datetime_picker(get_field_name_base+'[from]', fill_from, 'yyyy/MM') buf << ' ~ ' buf << datetime_picker(get_field_name_base+'[to]', fill_to, 'yyyy/MM') when 'format4' fill_from = (@prefiled_value && @prefiled_value["from"] ) ? @prefiled_value["from"] : d.strftime("%Y") fill_to = (@prefiled_value && @prefiled_value["to"] ) ? @prefiled_value["to"] : d.strftime("%Y") - buf = datetime_picker(get_field_name_base+'[from]', fill_from, 'yyyy') + buf = datetime_picker(get_field_name_base+'[from]', fill_from, 'yyyy') buf << ' ~ ' buf << datetime_picker(get_field_name_base+'[to]', fill_to, 'yyyy') end @@ -107,13 +107,13 @@ module Admin::SeminarsFieldHelper when 'format2' tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y/%m/%d")), 'yyyy/MM/dd') when 'format3' - tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y/%m")), 'yyyy/MM') + tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y/%m")), 'yyyy/MM') when 'format4' - tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y")), 'yyyy') + tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y")), 'yyyy') end - - control_group_wrapper_for_sm{tmp} - # control_group_wrapper_for_sm{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")} + + control_group_wrapper_for_sm{tmp} + # control_group_wrapper_for_sm{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")} end end @@ -131,7 +131,7 @@ module Admin::SeminarsFieldHelper end def render_date_durnation #Need re-write low priority - + end def render_radio_button @@ -179,7 +179,7 @@ module Admin::SeminarsFieldHelper place_holder= typeA["placeholder"][key_field] rescue '' name1 = can_muti_lang_input_for_sm? ? ([get_field_name_base,add_more_blank,"[#{key_field}]"].join) : ([get_field_name_base,add_more_blank].join) text_field_tag(name1, value, @markup_options.merge(:placeholder=>place_holder,:class=>'input-medium form-control')) - end + end end def render_file_field @@ -199,9 +199,9 @@ module Admin::SeminarsFieldHelper is_range = "false" data = get_data if !data.nil? - is_range = data['is_range'] if data.has_key? "is_range" + is_range = data['is_range'] if data.has_key? "is_range" end - is_range == "true" + is_range == "true" end protected @@ -239,7 +239,7 @@ protected div_class << (key == I18n.locale ? " active in" : '') content_tag(:div,yield(key,value), :id=>div_id,:class=>div_class) end# of VALID_LOCALES.collect for tabed input - tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do + tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do buff2 = valid_locales.each.collect do |key| # link_entry = self.add_more ? "#{add_more_tab(:tab_btn,loop_counter,key)}" : "#tab"+id.to_s+"_#{key}" if @show_set_field_for_sm && @markup=='text_area' @@ -262,7 +262,7 @@ protected else # tmp = content_tag :div,:class=> (add_more || self.markup=='address') ? "input-append" : "tab-content" do - tmp1 = + tmp1 = content_tag :div,:class=> "tab-content" do buff = valid_locales.collect do |key| @@ -289,7 +289,7 @@ protected end - tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do + tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do buff2 = valid_locales.each.collect do |key| # link_entry = self.add_more ? "#{add_more_tab(:tab_btn,loop_counter,key)}" : "#tab"+id.to_s+"_#{key}" link_entry_ary = ["##{get_pairing_tab_class({})}","_#{key}"] @@ -304,7 +304,7 @@ protected end # of content ul - + tmp = content_tag :div,:class=> "input-append" do tmp1 << tmp2 end @@ -319,8 +319,8 @@ protected add_more_counter = "" if can_add_more - add_more_counter = add_more_params[0][:counter] - add_more_value = add_more_params[0][:value] + add_more_counter = add_more_params[0][:counter] + add_more_value = add_more_params[0][:value] end if can_muti_lang_input_for_sm? @@ -330,7 +330,7 @@ protected else #cross lang field case can_add_more when true - value = add_more_params[0][:value] + value = add_more_params[0][:value] result << content_tag(:div,:class=>"input-append"){yield(nil,value) + link_to((content_tag :i,'',:class=>'icon-trash'),"#",:class=>"btn remove-input") } # result << add_more_unt else @@ -346,7 +346,7 @@ protected end # of def controls_wrapper_for_sm(&block) - def control_group_wrapper_for_sm(&block) + def control_group_wrapper_for_sm(&block) div_class = can_muti_lang_input_for_sm? ? "col-sm-10 controls" : "col-sm-10 controls" # div_class = can_muti_lang_input_for_sm? ? "control-group language-swich" : "control-group" result = "" @@ -357,7 +357,7 @@ protected if can_add_more - multipleInputs = + multipleInputs = content_tag(:div,:class=>"add-target") do @attribute_value.add_more_counter.times.collect do |t| controls_wrapper_for_sm(:value=>(@prefiled_value[t] rescue nil),:counter=>t,&block) @@ -366,8 +366,8 @@ protected temp = content_tag(:div, multipleInputs + add_more_unt, :class=>'add-input') - - result = form_label + content_tag(:div,temp,:class=>div_class) + + result = form_label + content_tag(:div,temp,:class=>div_class) # result = label + multipleInputs + add_more_unt # result = label + 一堆的輸入框(要用 multipleInput editMore 包起來) + add_more btn + hidden_fields @@ -385,7 +385,7 @@ protected result = address else - result = form_label + content_tag(:div,controls_wrapper_for_sm(&block),:class=>div_class) + result = form_label + content_tag(:div, controls_wrapper_for_sm(&block),:class=>div_class, :id => "yessss") end result = result + end_block result.html_safe @@ -393,7 +393,7 @@ protected end - def add_more_unt + def add_more_unt temp_field_name = get_basic_field_name_base + '[temp]' add_more = content_tag :p,:class=> 'add-btn' do content = link_to (content_tag :i,I18n.t(:add),:class=>"icon-plus"),"#","data-roles"=>"role_a",:class=>"trigger #{can_muti_lang_input_for_sm? ? 'textLengInput' : 'textInput' } btn btn-small btn-primary" @@ -432,7 +432,7 @@ protected prefix = opts[:prefix] suffix = opts[:suffix] str = get_basic_field_name_base.gsub("[","_").gsub("]",'') - str = prefix.nil? ? str : prefix+ str + str = prefix.nil? ? str : prefix+ str suffix.nil? ? str : str + suffix end @@ -471,7 +471,7 @@ protected if self.markup == "address" return true else - $seminar_list[:markups][markup]["muti_lang_input_supprt"] and !(get_data["cross_lang"] == "true") + $seminar_list[:markups][markup]["muti_lang_input_supprt"] and !(get_data["cross_lang"] == "true") end end @@ -533,23 +533,29 @@ protected end @attribute_value = field_sets @prefiled_value = field_sets[field] - a = control_group_wrapper_for_sm do |key,value| - add_more_blank = "" - if markup=='text_field' - if key_field == 'seminar_email_sets' - inside = text_field_tag([get_field_name_base,"[#{key}]"].join,value,:class=>'input-medium form-control') - else - inside = text_field_tag([get_field_name_base,"[#{key}]"].join,value) + add_more_blank = "" + if markup=='text_field' + a = control_group_wrapper_for_sm do |key,value| + # debugger + if key_field == 'seminar_email_sets' + inside = text_field_tag([get_field_name_base,"[#{key}]"].join,value,:class=>'input-medium form-control') + else + inside = text_field_tag([get_field_name_base,"[#{key}]"].join,value) + end + inside end else - inside = cktext_area("seminar_main[#{@key_field}][#{@key_index}][#{@field}]","#{key}",value:value) + a = "" + a = a + cktext_area("seminar_main[#{@key_field}][#{@key_index}][#{@field}]","en",value:@prefiled_value['en']) + a = a + "" + a = a + cktext_area("seminar_main[#{@key_field}][#{@key_index}][#{@field}]","zh_tw",value:@prefiled_value['zh_tw']) + end - inside - end + @key_field = nil @key_index = nil @field = nil @show_set_field_for_sm = nil return a.html_safe end -end \ No newline at end of file +end diff --git a/app/models/seminar_signup.rb b/app/models/seminar_signup.rb index fefd159..103293f 100644 --- a/app/models/seminar_signup.rb +++ b/app/models/seminar_signup.rb @@ -8,6 +8,7 @@ class SeminarSignup field :sort_number , type: Integer, default: 10000 field :status + field :reset_token field :name # become Last Name for TICC field :tel, type: String # become First Name for TICC field :unit, localize: true #Only localize for preserving old record @@ -26,7 +27,7 @@ class SeminarSignup field :seminar_session_ids, type: Array, default: [] has_many :seminar_signup_values, :autosave => true, :dependent => :destroy has_many :seminar_signup_contributes, :autosave => true, :dependent => :destroy - + accepts_nested_attributes_for :seminar_signup_values, allow_destroy: true accepts_nested_attributes_for :seminar_signup_contributes, allow_destroy: true scope :sort_ordered, ->{ order_by(:sort_number=>1,:created_at=>1) } @@ -80,6 +81,13 @@ class SeminarSignup seminar_session.save end end + + def generate_reset_token + reset_token = SecureRandom.hex(5) + self.reset_token = reset_token + self.save + return reset_token + end def display_serial_number display_format_string(self.serial_number,4) end diff --git a/app/models/seminar_signup_field.rb b/app/models/seminar_signup_field.rb index 2025454..1cbd39e 100644 --- a/app/models/seminar_signup_field.rb +++ b/app/models/seminar_signup_field.rb @@ -15,9 +15,9 @@ class SeminarSignupField field :built_in, type: Boolean, default: false field :disabled, type: Boolean, default: false # field :to_delete, type: Boolean, default: false - + field :to_require,type: Boolean, default: true - + field :typeA, type: Hash, default: {cross_lang: false} field :typeB, type: Hash, default: {} field :typeC, type: Hash, default: {calendar: "west_calendar", format: "format3"} @@ -57,8 +57,8 @@ class SeminarSignupField def option_list if self_defined_markup_options? - #Class need to have corresponding field and value agent - # Ex: For "status" the class must have field called "statuses" for the relation and "statuses_for_select" for the select function + #Class need to have corresponding field and value agent + # Ex: For "status" the class must have field called "statuses" for the relation and "statuses_for_select" for the select function method = self.seminar.method(self[:key].pluralize+"_for_"+markup) return (method.call rescue {}) elsif self[:option_list].nil? || (self[:option_list].empty?) @@ -103,7 +103,7 @@ class SeminarSignupField def is_built_in? self.built_in end - + def is_disabled? self.disabled end @@ -131,7 +131,7 @@ class SeminarSignupField if self[field]["cross_lang"] != var["cross_lang"] case var["cross_lang"] when "true" #from no-add_more to add_more - cross_lang_convert(:to_cross_lang) + cross_lang_convert(:to_cross_lang) else #from add_more to no-add_more cross_lang_convert(:to_no_cross_lang) end # of case @@ -142,23 +142,23 @@ class SeminarSignupField if self["typeA"]["add_more"] != var["add_more"] case var["add_more"] when "true" #from no-add_more to add_more - add_more_convert(:to_add_more) + add_more_convert(:to_add_more) else #from add_more to no-add_more add_more_convert(:to_no_add_more) end # of case end # of if end - def cross_lang_convert(opt) - + def cross_lang_convert(opt) + end def check_option_list self[:option_list] = self[panel]["option_list"] rescue nil end - def add_more_convert(opt) + def add_more_convert(opt) end -end \ No newline at end of file +end diff --git a/app/views/admin/seminars/_form.html.erb b/app/views/admin/seminars/_form.html.erb index b35f000..7120a0d 100644 --- a/app/views/admin/seminars/_form.html.erb +++ b/app/views/admin/seminars/_form.html.erb @@ -552,6 +552,8 @@ $(".summary_choice_block").css("display","none"); } }) + // $("div#seminar_main_seminar_email_sets_attributes_0_content_en").attr('id',"div_seminar_main_seminar_email_sets_attributes_0_content_en"); + // $("div#seminar_main_seminar_email_sets_attributes_0_content_zh_tw").attr('id',"div_seminar_main_seminar_email_sets_attributes_0_content_zh_tw"); }); <% end %> diff --git a/app/views/email/reset_password_email.html.erb b/app/views/email/reset_password_email.html.erb new file mode 100644 index 0000000..0ccf084 --- /dev/null +++ b/app/views/email/reset_password_email.html.erb @@ -0,0 +1,4 @@ +
<%= t("seminar_signup.click_on_link") %>
+ diff --git a/app/views/seminars/con_login.html.erb b/app/views/seminars/con_login.html.erb index 7125135..c91d146 100644 --- a/app/views/seminars/con_login.html.erb +++ b/app/views/seminars/con_login.html.erb @@ -39,8 +39,12 @@ <%= password_field_tag :password, nil, :placeholder => t(:dots), :id=>"user_password" %><%= description.html_safe %> | <% end %> <% if show3 %> -<%= link_to seminar_signup_contribute.disp_filename, seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub(" "," , ")).text, :download=>seminar_signup_contribute.disp_filename} if seminar_signup_contribute.file.file %> |
+
+ <% if show2 %>
+ <%= link_to seminar_signup_contribute.disp_filename, seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub(" "," , ")).text, :download=>seminar_signup_contribute.disp_filename} if seminar_signup_contribute.file.file %> + <% else %> + <%= link_to seminar_signup_contribute.disp_filename, seminar_signup_contribute.file.url, {:target => '_blank', :title => seminar_signup_contribute.disp_filename, :download=>seminar_signup_contribute.disp_filename} if seminar_signup_contribute.file.file %> + <% end %> + |
<% end %>
<% if seminar_submission_field %>
<%= seminar_signup_contribute.seminar_submission_values.where(:seminar_submission_field=>seminar_submission_field).first.get_value_by_locale(I18n.locale) %> | <% end %>
- <%= link_to t(:edit), prefix_url + '?method=edit_file&con_no=' + seminar_signup_contribute.id, :class => 'btn btn-primary' %>
+ <%= link_to t(:edit), prefix_url + '?method=edit_file&con_no=' + seminar_signup_contribute.id, :class => 'btn btn-primary', :style => 'display:block; width: 150px;' %>
<%= form_tag(del_file_seminars_path, {method: "post"}) do |f| %>
<%= submit_tag t(:delete_), class: "btn btn-primary" %>
<%= hidden_field_tag "referer_url", request.original_url.split(request.env["HTTP_HOST"]).last.split('?').first %>
@@ -89,7 +96,7 @@
<% if ( @seminar.contribute_file_count.blank? or @seminar_signup.seminar_signup_contributes.count < @seminar.contribute_file_count.to_i ) %>
- <%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('seminar_signup.new_'), prefix_url + '?method=add_file', :class => 'btn btn-primary' %>
+ <%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('seminar_signup.new_'), prefix_url + '?method=add_file', :class => 'btn btn-primary' , :style => 'display:block; width: 150px;' %>
<% end %>
diff --git a/app/views/seminars/index.html.erb b/app/views/seminars/index.html.erb index a64cdf1..9f8f71c 100644 --- a/app/views/seminars/index.html.erb +++ b/app/views/seminars/index.html.erb @@ -6,12 +6,14 @@ @time_now = data["time_now"] %> <% begin %> -
|