Update find method
This commit is contained in:
@ -12,7 +12,7 @@ class LaExercisesChannel < ApplicationCable::Channel
|
|||||||
private
|
private
|
||||||
|
|
||||||
def specific_channel
|
def specific_channel
|
||||||
reject unless StudyGroupPolicy.new(current_user, StudyGroup.find_by(id: params[:study_group_id])).stream_la?
|
reject unless StudyGroupPolicy.new(current_user, StudyGroup.find(params[:study_group_id])).stream_la?
|
||||||
"la_exercises_#{params[:exercise_id]}_channel_study_group_#{params[:study_group_id]}"
|
"la_exercises_#{params[:exercise_id]}_channel_study_group_#{params[:study_group_id]}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -41,7 +41,7 @@ module CodeOcean
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@file = CodeOcean::File.find_by(id: params[:id])
|
@file = CodeOcean::File.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
destroy_and_respond(object: @file, path: @file.context)
|
destroy_and_respond(object: @file, path: @file.context)
|
||||||
end
|
end
|
||||||
|
@ -43,7 +43,7 @@ class CodeharborLinksController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_codeharbor_link
|
def set_codeharbor_link
|
||||||
@codeharbor_link = CodeharborLink.find_by(id: params[:id])
|
@codeharbor_link = CodeharborLink.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class CommentsController < ApplicationController
|
|||||||
|
|
||||||
# GET /comments.json
|
# GET /comments.json
|
||||||
def index
|
def index
|
||||||
file = CodeOcean::File.find_by(id: params[:file_id])
|
file = CodeOcean::File.find(params[:file_id])
|
||||||
# there might be no submission yet, so dont use find
|
# there might be no submission yet, so dont use find
|
||||||
submission = Submission.find_by(id: file.context_id)
|
submission = Submission.find_by(id: file.context_id)
|
||||||
if submission
|
if submission
|
||||||
@ -38,7 +38,7 @@ class CommentsController < ApplicationController
|
|||||||
|
|
||||||
if @comment.save
|
if @comment.save
|
||||||
if comment_params[:request_id]
|
if comment_params[:request_id]
|
||||||
request_for_comment = RequestForComment.find_by(id: comment_params[:request_id])
|
request_for_comment = RequestForComment.find(comment_params[:request_id])
|
||||||
send_mail_to_author @comment, request_for_comment
|
send_mail_to_author @comment, request_for_comment
|
||||||
send_mail_to_subscribers @comment, request_for_comment
|
send_mail_to_subscribers @comment, request_for_comment
|
||||||
end
|
end
|
||||||
@ -71,7 +71,7 @@ class CommentsController < ApplicationController
|
|||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_comment
|
def set_comment
|
||||||
@comment = Comment.find_by(id: params[:id])
|
@comment = Comment.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def comment_params_for_update
|
def comment_params_for_update
|
||||||
|
@ -90,11 +90,11 @@ class CommunitySolutionsController < ApplicationController
|
|||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_community_solution
|
def set_community_solution
|
||||||
@community_solution = CommunitySolution.find_by(id: params[:id])
|
@community_solution = CommunitySolution.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_community_solution_lock
|
def set_community_solution_lock
|
||||||
@community_solution_lock = CommunitySolutionLock.find_by(id: params[:lock_id])
|
@community_solution_lock = CommunitySolutionLock.find(params[:lock_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_exercise_and_submission
|
def set_exercise_and_submission
|
||||||
|
@ -38,7 +38,7 @@ class ConsumersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_consumer
|
def set_consumer
|
||||||
@consumer = Consumer.find_by(id: params[:id])
|
@consumer = Consumer.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_consumer
|
private :set_consumer
|
||||||
|
@ -86,7 +86,7 @@ class ErrorTemplateAttributesController < ApplicationController
|
|||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_error_template_attribute
|
def set_error_template_attribute
|
||||||
@error_template_attribute = ErrorTemplateAttribute.find_by(id: params[:id])
|
@error_template_attribute = ErrorTemplateAttribute.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_template_attribute_params
|
def error_template_attribute_params
|
||||||
|
@ -77,7 +77,7 @@ class ErrorTemplatesController < ApplicationController
|
|||||||
|
|
||||||
def add_attribute
|
def add_attribute
|
||||||
authorize!
|
authorize!
|
||||||
@error_template.error_template_attributes << ErrorTemplateAttribute.find_by(id: params[:error_template_attribute_id])
|
@error_template.error_template_attributes << ErrorTemplateAttribute.find(params[:error_template_attribute_id])
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to @error_template }
|
format.html { redirect_to @error_template }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
@ -86,7 +86,7 @@ class ErrorTemplatesController < ApplicationController
|
|||||||
|
|
||||||
def remove_attribute
|
def remove_attribute
|
||||||
authorize!
|
authorize!
|
||||||
@error_template.error_template_attributes.delete(ErrorTemplateAttribute.find_by(id: params[:error_template_attribute_id]))
|
@error_template.error_template_attributes.delete(ErrorTemplateAttribute.find(params[:error_template_attribute_id]))
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to @error_template }
|
format.html { redirect_to @error_template }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
@ -97,7 +97,7 @@ class ErrorTemplatesController < ApplicationController
|
|||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_error_template
|
def set_error_template
|
||||||
@error_template = ErrorTemplate.find_by(id: params[:id])
|
@error_template = ErrorTemplate.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_template_params
|
def error_template_params
|
||||||
|
@ -141,7 +141,7 @@ class ExecutionEnvironmentsController < ApplicationController
|
|||||||
private :set_docker_images
|
private :set_docker_images
|
||||||
|
|
||||||
def set_execution_environment
|
def set_execution_environment
|
||||||
@execution_environment = ExecutionEnvironment.find_by(id: params[:id])
|
@execution_environment = ExecutionEnvironment.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_execution_environment
|
private :set_execution_environment
|
||||||
|
@ -41,7 +41,7 @@ class ExerciseCollectionsController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def set_exercise_collection
|
def set_exercise_collection
|
||||||
@exercise_collection = ExerciseCollection.find_by(id: params[:id])
|
@exercise_collection = ExerciseCollection.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class ExercisesController < ApplicationController
|
|||||||
@exercises = Exercise.all
|
@exercises = Exercise.all
|
||||||
authorize!
|
authorize!
|
||||||
@exercises = params[:exercises].values.map do |exercise_params|
|
@exercises = params[:exercises].values.map do |exercise_params|
|
||||||
exercise = Exercise.find_by(id: exercise_params.delete(:id))
|
exercise = Exercise.find(exercise_params.delete(:id))
|
||||||
exercise.update(exercise_params)
|
exercise.update(exercise_params)
|
||||||
exercise
|
exercise
|
||||||
end
|
end
|
||||||
@ -439,7 +439,7 @@ class ExercisesController < ApplicationController
|
|||||||
private :set_execution_environments
|
private :set_execution_environments
|
||||||
|
|
||||||
def set_exercise_and_authorize
|
def set_exercise_and_authorize
|
||||||
@exercise = Exercise.find_by(id: params[:id])
|
@exercise = Exercise.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ class ExercisesController < ApplicationController
|
|||||||
|
|
||||||
def set_external_user_and_authorize
|
def set_external_user_and_authorize
|
||||||
if params[:external_user_id]
|
if params[:external_user_id]
|
||||||
@external_user = ExternalUser.find_by(id: params[:external_user_id])
|
@external_user = ExternalUser.find(params[:external_user_id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -15,7 +15,7 @@ class ExternalUsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@user = ExternalUser.find_by(id: params[:id])
|
@user = ExternalUser.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class ExternalUsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def statistics
|
def statistics
|
||||||
@user = ExternalUser.find_by(id: params[:id])
|
@user = ExternalUser.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
|
|
||||||
statistics = {}
|
statistics = {}
|
||||||
@ -73,7 +73,7 @@ class ExternalUsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def tag_statistics
|
def tag_statistics
|
||||||
@user = ExternalUser.find_by(id: params[:id])
|
@user = ExternalUser.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
|
|
||||||
statistics = []
|
statistics = []
|
||||||
|
@ -87,7 +87,7 @@ class FileTemplatesController < ApplicationController
|
|||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_file_template
|
def set_file_template
|
||||||
@file_template = FileTemplate.find_by(id: params[:id])
|
@file_template = FileTemplate.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_template_params
|
def file_template_params
|
||||||
|
@ -51,7 +51,7 @@ class FileTypesController < ApplicationController
|
|||||||
private :set_editor_modes
|
private :set_editor_modes
|
||||||
|
|
||||||
def set_file_type
|
def set_file_type
|
||||||
@file_type = FileType.find_by(id: params[:id])
|
@file_type = FileType.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_file_type
|
private :set_file_type
|
||||||
|
@ -127,7 +127,7 @@ class InternalUsersController < ApplicationController
|
|||||||
private :set_up_password
|
private :set_up_password
|
||||||
|
|
||||||
def set_user
|
def set_user
|
||||||
@user = InternalUser.find_by(id: params[:id])
|
@user = InternalUser.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_user
|
private :set_user
|
||||||
|
@ -24,7 +24,7 @@ class ProxyExercisesController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
myparams = proxy_exercise_params
|
myparams = proxy_exercise_params
|
||||||
myparams[:exercises] = Exercise.find_by(id: myparams[:exercise_ids].compact_blank)
|
myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank)
|
||||||
@proxy_exercise = ProxyExercise.new(myparams)
|
@proxy_exercise = ProxyExercise.new(myparams)
|
||||||
authorize!
|
authorize!
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class ProxyExercisesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_exercise_and_authorize
|
def set_exercise_and_authorize
|
||||||
@proxy_exercise = ProxyExercise.find_by(id: params[:id])
|
@proxy_exercise = ProxyExercise.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_exercise_and_authorize
|
private :set_exercise_and_authorize
|
||||||
@ -78,7 +78,7 @@ class ProxyExercisesController < ApplicationController
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
myparams = proxy_exercise_params
|
myparams = proxy_exercise_params
|
||||||
myparams[:exercises] = Exercise.find_by(id: myparams[:exercise_ids].compact_blank)
|
myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank)
|
||||||
update_and_respond(object: @proxy_exercise, params: myparams)
|
update_and_respond(object: @proxy_exercise, params: myparams)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -58,7 +58,7 @@ class RequestForCommentsController < ApplicationController
|
|||||||
|
|
||||||
# GET /exercises/:id/request_for_comments
|
# GET /exercises/:id/request_for_comments
|
||||||
def rfcs_for_exercise
|
def rfcs_for_exercise
|
||||||
exercise = Exercise.find_by(id: params[:exercise_id])
|
exercise = Exercise.find(params[:exercise_id])
|
||||||
@search = RequestForComment
|
@search = RequestForComment
|
||||||
.with_last_activity
|
.with_last_activity
|
||||||
.where(exercise_id: exercise.id)
|
.where(exercise_id: exercise.id)
|
||||||
@ -141,7 +141,7 @@ class RequestForCommentsController < ApplicationController
|
|||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_request_for_comment
|
def set_request_for_comment
|
||||||
@request_for_comment = RequestForComment.find_by(id: params[:id])
|
@request_for_comment = RequestForComment.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def request_for_comment_params
|
def request_for_comment_params
|
||||||
@ -154,7 +154,7 @@ class RequestForCommentsController < ApplicationController
|
|||||||
# The index page requires the grouping of the study groups
|
# The index page requires the grouping of the study groups
|
||||||
# The study groups are grouped by the current study group and other study groups of the user
|
# The study groups are grouped by the current study group and other study groups of the user
|
||||||
def set_study_group_grouping
|
def set_study_group_grouping
|
||||||
current_study_group = StudyGroup.find_by(id: session[:study_group_id])
|
current_study_group = StudyGroup.find_by(session[:study_group_id])
|
||||||
my_study_groups = current_user.study_groups.reject {|group| group == current_study_group }
|
my_study_groups = current_user.study_groups.reject {|group| group == current_study_group }
|
||||||
@study_groups_grouping = [[t('request_for_comments.index.study_groups.current'), Array(current_study_group)],
|
@study_groups_grouping = [[t('request_for_comments.index.study_groups.current'), Array(current_study_group)],
|
||||||
[t('request_for_comments.index.study_groups.my'), my_study_groups]]
|
[t('request_for_comments.index.study_groups.my'), my_study_groups]]
|
||||||
|
@ -42,7 +42,7 @@ class SessionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy_through_lti
|
def destroy_through_lti
|
||||||
@submission = Submission.find_by(id: params[:submission_id])
|
@submission = Submission.find(params[:submission_id])
|
||||||
authorize(@submission, :show?)
|
authorize(@submission, :show?)
|
||||||
lti_parameter = LtiParameter.where(external_users_id: @submission.user_id, exercises_id: @submission.exercise_id).last
|
lti_parameter = LtiParameter.where(external_users_id: @submission.user_id, exercises_id: @submission.exercise_id).last
|
||||||
@url = consumer_return_url(build_tool_provider(consumer: @submission.user.consumer, parameters: lti_parameter&.lti_parameters))
|
@url = consumer_return_url(build_tool_provider(consumer: @submission.user.consumer, parameters: lti_parameter&.lti_parameters))
|
||||||
|
@ -23,7 +23,7 @@ class StudyGroupsController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
myparams = study_group_params
|
myparams = study_group_params
|
||||||
myparams[:external_users] =
|
myparams[:external_users] =
|
||||||
StudyGroupMembership.find_by(id: myparams[:study_group_membership_ids].compact_blank).map(&:user)
|
StudyGroupMembership.find(myparams[:study_group_membership_ids].compact_blank).map(&:user)
|
||||||
myparams.delete(:study_group_membership_ids)
|
myparams.delete(:study_group_membership_ids)
|
||||||
update_and_respond(object: @study_group, params: myparams)
|
update_and_respond(object: @study_group, params: myparams)
|
||||||
end
|
end
|
||||||
@ -38,7 +38,7 @@ class StudyGroupsController < ApplicationController
|
|||||||
private :study_group_params
|
private :study_group_params
|
||||||
|
|
||||||
def set_group
|
def set_group
|
||||||
@study_group = StudyGroup.find_by(id: params[:id])
|
@study_group = StudyGroup.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_group
|
private :set_group
|
||||||
|
@ -369,7 +369,7 @@ class SubmissionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_submission
|
def set_submission
|
||||||
@submission = Submission.find_by(id: params[:id])
|
@submission = Submission.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class SubscriptionsController < ApplicationController
|
|||||||
# DELETE /subscriptions/1
|
# DELETE /subscriptions/1
|
||||||
# DELETE /subscriptions/1.json
|
# DELETE /subscriptions/1.json
|
||||||
def destroy
|
def destroy
|
||||||
@subscription = Subscription.find_by(id: params[:id])
|
@subscription = Subscription.find(params[:id])
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
skip_authorization
|
skip_authorization
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@ -47,7 +47,7 @@ class SubscriptionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_subscription
|
def set_subscription
|
||||||
@subscription = Subscription.find_by(id: params[:id])
|
@subscription = Subscription.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_subscription
|
private :set_subscription
|
||||||
|
@ -38,7 +38,7 @@ class TagsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_tag
|
def set_tag
|
||||||
@tag = Tag.find_by(id: params[:id])
|
@tag = Tag.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_tag
|
private :set_tag
|
||||||
|
@ -44,7 +44,7 @@ class TipsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_tip
|
def set_tip
|
||||||
@tip = Tip.find_by(id: params[:id])
|
@tip = Tip.find(params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_tip
|
private :set_tip
|
||||||
|
@ -25,7 +25,7 @@ class UserExerciseFeedbacksController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
Sentry.set_extras(params: uef_params)
|
Sentry.set_extras(params: uef_params)
|
||||||
|
|
||||||
@exercise = Exercise.find_by(id: uef_params[:exercise_id])
|
@exercise = Exercise.find(uef_params[:exercise_id])
|
||||||
rfc = RequestForComment.unsolved.where(exercise_id: @exercise.id, user_id: current_user.id).first
|
rfc = RequestForComment.unsolved.where(exercise_id: @exercise.id, user_id: current_user.id).first
|
||||||
submission = begin
|
submission = begin
|
||||||
current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first
|
current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first
|
||||||
@ -67,7 +67,7 @@ class UserExerciseFeedbacksController < ApplicationController
|
|||||||
else
|
else
|
||||||
params[:user_exercise_feedback][:exercise_id]
|
params[:user_exercise_feedback][:exercise_id]
|
||||||
end
|
end
|
||||||
@exercise = Exercise.find_by(id: exercise_id)
|
@exercise = Exercise.find(exercise_id)
|
||||||
@uef = UserExerciseFeedback.find_or_initialize_by(user: current_user, exercise: @exercise)
|
@uef = UserExerciseFeedback.find_or_initialize_by(user: current_user, exercise: @exercise)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
@ -105,7 +105,7 @@ class UserExerciseFeedbacksController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_user_exercise_feedback
|
def set_user_exercise_feedback
|
||||||
@uef = UserExerciseFeedback.find_by(id: params[:id])
|
@uef = UserExerciseFeedback.find(params[:id])
|
||||||
@exercise = @uef.exercise
|
@exercise = @uef.exercise
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user