Add StudyGroup to submissions and show it for submissions and RfCs

Also take care of deleting a StudyGroup for existing submissions
This commit is contained in:
Sebastian Serth
2019-02-14 18:09:21 +01:00
parent 532416b9d3
commit 6e03939c10
8 changed files with 29 additions and 20 deletions

View File

@ -83,17 +83,10 @@ class RequestForCommentsController < ApplicationController
authorize!
end
# GET /request_for_comments/new
def new
@request_for_comment = RequestForComment.new
authorize!
end
# GET /request_for_comments/1/edit
def edit
end
# POST /request_for_comments
# POST /request_for_comments.json
def create
# Consider all requests as JSON
@ -149,8 +142,8 @@ class RequestForCommentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def request_for_comment_params
# we are using the current_user.id here, since internal users are not able to create comments. The external_user.id is a primary key and does not require the consumer_id to be unique.
params.require(:request_for_comment).permit(:exercise_id, :file_id, :question, :requested_at, :solved, :submission_id).merge(user_id: current_user.id, user_type: current_user.class.name)
# The study_group_id might not be present in the session (e.g. for internal users), resulting in session[:study_group_id] = nil which is intended.
params.require(:request_for_comment).permit(:exercise_id, :file_id, :question, :requested_at, :solved, :submission_id).merge(user_id: current_user.id, user_type: current_user.class.name, study_group_id: session[:study_group_id])
end
def comment_params