Files
codeocean/app/controllers/events_controller.rb
Sebastian Serth 092487344a Replace obsolete HTTP status code :unprocessable_entity
The new naming is :unprocessable_content and required by Rack 3.1+
2024-06-17 15:07:04 +02:00

38 lines
936 B
Ruby

# frozen_string_literal: true
class EventsController < ApplicationController
before_action :require_user!
def create
@event = Event.new(event_params)
authorize!
respond_to do |format|
if @event.save
format.html { head :created }
format.json { head :created }
else
format.html { head :unprocessable_content }
format.json { head :unprocessable_content }
end
end
end
private
def authorize!
authorize(@event || @events)
end
def event_params
# The file ID processed here is the context of the exercise (template),
# not in the context of the submission!
params[:event]
&.permit(:category, :data, :exercise_id, :file_id)
&.merge(user: current_user, programming_group:, study_group_id: current_user.current_study_group_id)
end
def programming_group
current_contributor if current_contributor.programming_group?
end
end