change how group sis csvs are detected
The group SIS CSV was being detected by an optional setting so this makes it check on only required headers. It also adds counts to the "report" shown on the sis page. Test Plan: * Import groups without the account_id header * It should be successful and show the count in the UI closes #5730 Change-Id: I9b8cc27be82499fbb7b8778eacab183fb77a5126 Reviewed-on: https://gerrit.instructure.com/8828 Reviewed-by: Cody Cutrer <cody@instructure.com> Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
parent
6a7a6f3ae2
commit
faaa2072af
|
@ -9,6 +9,8 @@
|
|||
<li><%= before_label(t(:users_label, "Users")) %> <%= counts[:users] %></li>
|
||||
<li><%= before_label(t(:enrollments_label, "Enrollments")) %> <%= counts[:enrollments] %></li>
|
||||
<li><%= before_label(t(:crosslists_label, "Crosslists")) %> <%= counts[:xlists] %></li>
|
||||
<li><%= before_label(t(:groups, "Groups")) %> <%= counts[:groups] %></li>
|
||||
<li><%= before_label(t(:group_enrollments, "Group Enrollments")) %> <%= counts[:group_memberships] %></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -23,7 +23,7 @@ module SIS
|
|||
# note these are account-level groups, not course groups
|
||||
class GroupImporter < BaseImporter
|
||||
def self.is_group_csv?(row)
|
||||
row.header?('group_id') && row.header?('account_id')
|
||||
row.header?('group_id') && row.header?('name')
|
||||
end
|
||||
|
||||
# expected columns
|
||||
|
|
|
@ -84,6 +84,8 @@ $(document).ready(function(event) {
|
|||
output += "<li>" + I18n.t('import_counts.users', "Users: %{user_count}", {user_count: batch.data.counts.users}) + "</li>";
|
||||
output += "<li>" + I18n.t('import_counts.enrollments', "Enrollments: %{enrollment_count}", {enrollment_count: batch.data.counts.enrollments}) + "</li>";
|
||||
output += "<li>" + I18n.t('import_counts.crosslists', "Crosslists: %{crosslist_count}", {crosslist_count: batch.data.counts.xlists}) + "</li>";
|
||||
output += "<li>" + I18n.t('import_counts.groups', "Groups: %{group_count}", {group_count: batch.data.counts.groups}) + "</li>";
|
||||
output += "<li>" + I18n.t('import_counts.group_enrollments', "Group Enrollments: %{group_enrollments_count}", {group_enrollments_count: batch.data.counts.group_memberships}) + "</li>";
|
||||
output += "</ul></li></ul>";
|
||||
|
||||
return output
|
||||
|
|
|
@ -59,6 +59,18 @@ describe SIS::CSV::GroupImporter do
|
|||
groups.map(&:workflow_state).should == %w(available deleted)
|
||||
end
|
||||
|
||||
it "should create groups with no account id column" do
|
||||
account_model
|
||||
process_csv_data_cleanly(
|
||||
"group_id,name,status",
|
||||
"G001,Group 1,available")
|
||||
groups = Group.all(:order => :id)
|
||||
groups.map(&:account_id).should == [@account.id]
|
||||
groups.map(&:sis_source_id).should == %w(G001)
|
||||
groups.map(&:name).should == ["Group 1"]
|
||||
groups.map(&:workflow_state).should == %w(available)
|
||||
end
|
||||
|
||||
it "should update group attributes" do
|
||||
@sub = @account.sub_accounts.create!(:name => 'sub')
|
||||
@sub.update_attribute('sis_source_id', 'A002')
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
#
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../views_helper')
|
||||
|
||||
describe "accounts/_sis_batch_counts.html.erb" do
|
||||
|
||||
it "should render sis count data" do
|
||||
data = {:counts => {:xlists => 2, :enrollments => 3, :courses => 5, :users => 6, :terms => 6, :group_memberships => 7, :groups => 8, :sections => 9, :accounts => 10}}
|
||||
report = mock()
|
||||
report.expects(:data).returns(data)
|
||||
render :partial => 'accounts/sis_batch_counts', :object => report
|
||||
|
||||
map = {:xlists => "Crosslists", :group_memberships => "Group Enrollments"}
|
||||
|
||||
data[:counts].each_pair do |type, count|
|
||||
name = map[type] || type.to_s.capitalize
|
||||
response.body.should =~ /#{name}: #{count}/
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue