Class: ProjectImportController

Inherits:
ApplicationController show all
Defined in:
app/controllers/project_import_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#add_breadcrumb, #after_sign_in_path_for, #breadcrumbs, #new_session_path, #require_admin_user

Instance Method Details

#runObject



3
4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/project_import_controller.rb', line 3

def run
  if current_user.eligible_sysadmin?
    @results = ProjectImport.run_with_report(mediaflux_session: current_user.mediaflux_session).sort
    created_count = @results.count { |out| out.starts_with?("Created") }
    notice = "Created #{created_count} #{'project'.pluralize(created_count)}."
    flash[:notice] = notice
  else
    flash[:alert] = I18n.t(:access_denied)
    redirect_to dashboard_path
  end
end