From 9fb497e22425f59d14812346d9e8450d88d5a6a2 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 2 Aug 2019 11:04:40 +0800 Subject: [PATCH 1/2] fix --- app/decorators/tiding_decorator.rb | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/app/decorators/tiding_decorator.rb b/app/decorators/tiding_decorator.rb index c9ad806ee..677812217 100644 --- a/app/decorators/tiding_decorator.rb +++ b/app/decorators/tiding_decorator.rb @@ -2,6 +2,9 @@ module TidingDecorator def content method_name = "#{container_type.underscore}_content" respond_to?(method_name) ? send(method_name) : '' + rescue => ex + Util.logger_error(ex) + '' end def how_long_time @@ -261,16 +264,16 @@ module TidingDecorator def journal_content case tiding_type when 'Mentioned' then - I18n.t(locale_format(tiding_type)) % message_content_helper(container.notes) + I18n.t(locale_format(tiding_type)) % message_content_helper(container&.notes) when 'Comment' then - I18n.t(locale_format(tiding_type, container.parent.present?)) % message_content_helper(container.notes) + I18n.t(locale_format(tiding_type, container.parent.present?)) % message_content_helper(container&.notes) else - I18n.t(locale_format) % container.issue.subject + I18n.t(locale_format) % container&.issue&.subject end end def issue_content - I18n.t(locale_format) % container.subject + I18n.t(locale_format) % container&.subject end def pull_request_content @@ -291,15 +294,15 @@ module TidingDecorator end def poll_content - I18n.t(locale_format(parent_container_type)) % container.polls_name + I18n.t(locale_format(parent_container_type)) % container&.polls_name end def exercise_content - I18n.t(locale_format(parent_container_type)) % container.exercise_name + I18n.t(locale_format(parent_container_type)) % container&.exercise_name end def student_graduation_topic_content - I18n.t(locale_format) % container.graduation_topic.try(:name) + I18n.t(locale_format) % container&.graduation_topic.try(:name) end def deal_student_topic_select_content @@ -307,27 +310,27 @@ module TidingDecorator end def graduation_task_content - I18n.t(locale_format(parent_container_type)) % container.name + I18n.t(locale_format(parent_container_type)) % container&.name end def graduation_work_content - I18n.t(locale_format(extra.nil?)) % container.graduation_task.try(:name) + I18n.t(locale_format(extra.nil?)) % container&.graduation_task.try(:name) end def graduation_work_score_content - I18n.t(locale_format) % container.graduation_work.graduation_task.try(:name) + I18n.t(locale_format) % container&.graduation_work&.graduation_task.try(:name) end def homework_common_content - I18n.t(locale_format(parent_container_type), name: container.name, reason: extra) + I18n.t(locale_format(parent_container_type), name: container&.name, reason: extra) end def student_work_content - I18n.t(locale_format(extra.nil?)) % container.homework_common.try(:name) + I18n.t(locale_format(extra.nil?)) % container&.homework_common.try(:name) end def student_works_score_content - I18n.t(locale_format(extra)) % container.student_work.homework_common.try(:name) + I18n.t(locale_format(extra)) % container&.student_work&.homework_common.try(:name) end def challenge_work_score_content From 8db1823226e64cc1ba9c83ff64c07bbfcebd8c5c Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 2 Aug 2019 11:07:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/memos_controller.rb | 8 ++------ dump.rdb | Bin 551 -> 668 bytes 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 0475eb0da..9d7beb6c1 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -3,7 +3,7 @@ class MemosController < ApplicationController before_action :set_memo, only: [:show, :edit, :update, :destroy, :sticky_or_cancel, :hidden, :more_reply] before_action :validate_memo_params, only: [:create, :update] before_action :owner_or_admin, only: [:edit, :update, :destroy] - before_action :is_admin, only: [:sticky_or_cancel, :hidden] + before_action :require_business, only: [:sticky_or_cancel, :hidden] include ApplicationHelper # GET /memos @@ -132,7 +132,7 @@ class MemosController < ApplicationController def hidden tip_exception("不能对主贴进行隐藏操作") if @memo.parent_id.nil? begin - @memo.update_attributes!(hidden: !@memo.hidden) + @memo.update_attributes!(hidden: @memo.hidden == 0 ? 1 : 0) normal_status("更新成功") rescue Exception => e tip_exception("更新失败,原因:#{e}") @@ -182,10 +182,6 @@ class MemosController < ApplicationController tip_exception(403, "无权限操作") unless @memo.author == current_user || current_user.admin? || current_user.business? end - def is_admin - tip_exception(403, "无权限操作") unless current_user.admin? || current_user.business? - end - # Never trust parameters from the scary internet, only allow the white list through. def memo_params params.require(:memo).permit(:subject, :content, :forum_id) diff --git a/dump.rdb b/dump.rdb index a799840b19b627ba79861403e776c55d27442bac..4687968bdc78f7e61538606ad77386166339f236 100644 GIT binary patch delta 421 zcmWmAO=}ZD7y#hiP11&>B7*c}$#%hm9~0+uXC^1pDyX0!3Oz|WGy86vrb%=^T574b z;7Ko*UOd=yz4;f4SAT)GvR(!63a$A3gy*FGx$zNSIry^t;!m^8Awgppe>=5@{aa+| z^1b$KyY6|-!1KbO)Bn30xlNPjQ7`JdVz>p5rnc96T0#l^#Jrq4JYKsF$}+5z7=d66 zaibMd%%q6A)at~tnx<)dbi=3Jdh{5^)9`tNam}LJs}GyIQ8q1$;biUf&ZU9b800%+ zJKY?NU}sevz4sU1zH7W*N6Sy5yNk69iY$CnE3y*8-}}GjQ)vw6I$?rX!%_*_GEPnS z;hM|96p#!|5%q|Oxg>%x+2t(8l!Oy+Vz$m&ou;N5tG)AczxwL86Ba9#!~$VVBL8ZN zQ)IZ@7RbiV38e{_ST2UueShXzX*a+X;fhBp2i7dkpob!ByBL1bZYk)3BHWHUB6IAk_8Eif=KGc7b` zFlH@bG&eOZVm4!AH8?pj12i`}P9i`d19D|_av*;LbaHiNAn;)A z7c?QZee%e3X^vN9SB{g@}Rpw8d??$RI>m8