canvas-lms/lib/eportfolio_page.rb

48 lines
1.8 KiB
Ruby

#
# Copyright (C) 2011 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
module EportfolioPage
def eportfolio_page_attributes
@portfolio.setup_defaults
@categories = @portfolio.eportfolio_categories
if @portfolio.grants_rights?(@current_user, session, :manage)[:manage]
@recent_submissions = @current_user.submissions.find(:all, :order => 'created_at DESC') if @current_user && @current_user == @portfolio.user
@files = @current_user.attachments.to_a
@folders = @current_user.active_folders_detailed.to_a
end
@recent_submissions ||= []
@files ||= []
@folders ||= []
@attachments = []
@page.content_sections.each do |section|
attachment = @portfolio.user.attachments.find_by_uuid(section["attachment_id"]) rescue nil
@attachments << attachment if attachment
end
@entries = @category.eportfolio_entries
@eportfolio_view = true
@show_left_side = true
add_crumb(@portfolio.name, eportfolio_path(@portfolio))
if @owner_view
add_crumb("Welcome to Your ePortfolio")
else
add_crumb(@category.name, eportfolio_named_category_path(@portfolio.id, @category.slug))
add_crumb(@page.name, eportfolio_named_category_entry_path(@portfolio.id, @category.slug, @page.slug))
end
end
end