Fix bug.
Add email regex feature. Edit defined_by_applicant feature. Add agree and disagree record time and let admin can click in backend page. Edit frontend select email feature. Remove items and enquiry_for_applicants page.
This commit is contained in:
1 parent
d0062fed8f
commit
10cb149fc7
18 files changed
+563
-105
No files matched your search
@@ -7,6 +7,9 @@ class ApplicationFormMain
|
||||
# encoding: utf-8
|
||||
include OrbitCategory::Categorizable
|
||||
include Slug
|
||||
StaticSignupFields = ["application_form_signup.created_at", "application_form_signup.ip"]
|
||||
DefaultSignupFields = ["created_at", "ip", "serial_number", "review_progress"]
|
||||
ExceptFieldSetDisplays = ["password", "recaptcha"]
|
||||
ChoiceTypes = ["checkbox","radio","select"]
|
||||
# field :annc_count, :type => Integer, :default => 0
|
||||
# field :album_count, :type => Integer, :default => 0
|
||||
@@ -63,6 +66,8 @@ class ApplicationFormMain
|
||||
field :review_end_date, :type => Date
|
||||
field :assign_mode, :type => Integer, :default => 0 # 0 => 用default signup ids來分配 ,1 => 用final_session來分配, 2 => 用final_session來分配(當有preffered session欄位時)
|
||||
field :update_old_flag, :type => Boolean, :default => false
|
||||
field :email_regex_enable, type: Boolean, default: false
|
||||
field :email_regex, type: String, default: '\A[^@\s]+@([^@.\s]+\.)+[^@.\s]+\z'
|
||||
belongs_to :application_form_item
|
||||
belongs_to :organizer , :class_name=>"MemberProfile", :foreign_key => :organizer_id
|
||||
has_many :application_form_sessions, :autosave => true, :dependent => :destroy
|
||||
@@ -195,6 +200,14 @@ class ApplicationFormMain
|
||||
end
|
||||
after_initialize do
|
||||
end
|
||||
def get_email_regex(frontend=false)
|
||||
tmp = self.email_regex
|
||||
if frontend && tmp
|
||||
tmp = tmp.gsub("\\A","^").gsub("\\z","$").gsub("\\","\\\\\\\\")
|
||||
end
|
||||
tmp = nil if !(self.email_regex_enable) || (self.application_form_signup_field_sets.where(:field_name=>'email').pluck(:disabled)[0] rescue false)
|
||||
tmp
|
||||
end
|
||||
def get_max_stage
|
||||
self.reviewer_enables.rindex(true) || 0
|
||||
end
|
||||
|
||||
@@ -3,8 +3,9 @@ class ApplicationFormSignup
|
||||
require 'openssl/cipher'
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
HiddenFields = ['application_form_signup_id', 'password', 'status', 'reviewer_ids_list','_id', 'created_at', 'updated_at','application_form_main_id',"serial_number","final_session","final_sessions","preferred_sessions",'application_form_session_id',"application_form_session_ids","preferred_session","sort_number","abstract_number","presentation_type", "cipher_stage_num", "process_stage", "review_status", "agree_reviewer_ids"]
|
||||
HiddenFields = ['ip', 'application_form_signup_id', 'password', 'status', 'reviewer_ids_list','_id', 'created_at', 'updated_at','application_form_main_id',"serial_number","final_session","final_sessions","preferred_sessions",'application_form_session_id',"application_form_session_ids","preferred_session","sort_number","abstract_number","presentation_type", "cipher_stage_num", "process_stage", "review_status", "agree_reviewer_ids", "agree_reviewer_times"]
|
||||
DefaultEnableFields = ['name','tel','phone','email', 'recaptcha']
|
||||
field :ip, type: String
|
||||
field :sort_number , type: Integer, default: 10000
|
||||
field :process_stage, type: Integer, default: 1
|
||||
field :review_status, type: Integer, default: 0 # 0 => 審核中, 1 => 不通過, 2=> 申請通過
|
||||
@@ -12,7 +13,7 @@ class ApplicationFormSignup
|
||||
field :status
|
||||
field :name # become Last Name for TICC
|
||||
field :tel, type: String # become First Name for TICC
|
||||
field :unit, localize: true
|
||||
field :unit, localize: true #Only localize for preserving old record
|
||||
field :phone, type: String
|
||||
field :fax, type: String
|
||||
field :email, type: String
|
||||
@@ -25,6 +26,7 @@ class ApplicationFormSignup
|
||||
field :preferred_sessions, type: Array, default: []
|
||||
field :reviewer_ids_list, type: Array, default: []
|
||||
field :agree_reviewer_ids, type: Hash, default: {}
|
||||
field :agree_reviewer_times, type: Hash, default: {}
|
||||
def reviewer_ids_list
|
||||
main = self.application_form_main
|
||||
main.reviewer_enables.each_with_index.collect do |e,k|
|
||||
@@ -51,7 +53,12 @@ class ApplicationFormSignup
|
||||
|
||||
before_create do
|
||||
unit = self.unit_translations.values.select{|v| v.present?}.first
|
||||
self.unit_translations = I18n.available_locales.map{|l| [l.to_s,unit]}.to_h
|
||||
tmp_unit_translations = self.unit_translations
|
||||
self.unit_translations = I18n.available_locales.map do |l|
|
||||
l = l.to_s
|
||||
tmp = tmp_unit_translations[l]
|
||||
[l, (tmp ? tmp : unit)]
|
||||
end.to_h
|
||||
self.random_cipher(false)
|
||||
if self.application_form_main
|
||||
enable_idx = self.application_form_main.reviewer_enables.index(true)
|
||||
@@ -107,7 +114,41 @@ class ApplicationFormSignup
|
||||
self.process_stage = new_stage
|
||||
self.save
|
||||
end
|
||||
def review_progress(with_details=true)
|
||||
def procedure(agree_link=nil)
|
||||
stage_trans = I18n.t('application_form.stage')
|
||||
text = ""
|
||||
main = self.application_form_main
|
||||
tmp_process_idx = self.process_stage - 1
|
||||
if main
|
||||
main.reviewer_enables.each_with_index do |t, i|
|
||||
if t
|
||||
text += "<span>#{I18n.t("application_form.num.#{i + 1}")}#{stage_trans}: "
|
||||
if main.reviewer_type_list[i]=='fixed'
|
||||
member_ids = main.reviewer_ids_list[i]
|
||||
is_fixed = true
|
||||
else
|
||||
member_ids = self[:reviewer_ids_list][i] rescue []
|
||||
is_fixed = false
|
||||
end
|
||||
if member_ids.present?
|
||||
text += member_ids.map{|id| MemberProfile.find(id).name rescue nil}.compact.join(', ')
|
||||
if is_fixed
|
||||
text += " (#{I18n.t('application_form.fixed')})"
|
||||
else
|
||||
text += " (#{I18n.t('application_form.defined_by_applicant')})"
|
||||
end
|
||||
end
|
||||
if i == tmp_process_idx && self.review_status == 0 && agree_link
|
||||
text += "<a style=\"margin-left: 0.5em;\" class=\"btn btn-success agree_link\" href=\"#{agree_link}&type=agree\">#{I18n.t('application_form.link_choice.agree')}</a>"
|
||||
text += "<a style=\"margin-left: 0.5em;\" class=\"btn btn-danger disagree_link\" href=\"#{agree_link}&type=disagree\">#{I18n.t('application_form.link_choice.disagree')}</a>"
|
||||
end
|
||||
text += "</span><br>"
|
||||
end
|
||||
end
|
||||
end
|
||||
text
|
||||
end
|
||||
def review_progress(with_details=true, include_time=false)
|
||||
stage_trans = I18n.t('application_form.stage')
|
||||
max_stage = @max_stage
|
||||
if max_stage.nil?
|
||||
@@ -117,17 +158,29 @@ class ApplicationFormSignup
|
||||
text = "#{I18n.t('application_form.num.'+self.process_stage.to_s)}#{stage_trans} / #{I18n.t('application_form.num.'+max_stage.to_s)}#{stage_trans} : #{I18n.t('application_form.status.'+review_status.to_s)}"
|
||||
if with_details
|
||||
text += "<br>"
|
||||
text += review_details
|
||||
text += review_details(include_time)
|
||||
end
|
||||
text
|
||||
end
|
||||
def review_details
|
||||
def review_details(include_time=true)
|
||||
text = ""
|
||||
stage_trans = I18n.t('application_form.stage')
|
||||
last_is_disagree = (self.review_status == 1)
|
||||
last_idx = (self.process_stage - 1).to_s
|
||||
self.agree_reviewer_ids.each do |i, member_id|
|
||||
m = MemberProfile.find(member_id) rescue nil
|
||||
t = agree_reviewer_times[i]
|
||||
if m
|
||||
text += "#{I18n.t('application_form.num.'+(i.to_i+1).to_s)}#{stage_trans}: #{m.tmp_name}<br>"
|
||||
text += "#{I18n.t('application_form.num.'+(i.to_i+1).to_s)}#{stage_trans}: #{m.tmp_name} "
|
||||
if i == last_idx && last_is_disagree
|
||||
text += I18n.t('application_form.link_choice.disagree')
|
||||
else
|
||||
text += I18n.t('application_form.link_choice.agree')
|
||||
end
|
||||
if include_time && t
|
||||
text += " (#{t.to_time.strftime("%Y/%m/%d %H:%M")})"
|
||||
end
|
||||
text += "<br>"
|
||||
end
|
||||
end
|
||||
text
|
||||
@@ -173,10 +226,11 @@ class ApplicationFormSignup
|
||||
field_name = set.field_name
|
||||
next if set.disabled || except_fields.include?(field_name)
|
||||
value = self.send(field_name) rescue nil
|
||||
next if value.nil?
|
||||
localize = self.fields[field_name].options[:localize]
|
||||
next if value.nil? && !localize
|
||||
if field_name == "status"
|
||||
value = I18n.t("application_form.registration_status_#{value}")
|
||||
elsif self.fields[field_name].options[:localize]
|
||||
elsif localize && field_name != "unit"
|
||||
values = self.send("#{field_name}_translations").select{|k,v| v.present?}
|
||||
value = ""
|
||||
if values.count == 0
|
||||
|
||||
Reference in new issue
Block a user