use DisucssionTopic::ScopedToUser in CC::TopicResources#add_topics

fixes CNVS-21394

The content export tool is being updated so that it consders the
provided user's rights, so that the CC export can be used for the new
epub generation tool.

This PS employs DiscussionTopic::ScopedToUser to make sure that the user
only gets the discussion topics that they have the right to view.

test plan:
- Regression test for content export tool discussion topic functionality.

Change-Id: Id67bf1ed69c4b2066ff9d81678a5d61d52702978
Reviewed-on: https://gerrit.instructure.com/59365
Tested-by: Jenkins
Reviewed-by: Brian Finney <bfinney@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Cameron Sutter <csutter@instructure.com>
This commit is contained in:
John Corrigan 2015-07-27 17:40:37 -05:00
parent 8f329ed9a2
commit 9a3a560539
1 changed files with 4 additions and 3 deletions

View File

@ -17,16 +17,17 @@
#
module CC
module TopicResources
def add_topics
@course.discussion_topics.active.each do |topic|
scope = @course.discussion_topics.active
DiscussionTopic::ScopedToUser.new(@course, @user, scope).scope.each do |topic|
if topic.is_announcement
next unless export_object?(topic, 'announcements')
else
next unless export_object?(topic) || export_object?(topic.assignment)
end
title = topic.title rescue I18n.t('course_exports.unknown_titles.topic', "Unknown topic")
title = topic.title || I18n.t('course_exports.unknown_titles.topic', "Unknown topic")
if topic.assignment && !topic.assignment.can_copy?(@user)
add_error(I18n.t('course_exports.errors.topic_is_locked', "The topic \"%{title}\" could not be copied because it is locked.", :title => title))