Merge branch 'bug_fixes'

This commit is contained in:
Sebastian Serth
2020-10-28 16:46:41 +01:00
14 changed files with 24 additions and 31 deletions

View File

@ -13,7 +13,7 @@ class ApplicationController < ActionController::Base
def current_user
::NewRelic::Agent.add_custom_attributes(external_user_id: session[:external_user_id], session_user_id: session[:user_id])
@current_user ||= ExternalUser.find_by(id: session[:external_user_id]) || login_from_session || login_from_other_sources
@current_user ||= ExternalUser.find_by(id: session[:external_user_id]) || login_from_session || login_from_other_sources || nil
end
def require_user!

View File

@ -88,7 +88,7 @@ module SubmissionScoring
# Return all test results except for those of a linter if not allowed
show_linter = Python20CourseWeek.show_linter? submission.exercise, submission.user_id
outputs&.reject do |output|
next if show_linter
next if show_linter || output.blank?
output[:file_role] == 'teacher_defined_linter'
end

View File

@ -2,7 +2,7 @@ class RequestForCommentsController < ApplicationController
include SubmissionScoring
before_action :set_request_for_comment, only: [:show, :edit, :update, :destroy, :mark_as_solved, :set_thank_you_note]
skip_after_action :verify_authorized
before_action :require_user!
def authorize!
authorize(@request_for_comments || @request_for_comment)
@ -26,11 +26,12 @@ class RequestForCommentsController < ApplicationController
def get_my_comment_requests
@search = RequestForComment
.with_last_activity
.where(user_id: current_user.id)
.where(user_id: current_user&.id)
.ransack(params[:q])
@request_for_comments = @search.result
.order('created_at DESC')
.paginate(page: params[:page])
authorize!
render 'index'
end
@ -44,6 +45,7 @@ class RequestForCommentsController < ApplicationController
@request_for_comments = @search.result
.order('last_comment DESC')
.paginate(page: params[:page])
authorize!
render 'index'
end
@ -83,10 +85,6 @@ class RequestForCommentsController < ApplicationController
authorize!
end
# GET /request_for_comments/1/edit
def edit
end
# POST /request_for_comments.json
def create
# Consider all requests as JSON
@ -111,17 +109,6 @@ class RequestForCommentsController < ApplicationController
authorize!
end
# DELETE /request_for_comments/1
# DELETE /request_for_comments/1.json
def destroy
@request_for_comment.destroy
respond_to do |format|
format.html { redirect_to request_for_comments_url, notice: 'Request for comment was successfully destroyed.' }
format.json { head :no_content }
end
authorize!
end
private
# Use callbacks to share common setup or constraints between actions.
def set_request_for_comment

View File

@ -30,7 +30,7 @@ class SessionsController < ApplicationController
end
def destroy
if current_user.external_user?
if current_user&.external_user?
clear_lti_session_data
else
logout

View File

@ -8,8 +8,8 @@ class SubmissionsController < ApplicationController
before_action :set_submission, only: [:download, :download_file, :render_file, :run, :score, :extract_errors, :show, :statistics, :stop, :test]
before_action :set_docker_client, only: [:run, :test]
before_action :set_files, only: [:download, :download_file, :render_file, :show]
before_action :set_file, only: [:download_file, :render_file]
before_action :set_files, only: [:download, :download_file, :render_file, :show, :run]
before_action :set_file, only: [:download_file, :render_file, :run]
before_action :set_mime_type, only: [:download_file, :render_file]
skip_before_action :verify_authenticity_token, only: [:download_file, :render_file]

View File

@ -20,6 +20,8 @@ class UserExerciseFeedbacksController < ApplicationController
end
def create
Raven.extra_context(params: uef_params)
@exercise = Exercise.find(uef_params[:exercise_id])
rfc = RequestForComment.unsolved.where(exercise_id: @exercise.id, user_id: current_user.id).first
submission = current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first rescue nil