Skip to content

Commit

Permalink
Refactor and remove bank model
Browse files Browse the repository at this point in the history
  • Loading branch information
lgn21st committed Jul 24, 2014
1 parent a054e45 commit d3926ed
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 85 deletions.
1 change: 0 additions & 1 deletion app/assets/javascripts/fund_source.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Selectize.define 'option_destroy', ->
(e) ->
$target = $(e.target)
if $target.hasClass('fa-trash-o')
console.log $target.parent()
$.ajax
url: "/fund_sources/#{encodeURIComponent($target.parent().data('fs-uid'))}"
type: 'DELETE'
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/deposits/ctrl_bankable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def new
@deposit = model_kls.new member: current_user, account: @account, member: current_user
@fund_sources = current_user.fund_sources.with_channel(@channel.id)
@assets = model_kls.where(member: current_user).order('id desc').first(10)
gon.banks = ::Bank.fetch
gon.banks = model_kls.bank_hash
end

def create
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/withdraws/ctrl_bankable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def new
@fund_sources = current_user.fund_sources.with_channel(channel.id)
@assets = model_kls.without_aasm_state(:submitting).where(member: current_user).order('id desc').first(10)

gon.banks = ::Bank.fetch
gon.banks = model_kls.bank_hash
end

def create
Expand Down
8 changes: 0 additions & 8 deletions app/models/bank.rb

This file was deleted.

9 changes: 7 additions & 2 deletions app/models/concerns/deposits/bankable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ module Bankable

delegate :receive_fund_holder_text, :receive_fund_uid_text, :receive_fund_extra_text, to: :channel

enumerize :fund_extra, in: channel.banks, scope: true, \
i18n_scope: ["deposit_channel.#{name.demodulize.underscore}.banks", 'banks']
enumerize :fund_extra, in: channel.banks, scope: true, i18n_scope: 'banks'
end

module ClassMethods
def bank_hash
enumerized_attributes['fund_extra'].options.inject({}) {|k, v| k[v[1]] = v[0]; k}
end
end
end
end
8 changes: 6 additions & 2 deletions app/models/concerns/withdraws/bankable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ module Bankable

alias_attribute :remark, :id

enumerize :fund_extra, in: channel.banks, scope: true, \
i18n_scope: ["withdraw_channel.#{name.demodulize.underscore}.banks", 'banks']
enumerize :fund_extra, in: channel.banks, scope: true, i18n_scope: 'banks'
end

module ClassMethods
def bank_hash
enumerized_attributes['fund_extra'].options.inject({}) {|k, v| k[v[1]] = v[0]; k}
end
end
end
end
45 changes: 0 additions & 45 deletions config/banks.yml

This file was deleted.

2 changes: 1 addition & 1 deletion config/deposit_channels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
key: bank
currency: cny
sort_order: 2
banks: ["icbc", "cbc", "bc", "bcm", "abc", "cmb", "cmbc", "cncb", "hxb", "cib", "spdb", "bob", "cncb", "ceb", "sdb", "pab", "gdb"]
banks: ["icbc", "cbc", "bc", "bcm", "abc", "cmb", "cmbc", "cncb", "hxb", "cib", "spdb", "bob", "ceb", "sdb", "pab", "gdb"]
18 changes: 18 additions & 0 deletions config/locales/banks/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
en:
banks:
icbc: Industryand Commercial Bank of China
cbc: Construction Bank of China
bc: Bank of China
bcm: Bank of Communications
abc: Agriculture Bank of China
cmb: China Merchants Bank Ltd
cmbc: China Minsheng Banking Co., Ltd
cncb: China CITIC Bank
hxb: Hua Xia Bank Co., Ltd.
cib: Industrial Bank Co., Ltd
spdb: Shanghai Pudong Development Bank
bob: Bank of Beijing
ceb: China Everbright Bank CO.LTD
sdb: Shenzhen Development Bank
pab: Ping An Bank Co., Ltd.
gdb: Guangdong Development Bank
18 changes: 18 additions & 0 deletions config/locales/banks/zh-CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
zh-CN:
banks:
icbc: 工商银行
cbc: 建设银行
bc: 中国银行
bcm: 交通银行
abc: 农业银行
cmb: 招商银行
cmbc: 民生银行
cncb: 中信银行
hxb: 华夏银行
cib: 兴业银行
spdb: 浦东发展银行
bob: 北京银行
ceb: 光大银行
sdb: 深圳发展银行
pab: 平安银行
gdb: 广东发展银行
5 changes: 0 additions & 5 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,3 @@ en:
'yes': 'Yes'
'no': 'No'

banks:
bc: Bank of China
abc: Agriculture Bank of China
cbc: Construction Bank of China
icbc: Industryand Commercial Bank of China
18 changes: 0 additions & 18 deletions config/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,3 @@ zh-CN:
'yes':
'no':

banks:
cmbc: 招商银行
bc: 中国银行
icbc: 工商银行
cbc: 建设银行
abc: 农业银行
cmb: 招商银行
cmbc: 民生银行
bcm: 交通银行
cncb: 中信银行
hxb: 华夏银行
cib: 兴业银行
spdb: 浦东发展银行
bob: 北京银行
ceb: 光大银行
sdb: 深圳发展银行
gdb: 广东发展银行
pab: 平安银行
2 changes: 1 addition & 1 deletion config/withdraw_channels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
fee: 0.003
proportion: true
inuse: true
banks: ["icbc", "cbc", "bc", "bcm", "abc", "cmb", "cmbc", "cncb", "hxb", "cib", "spdb", "bob", "cncb", "ceb", "sdb", "pab", "gdb"]
banks: ["icbc", "cbc", "bc", "bcm", "abc", "cmb", "cmbc", "cncb", "hxb", "cib", "spdb", "bob", "ceb", "sdb", "pab", "gdb"]
type: WithdrawChannelBank

0 comments on commit d3926ed

Please sign in to comment.