Permalink
Browse files

Added task to generate a top-level org

  • Loading branch information...
1 parent e0ea5d1 commit a5a818af651e85ae45d0b234ba1059238aa7237d @cthielen cthielen committed Feb 27, 2014
Showing with 22 additions and 1 deletion.
  1. +1 −1 config/initializers/last_updated.rb
  2. +21 −0 lib/tasks/organization_tasks.rake
@@ -1 +1 @@
-LAST_UPDATED = 'Wed Feb 26 17:16:44 PST 2014'
+LAST_UPDATED = 'Wed Feb 26 18:30:00 PST 2014'
@@ -257,6 +257,27 @@ namespace :organization do
puts "#{organization.name} (#{organization.parent_organizations.length})" if organization.parent_organizations.length > 1
end
end
+
+ desc 'Adds a top-level node containing all the parentless-nodes'
+ task :add_top_level_node => :environment do
+ Authorization.ignore_access_control(true)
+
+ orphaned_organizations = []
+
+ Organization.all.each do |organization|
+ orphaned_organizations << organization if organization.parent_organizations.length == 0
+ end
+
+ top_level = Organization.create!({name: "UC Davis"})
+
+ puts "Found #{orphaned_organizations.length} organizations:"
+ orphaned_organizations.each do |org|
+ puts "\t#{org.name}"
+ top_level.child_organizations << org
+ end
+
+ Authorization.ignore_access_control(false)
+ end
desc 'List any organizations who have a parent which is also a grandparent'
task :list_dubious_parentage, [:options] => :environment do |t, args|

0 comments on commit a5a818a

Please sign in to comment.