From 9cff91dcac4524d40cf10f36dcd2c0936b7ac81f Mon Sep 17 00:00:00 2001 From: Simon Williams Date: Mon, 28 Oct 2013 16:14:44 -0600 Subject: [PATCH] check .draft_state_enabled? on correct context in assignments api fixes CNVS-9059 test plan: - disable draft state in the console - turn on draft state in the account and course settings - create a new assignment - go to the course assignments page - click the cloud next to the assignment to publish - refresh the page, it should still be published Change-Id: Iddb633b4785a3343594bd64459aa245e991fb234 Reviewed-on: https://gerrit.instructure.com/25720 QA-Review: Matt Fairbourn Tested-by: Jenkins Reviewed-by: Cameron Sutter Product-Review: Simon Williams --- lib/api/v1/assignment.rb | 5 ++--- lib/api/v1/assignment_group.rb | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/api/v1/assignment.rb b/lib/api/v1/assignment.rb index 73868592250..b7654c062e8 100644 --- a/lib/api/v1/assignment.rb +++ b/lib/api/v1/assignment.rb @@ -167,8 +167,7 @@ module Api::V1::Assignment hash['module_ids'] = module_ids end - #show published/unpublished if account.settings[:enable_draft] - if @domain_root_account.enable_draft? + if assignment.context.draft_state_enabled? hash['published'] = ! assignment.unpublished? hash['unpublishable'] = !assignment.has_student_submissions? end @@ -324,7 +323,7 @@ module Api::V1::Assignment update_params["description"] = process_incoming_html_content(update_params["description"]) end - if @domain_root_account.enable_draft? + if assignment.context.draft_state_enabled? if assignment_params.has_key? "published" published = value_to_boolean(assignment_params['published']) assignment.workflow_state = published ? 'published' : 'unpublished' diff --git a/lib/api/v1/assignment_group.rb b/lib/api/v1/assignment_group.rb index a5baa81df56..6b6d1bc47d7 100644 --- a/lib/api/v1/assignment_group.rb +++ b/lib/api/v1/assignment_group.rb @@ -42,7 +42,7 @@ module Api::V1::AssignmentGroup # fake assignment used for checking if the @current_user can read unpublished assignments fake = group.context.assignments.new fake.workflow_state = 'unpublished' - if @domain_root_account.enable_draft? && !fake.grants_right?(user, session, :read) + if group.context.draft_state_enabled? && !fake.grants_right?(user, session, :read) # user should not see unpublished assignments assignment_scope = assignment_scope.published end