Allow admins and teachers to remove explicit RfC text
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RequestForCommentsController < ApplicationController
|
||||
include CommonBehavior
|
||||
before_action :require_user!
|
||||
before_action :set_request_for_comment, only: %i[show mark_as_solved set_thank_you_note]
|
||||
before_action :set_request_for_comment, only: %i[show mark_as_solved set_thank_you_note clear_question]
|
||||
before_action :set_study_group_grouping,
|
||||
only: %i[index my_comment_requests rfcs_with_my_comments rfcs_for_exercise]
|
||||
|
||||
@ -101,6 +102,12 @@ class RequestForCommentsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
# POST /request_for_comments/1/clear_question
|
||||
def clear_question
|
||||
authorize!
|
||||
update_and_respond(object: @request_for_comment, params: {question: nil})
|
||||
end
|
||||
|
||||
# GET /request_for_comments/1
|
||||
# GET /request_for_comments/1.json
|
||||
def show
|
||||
|
@ -25,6 +25,10 @@ class RequestForCommentPolicy < ApplicationPolicy
|
||||
admin? || author?
|
||||
end
|
||||
|
||||
def clear_question?
|
||||
admin? || teacher_in_study_group?
|
||||
end
|
||||
|
||||
def edit?
|
||||
admin?
|
||||
end
|
||||
|
@ -1,6 +1,7 @@
|
||||
hr
|
||||
h5.mt-4 Admin Menu
|
||||
ul.text
|
||||
li = link_to "Clear question text (in case of explicit text)", clear_question_request_for_comment_path(id: @request_for_comment.id), method: :post if policy(@request_for_comment).clear_question?
|
||||
li = link_to "User's current status of this exercise", statistics_external_user_exercise_path(id: @request_for_comment.exercise_id, external_user_id: @request_for_comment.user_id) if policy(@request_for_comment.exercise).statistics?
|
||||
li = link_to "All exercises of this user", statistics_external_user_path(id: @request_for_comment.user_id) if policy(@request_for_comment.user).statistics?
|
||||
ul.text
|
||||
|
@ -21,6 +21,7 @@ Rails.application.routes.draw do
|
||||
member do
|
||||
get :mark_as_solved, defaults: {format: :json}
|
||||
post :set_thank_you_note, defaults: {format: :json}
|
||||
post :clear_question
|
||||
end
|
||||
end
|
||||
resources :comments, defaults: {format: :json}
|
||||
|
Reference in New Issue
Block a user