评阅记录的删除

dev_oauth
cxt 5 years ago
parent 58e8d21044
commit 73f3b6577d

@ -541,7 +541,7 @@ class StudentWorksController < ApplicationController
def destroy_score
score = @work.student_works_scores.find_by(id: params[:score_id])
tip_exception("该评阅记录不存在") unless score.present?
tip_exception("该评阅记录不能删除") unless score.allow_delete(current_user, @user_course_identity)
tip_exception("该评阅记录不能删除") unless score.allow_delete(current_user)
begin
score.destroy
normal_status(0,"删除成功")

@ -13,8 +13,8 @@ belongs_to :student_work
identity < Course::STUDENT || self.user == user || self.reviewer_role != 3
end
def allow_delete current_user, identity
self.is_invalid && (current_user == self.user || identity < Course::STUDENT) ||
def allow_delete current_user
(self.is_invalid && (current_user == self.user || current_user.admin?)) ||
(self.score.nil? && current_user == self.user)
end

@ -23,7 +23,7 @@ json.comment_scores @comment_scores do |score|
json.content score.comment
json.appeal_status score.appeal_status
json.is_invalid score.is_invalid
json.delete score.allow_delete(@current_user, @user_course_identity)
json.delete score.allow_delete(@current_user)
json.attachments score.attachments do |atta|
json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: false}
end

Loading…
Cancel
Save