break SIS error/count reports into partials, fixes #3889

Change-Id: I2811b01392c2320654e237f1840b918bc58dedc6
Reviewed-on: https://gerrit.instructure.com/2412
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
This commit is contained in:
Brian Palmer 2011-02-23 14:05:43 -07:00
parent 16eecfd4dc
commit 9b627b0e6e
3 changed files with 36 additions and 32 deletions

View File

@ -23,41 +23,11 @@ module AccountsHelper
def print_messages(batch)
return '' unless batch
output = "<ul>"
if batch.processing_errors && batch.processing_errors.length > 0
output += "<li>Errors that prevent importing\n<ul>"
batch.processing_errors.each do |message|
output += "<li>#{message.first} - #{message.last}</li>"
end
output += "</ul>\n</li>"
end
if batch.processing_warnings && batch.processing_warnings.length > 0
output += "<li>Warnings\n<ul>"
batch.processing_warnings.each do |message|
output += "<li>#{message.first} - #{message.last}</li>"
end
output += "</ul>\n</li>"
end
output += "</ul>"
output
render :partial => 'accounts/sis_batch_messages', :object => batch
end
def print_counts(batch)
return '' unless batch.data && batch.data[:counts]
counts = batch.data[:counts]
<<-EOF
<ul>
<li>Imported Items
<ul>
<li>Accounts: #{counts[:accounts]}</li>
<li>Terms: #{counts[:terms]}</li>
<li>Courses: #{counts[:courses]}</li>
<li>Sections: #{counts[:sections]}</li>
<li>Users: #{counts[:users]}</li>
<li>Enrollments: #{counts[:enrollments]}</li>
</ul>
</li>
</ul>
EOF
render :partial => 'accounts/sis_batch_counts', :object => batch
end
end

View File

@ -0,0 +1,13 @@
<% counts = sis_batch_counts.data[:counts] %>
<ul>
<li>Imported Items
<ul>
<li>Accounts: <%= counts[:accounts] %></li>
<li>Terms: <%= counts[:terms] %></li>
<li>Courses: <%= counts[:courses] %></li>
<li>Sections: <%= counts[:sections] %></li>
<li>Users: <%= counts[:users] %></li>
<li>Enrollments: <%= counts[:enrollments] %></li>
</ul>
</li>
</ul>

View File

@ -0,0 +1,21 @@
<% batch = sis_batch_messages %>
<ul>
<% if batch.processing_errors && batch.processing_errors.length > 0 %>
<li>Errors that prevent importing
<ul>
<% batch.processing_errors.each do |message| %>
<li><%= message.first %> - <%= message.last %></li>
<% end %>
</ul>
</li>
<% end %>
<% if batch.processing_warnings && batch.processing_warnings.length > 0 %>
<li>Warnings
<ul>
<% batch.processing_warnings.each do |message| %>
<li><%= message.first %> - <%= message.last %></li>
<% end %>
</ul>
</li>
<% end %>
</ul>