Skip to content

Commit dcf3df4

Browse files
committed
move draft state under feature flag umbrella
fixes CNVS-9496 test plan: - draft state feature should show up in site admin feature flags, or root account feature flags when called as site admin - when site admin hits "allow" for the feature, it should appear in the root account administrator's settings in "Off" state - the root account admin should be able to "Allow" the setting which allows a sub-account or course to turn it on - when the feature is turned on via the Feature Settings tab or features API, draft state functionality should appear in the course wiki pages and elsewhere Change-Id: Id7403f2a8371b0a7bfebffbb8f29330fff5c94c5 Reviewed-on: https://gerrit.instructure.com/26308 Reviewed-by: Bracken Mosbacker <bracken@instructure.com> Product-Review: Bracken Mosbacker <bracken@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Nathan Rogowski <nathan@instructure.com>
1 parent 30b640b commit dcf3df4

76 files changed

Lines changed: 194 additions & 375 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ def get_wiki_page
10141014
@wiki.check_has_front_page
10151015

10161016
page_name = params[:wiki_page_id] || params[:id] || (params[:wiki_page] && params[:wiki_page][:title])
1017-
page_name ||= (@wiki.get_front_page_url || Wiki::DEFAULT_FRONT_PAGE_URL) unless @context.draft_state_enabled?
1017+
page_name ||= (@wiki.get_front_page_url || Wiki::DEFAULT_FRONT_PAGE_URL) unless @context.feature_enabled?(:draft_state)
10181018
if(params[:format] && !['json', 'html'].include?(params[:format]))
10191019
page_name += ".#{params[:format]}"
10201020
params[:format] = 'html'

app/controllers/assignments_api_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def index
324324
fake = @context.assignments.new
325325
fake.workflow_state = 'unpublished'
326326

327-
if @context.draft_state_enabled? && !fake.grants_right?(@current_user, session, :read)
327+
if @context.feature_enabled?(:draft_state) && !fake.grants_right?(@current_user, session, :read)
328328
# user should not see unpublished assignments
329329
@assignments = @assignments.published
330330
end
@@ -372,7 +372,7 @@ def show
372372
@assignment = @context.active_assignments.find(params[:id],
373373
:include => [:assignment_group, :rubric_association, :rubric])
374374

375-
if @context.draft_state_enabled? && !@assignment.grants_right?(@current_user, session, :read)
375+
if @context.feature_enabled?(:draft_state) && !@assignment.grants_right?(@current_user, session, :read)
376376
# user should not see unpublished assignments
377377
render_unauthorized_action
378378
return
@@ -517,7 +517,7 @@ def show
517517
# @returns Assignment
518518
def create
519519
@assignment = @context.assignments.build
520-
@assignment.workflow_state = 'unpublished' if @context.draft_state_enabled?
520+
@assignment.workflow_state = 'unpublished' if @context.feature_enabled?(:draft_state)
521521

522522
if authorized_action(@assignment, @current_user, :create)
523523
save_and_render_response

app/controllers/assignments_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AssignmentsController < ApplicationController
3232
before_filter :normalize_title_param, :only => [:new, :edit]
3333

3434
def index
35-
return old_index if @context == @current_user || !@context.draft_state_enabled?
35+
return old_index if @context == @current_user || !@context.feature_enabled?(:draft_state)
3636

3737
if authorized_action(@context, @current_user, :read)
3838
return unless tab_enabled?(@context.class::TAB_ASSIGNMENTS)
@@ -109,7 +109,7 @@ def show
109109
@assignment.ensure_assignment_group
110110
js_env({
111111
:ROOT_OUTCOME_GROUP => outcome_group_json(@context.root_outcome_group, @current_user, session),
112-
:DRAFT_STATE => @context.draft_state_enabled?,
112+
:DRAFT_STATE => @context.feature_enabled?(:draft_state),
113113
:COURSE_ID => @context.id,
114114
:ASSIGNMENT_ID => @assignment.id
115115
})
@@ -325,7 +325,7 @@ def create
325325

326326
def new
327327
@assignment ||= @context.assignments.new
328-
@assignment.workflow_state = 'unpublished' if @context.draft_state_enabled?
328+
@assignment.workflow_state = 'unpublished' if @context.feature_enabled?(:draft_state)
329329
add_crumb t :create_new_crumb, "Create new"
330330

331331
if params[:submission_types] == 'online_quiz'

app/controllers/context_module_items_api_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def create
291291
item_params[:url] = params[:module_item][:external_url]
292292

293293
if (@tag = @module.add_item(item_params)) && set_position && set_completion_requirement
294-
if @context.draft_state_enabled?
294+
if @context.feature_enabled?(:draft_state)
295295
@tag.workflow_state = 'unpublished'
296296
@tag.save
297297
end

app/controllers/context_modules_api_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def create
269269
if ids = params[:module][:prerequisite_module_ids]
270270
@module.prerequisites = ids.map{|id| "module_#{id}"}.join(',')
271271
end
272-
if @context.draft_state_enabled?
272+
if @context.feature_enabled?(:draft_state)
273273
@module.workflow_state = 'unpublished'
274274
else
275275
@module.workflow_state = 'active'

app/controllers/context_modules_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def reevaluate_modules_if_locked(tag)
8787
def create
8888
if authorized_action(@context.context_modules.new, @current_user, :create)
8989
@module = @context.context_modules.build
90-
if @context.draft_state_enabled?
90+
if @context.feature_enabled?(:draft_state)
9191
@module.workflow_state = 'unpublished'
9292
else
9393
@module.workflow_state = 'active'
@@ -375,7 +375,7 @@ def progressions
375375
@progressions = @context.context_modules.active.map{|m| m.evaluate_for(@current_user, true) }
376376
render :json => @progressions
377377
end
378-
elsif !@context.draft_state_enabled?
378+
elsif !@context.feature_enabled?(:draft_state)
379379
redirect_to named_context_url(@context, :context_context_modules_url, :anchor => "student_progressions")
380380
elsif !@context.grants_right?(@current_user, session, :manage_students)
381381
@restrict_student_list = true

app/controllers/courses_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ def show
11121112

11131113

11141114
@context = Course.active.find(params[:id])
1115-
js_env :DRAFT_STATE => @context.draft_state_enabled?
1115+
js_env :DRAFT_STATE => @context.feature_enabled?(:draft_state)
11161116
if request.xhr?
11171117
if authorized_action(@context, @current_user, [:read, :read_as_admin])
11181118
render :json => @context
@@ -1161,7 +1161,7 @@ def show
11611161
when "wiki"
11621162
@wiki = @context.wiki
11631163
@page = @wiki.front_page
1164-
if @context.draft_state_enabled?
1164+
if @context.feature_enabled?(:draft_state)
11651165
set_js_rights [:wiki, :page]
11661166
set_js_wiki_data :course_home => true
11671167
@padless = true

app/controllers/discussion_topics_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def index
228228
create: @context.discussion_topics.new.grants_right?(@current_user, session, :create),
229229
moderate: user_can_moderate,
230230
change_settings: user_can_edit_course_settings?,
231-
publish: user_can_moderate && @domain_root_account.enable_draft?
231+
publish: user_can_moderate && @domain_root_account.feature_enabled?(:draft_state)
232232
}}
233233
append_sis_data(hash)
234234

app/controllers/gradebook2_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def show
2626
:course_is_concluded => @context.completed?,
2727
:gradebook_is_editable => @gradebook_is_editable,
2828
:speed_grader_enabled => @context.allows_speed_grader?,
29-
:draft_state_enabled => @context.draft_state_enabled?
29+
:draft_state_enabled => @context.feature_enabled?(:draft_state)
3030
}
3131
end
3232
end

app/controllers/gradebooks_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def show
182182
newest = Time.parse("Jan 1 2010")
183183
@just_assignments = @just_assignments.sort_by{|a| [a.due_at || newest, @groups_order[a.assignment_group_id] || 0, a.position || 0] }
184184
@assignments = @just_assignments.dup + groups_as_assignments(@groups)
185-
if @context.draft_state_enabled?
185+
if @context.feature_enabled?(:draft_state)
186186
@assignments = @assignments.select(&:published?)
187187
end
188188
@submissions = @context.submissions
@@ -374,7 +374,7 @@ def speed_grader
374374
return unless authorized_action(@context, @current_user, [:manage_grades, :view_all_grades])
375375

376376
@assignment = @context.assignments.active.find(params[:assignment_id])
377-
if @context.draft_state_enabled? && @assignment.unpublished?
377+
if @context.feature_enabled?(:draft_state) && @assignment.unpublished?
378378
flash[:notice] = t(:speedgrader_enabled_only_for_published_content,
379379
'Speedgrader is enabled only for published content.')
380380
return redirect_to polymorphic_url([@context, @assignment])

0 commit comments

Comments
 (0)