Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
cae0893ea6
|
@ -18,6 +18,9 @@
|
|||
class Changeset < ActiveRecord::Base
|
||||
belongs_to :repository
|
||||
belongs_to :user
|
||||
|
||||
after_save :be_user_score # user_score
|
||||
|
||||
has_many :filechanges, :class_name => 'Change', :dependent => :delete_all
|
||||
# fq
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
|
@ -292,4 +295,14 @@ class Changeset < ActiveRecord::Base
|
|||
def self.to_utf8(str, encoding)
|
||||
Redmine::CodesetUtil.to_utf8(str, encoding)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# update user score
|
||||
def be_user_score
|
||||
if self.new_record?
|
||||
UserScore.project(:push_code, self.user, { changeset_id: self.id })
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -144,9 +144,12 @@ class UserScore < ActiveRecord::Base
|
|||
# Returns boolean. 返回积分保存结果
|
||||
def self.project(operate, current_user, options={})
|
||||
current_user, target_user = get_users(current_user, nil)
|
||||
user_score = current_user.user_score_attr
|
||||
user_score = current_user.try(:user_score_attr)
|
||||
return false if current_user.nil?
|
||||
case operate
|
||||
when :push_code # current_user 提交了代码
|
||||
user_score = user_score.active.to_i + 4
|
||||
user_score.save
|
||||
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed code one time. options => (#{options.to_s})"
|
||||
when :push_document # current_user
|
||||
user_score.active = user_score.active.to_i + 4
|
||||
|
|
Loading…
Reference in New Issue