mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
init project
This commit is contained in:
30
app/models/apply_action.rb
Normal file
30
app/models/apply_action.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
# 申请消息
|
||||
class ApplyAction < ApplicationRecord
|
||||
belongs_to :user
|
||||
|
||||
has_many :tidings, :as => :container, :dependent => :destroy
|
||||
after_create :send_tiding
|
||||
|
||||
def status_text
|
||||
I18n.t!("apply_action.status.#{status}")
|
||||
rescue I18n::MissingTranslationData
|
||||
nil
|
||||
end
|
||||
|
||||
def send_tiding
|
||||
if container_type == 'TrialAuthorization' && status == 1
|
||||
tidings.create(user_id: user_id, trigger_user_id: 0, status: 1, viewed: 0, tiding_type: 'System',
|
||||
parent_container_id: container_id, parent_container_type: container_type,
|
||||
belong_container_id: container_id, belong_container_type: 'User')
|
||||
elsif %w(ApplyShixun ApplySubject TrialAuthorization).include?(container_type)
|
||||
belong_container_type = if container_type == 'TrialAuthorization'
|
||||
'User'
|
||||
else
|
||||
container_type == 'ApplyShixun' ? 'Shixun' : 'Subject'
|
||||
end
|
||||
tidings.create(user_id: '1', trigger_user_id: user_id, status: 0, viewed: 0, tiding_type: 'Apply',
|
||||
parent_container_id: container_id, parent_container_type: container_type,
|
||||
belong_container_id: container_id, belong_container_type: belong_container_type)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user