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/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 diff --git a/dump.rdb b/dump.rdb index a799840b1..4687968bd 100644 Binary files a/dump.rdb and b/dump.rdb differ