讨论区发帖协同得分+2
This commit is contained in:
parent
463508c1f3
commit
ee030e6fb5
|
@ -54,6 +54,7 @@ class Message < ActiveRecord::Base
|
|||
|
||||
# fq
|
||||
after_create :act_as_activity
|
||||
before_save :be_user_score
|
||||
# end
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
|
@ -121,4 +122,11 @@ class Message < ActiveRecord::Base
|
|||
self.acts << Activity.new(:user_id => self.author_id)
|
||||
end
|
||||
# end
|
||||
|
||||
# update user score
|
||||
def be_user_score
|
||||
if self.new_record?
|
||||
UserScore.joint(:post_message, User.current,nil, { message_id: self.id })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -47,16 +47,28 @@ class UserScore < ActiveRecord::Base
|
|||
#
|
||||
# Returns boolean. 返回积分保存结果
|
||||
def self.joint(operate, current_user, target_user, options={})
|
||||
current_user, target_user = get_users(current_user, target_user)
|
||||
user_score = current_user.user_score_attr
|
||||
case operate
|
||||
when :post_message # current_user 发帖了
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a message. options => (#{options.to_s})"
|
||||
when :post_issue # current_user 对 target_user 的缺陷留言了
|
||||
when :post_message # current_user 发帖了
|
||||
user_score.collaboration = user_score.collaboration.to_i + 2
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a message. options => (#{options.to_s})"
|
||||
when :post_issue # current_user 对 target_user 的缺陷留言了
|
||||
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a issue. options => (#{options.to_s})"
|
||||
when :change_issue_status # current_user 更改了缺陷的状态
|
||||
when :change_issue_status # current_user 更改了缺陷的状态
|
||||
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} change issue status. options => (#{options.to_s})"
|
||||
when :reply_message # current_user 对 target_user 留言的回复
|
||||
when :reply_message # current_user 对 target_user 留言的回复
|
||||
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply message. options => (#{options.to_s})"
|
||||
when :reply_posting # current_user 对 target_user 帖子的回复
|
||||
when :reply_posting # current_user 对 target_user 帖子的回复
|
||||
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply posting. options => (#{options.to_s})"
|
||||
else
|
||||
Rails.logger.error "[UserScore#joint] ===> #{operate} is not define."
|
||||
|
@ -77,8 +89,12 @@ class UserScore < ActiveRecord::Base
|
|||
#
|
||||
# Returns boolean. 返回积分保存结果
|
||||
def self.influence(operate, current_user, target_user, options={})
|
||||
current_user, target_user = get_users(current_user, target_user)
|
||||
user_score = current_user.user_score_attr
|
||||
case operate
|
||||
when :followed_by # current_user 关注了target_user
|
||||
when :followed_by # current_user 关注了target_user
|
||||
user_score.active = user_score.influence.to_i + 2
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#influence] ===> User: #{current_user} be followed. options => (#{options.to_s})"
|
||||
else
|
||||
Rails.logger.error "[UserScore#influence] ===> #{operate} is not define."
|
||||
|
@ -99,6 +115,8 @@ class UserScore < ActiveRecord::Base
|
|||
#
|
||||
# Returns boolean. 返回积分保存结果
|
||||
def self.skill(operate, current_user, target_user, options={})
|
||||
current_user, target_user = get_users(current_user, target_user)
|
||||
user_score = current_user.user_score_attr
|
||||
case operate
|
||||
# when :treading # current_user 踩了 target_user 的帖子
|
||||
# Rails.logger.info "[UserScore#skill] ===> User: #{current_user} treading #{target_user}'s posting. options => (#{options.to_s})"
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<h3 class="title"><%= l(:label_user_score) %></h3>
|
||||
<div class="inf_user_image">
|
||||
<table style="border-bottom: solid 1px #80a6d2;", width="100%">
|
||||
<table style="border-bottom: solid 1px #80a6d2;" width="100%">
|
||||
<tr>
|
||||
<td align="left" valign="middle" ><%= image_tag(url_to_avatar(@user), :class => 'avatar2') %></td>
|
||||
<td width="35%">
|
||||
|
@ -46,7 +46,7 @@
|
|||
|
||||
</table>
|
||||
|
||||
<table style="border-bottom: solid 0px #80a6d2;", width="100%">
|
||||
<table style="border-bottom: solid 0px #80a6d2;" width="100%">
|
||||
<tr>
|
||||
<%= link_to l(:label_user_score), {:controller => 'users', :action => 'score_index', :remote => true} %> :
|
||||
<%= format("%.2f" , finall_user_score).to_f %>
|
||||
|
@ -71,6 +71,6 @@
|
|||
|
||||
</div>
|
||||
|
||||
<div id="show_score_detail", style="padding-left: 6px">
|
||||
<div id="show_score_detail" style="padding-left: 6px">
|
||||
<%= render :partial => 'users/score_index', :locals => {:index => 0 } %>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue