From b5ef40118eb860183b6d4f3bedc1aef57d023969 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 25 Dec 2019 11:32:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/comments_controller.rb | 1 + app/controllers/hacks_controller.rb | 4 +++- app/decorators/tiding_decorator.rb | 8 +++++++- app/models/discuss.rb | 2 +- app/models/hack.rb | 3 ++- config/locales/tidings/zh-CN.yml | 13 +++++++++++-- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index c5d3082ba..3b0ac86a7 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -23,6 +23,7 @@ class CommentsController < ApplicationController @discuss.hidden = false @discuss.user_id = current_user.id @discuss.root_id = params[:comments][:parent_id] + @discusses.parent_container_id = @discuss.save! rescue Exception => e uid_logger_error("reply discuss failed : #{e.message}") diff --git a/app/controllers/hacks_controller.rb b/app/controllers/hacks_controller.rb index 7a0fb7635..cb2e67922 100644 --- a/app/controllers/hacks_controller.rb +++ b/app/controllers/hacks_controller.rb @@ -100,6 +100,7 @@ class HacksController < ApplicationController @hack.update_attribute(:status, 1) base_attrs = { trigger_user_id: current_user.id, viewed: 0, tiding_type: 'System', user_id: @hack.user_id, + parent_container_type: "HackPublish" } @hack.tidings.create!(base_attrs) render_ok @@ -109,7 +110,8 @@ class HacksController < ApplicationController def cancel_publish @hack.update_attribute(:status, 0) base_attrs = { - trigger_user_id: current_user.id, viewed: 0, tiding_type: 'System', user_id: @hack.user_id + trigger_user_id: current_user.id, viewed: 0, tiding_type: 'System', user_id: @hack.user_id, + parent_container_type: "HackUnPublish" } @hack.tidings.create!(base_attrs) render_ok diff --git a/app/decorators/tiding_decorator.rb b/app/decorators/tiding_decorator.rb index ff198468a..a9f60b890 100644 --- a/app/decorators/tiding_decorator.rb +++ b/app/decorators/tiding_decorator.rb @@ -220,11 +220,13 @@ module TidingDecorator when 'Journal' then message = parent_container&.notes.present? ? ':' + message_content_helper(parent_container.notes) : '' I18n.t(locale_format(parent_container_type)) % message + when 'Hack' then + I18n.t(locale_format(parent_container_type)) % parent_container.name end end def discuss_content - I18n.t(locale_format(container.parent_id.present?)) % message_content_helper(container.content) + I18n.t(locale_format(container_type, container.parent_id.present?)) % message_content_helper(container.content) end def grade_content @@ -408,4 +410,8 @@ module TidingDecorator def subject_start_course_content I18n.t(locale_format) % belong_container&.name end + + def hack_content + I18n.t(locale_format(parent_container_type)) % container&.name + end end diff --git a/app/models/discuss.rb b/app/models/discuss.rb index 148d6518b..4491a886c 100644 --- a/app/models/discuss.rb +++ b/app/models/discuss.rb @@ -59,7 +59,7 @@ class Discuss < ApplicationRecord elsif dis_type == 'Hack' user_id = has_parent? ? parent.user_id : Hack.find(dis_id).user_id parent_container_type = 'Hack' - challenge_id = nil + challenge_id = dis_id end base_attrs = { trigger_user_id: user_id, parent_container_id: challenge_id, parent_container_type: parent_container_type, diff --git a/app/models/hack.rb b/app/models/hack.rb index d1ec3932c..915ff6f9e 100644 --- a/app/models/hack.rb +++ b/app/models/hack.rb @@ -56,7 +56,8 @@ class Hack < ApplicationRecord private def send_delete_tiding base_attrs = { - user_id: user_id, viewed: 0, tiding_type: 'Delete', trigger_user_id: current_user.id, content: "你删除了题目:#{name}" + user_id: user_id, viewed: 0, tiding_type: 'System', trigger_user_id: current_user.id, + parent_container_type: "HackDelete" } tidings.create!(base_attrs) end diff --git a/config/locales/tidings/zh-CN.yml b/config/locales/tidings/zh-CN.yml index dc56ad345..cdde0f97f 100644 --- a/config/locales/tidings/zh-CN.yml +++ b/config/locales/tidings/zh-CN.yml @@ -93,6 +93,7 @@ Challenge: "1_end": "赞了你发布的实训任务:%s,第%s关" "2_end": "踩了你发布的实训任务:%s,第%s关" + Hack_end: "赞了你发布的题目:%s" Memo: true_end: "赞了你的评论:%s" false_end: "赞了发布的帖子:%s" @@ -107,8 +108,16 @@ Issue_end: "赞了你发布的项目Issue:%s" Journal_end: "赞了你的回复%s" Discuss: - true_end: "评论了你的回复:%s" - false_end: "评论了你发布的实训:%s" + Shixun: + true_end: "评论了你的回复:%s" + false_end: "评论了你发布的实训:%s" + Hack: + true_end: "评论了你的回复:%s" + false_end: "评论了你发布的题目:%s" + Hack: + HackPublish_end: "你发布了题目:%s" + HackUnPublish_end: "你撤销发布了题目:%s" + HackDelete_end: "你删除了题目:%s" Grade: Avatar_end: "首次上传头像获得金币奖励:%s金币" Phone_end: "首次绑定手机号码获得金币奖励:%s金币"