gradebook uploads display error when no file is given
Fixes CNVS-21851 Test Plan: 1. Go to a Gradebook Uploads page (/courses/:id/gradebook_uploads/new) 2. Click the upload button. 3. Verify that an error message is displayed and the user is redirected to the Gradebook Uploads page. Change-Id: I78cfc149243d4bd169c095807cf36df3a3616ce2 Reviewed-on: https://gerrit.instructure.com/58293 Tested-by: Jenkins Reviewed-by: Derek Bender <dbender@instructure.com> QA-Review: Jason Carter <jcarter@instructure.com> Product-Review: Strand McCutchen <smccutchen@instructure.com>
This commit is contained in:
parent
97bf6daaf5
commit
41d1536193
|
@ -22,19 +22,12 @@ class GradebookUploadsController < ApplicationController
|
|||
|
||||
before_filter :require_context
|
||||
|
||||
def gradebook_upload
|
||||
GradebookUpload.where(
|
||||
course_id: @context,
|
||||
user_id: @current_user
|
||||
).first
|
||||
end
|
||||
|
||||
def new
|
||||
if authorized_action(@context, @current_user, :manage_grades)
|
||||
|
||||
# GradebookUpload is a singleton. If there is
|
||||
# already an instance we'll redirect to it or kill it
|
||||
if previous_upload = gradebook_upload
|
||||
previous_upload = gradebook_upload
|
||||
if previous_upload
|
||||
if previous_upload.stale?
|
||||
previous_upload.destroy
|
||||
elsif previous_upload
|
||||
|
@ -48,7 +41,6 @@ class GradebookUploadsController < ApplicationController
|
|||
|
||||
def show
|
||||
if authorized_action(@context, @current_user, :manage_grades)
|
||||
|
||||
upload = gradebook_upload
|
||||
unless upload
|
||||
redirect_to new_course_gradebook_upload_path(@context)
|
||||
|
@ -62,10 +54,16 @@ class GradebookUploadsController < ApplicationController
|
|||
|
||||
def create
|
||||
if authorized_action(@context, @current_user, :manage_grades)
|
||||
attachment = params[:gradebook_upload][:uploaded_data]
|
||||
@progress = GradebookUpload.queue_from(@context, @current_user, attachment.read)
|
||||
js_env gradebook_env(@progress)
|
||||
render :show
|
||||
if params[:gradebook_upload]
|
||||
attachment = params[:gradebook_upload][:uploaded_data]
|
||||
@progress = GradebookUpload.queue_from(@context, @current_user, attachment.read)
|
||||
js_env gradebook_env(@progress)
|
||||
render :show
|
||||
else
|
||||
flash[:error] = t(:no_file_attached, "We did not detect a CSV to "\
|
||||
"upload. Please select a CSV to upload and submit again.")
|
||||
redirect_to action: :new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -79,6 +77,7 @@ class GradebookUploadsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
def gradebook_env(progress)
|
||||
{
|
||||
progress: progress_json(progress, @current_user, session),
|
||||
|
@ -89,4 +88,11 @@ class GradebookUploadsController < ApplicationController
|
|||
new_gradebook_upload_path: new_course_gradebook_upload_path(@context),
|
||||
}
|
||||
end
|
||||
|
||||
def gradebook_upload
|
||||
GradebookUpload.where(
|
||||
course_id: @context,
|
||||
user_id: @current_user
|
||||
).first
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue