Commit cf24a67713893f9738fdfb222bb7033181cb5e5d

Authored by Antonio Terceiro
1 parent 6d52e0cb

ActionItem1165: adding the possibility of only importing articles

script/group-import-cooperation.net
@@ -1 +0,0 @@ @@ -1 +0,0 @@
1 -import-cooperation.net  
2 \ No newline at end of file 0 \ No newline at end of file
script/import-cooperation.net
@@ -84,7 +84,7 @@ for username in ARGV @@ -84,7 +84,7 @@ for username in ARGV
84 end 84 end
85 85
86 profile = nil 86 profile = nil
87 - if SCRIPT_TYPE == 'group-import-cooperation.net' 87 + if SCRIPT_TYPE == 'import-cooperation.net-groups'
88 # import as a group 88 # import as a group
89 imported_data = Hash.from_xml(File.read(File.join(IMPORT_DIR, username + '.xml')))['person'] 89 imported_data = Hash.from_xml(File.read(File.join(IMPORT_DIR, username + '.xml')))['person']
90 profile = Community.create!( 90 profile = Community.create!(
@@ -95,6 +95,9 @@ for username in ARGV @@ -95,6 +95,9 @@ for username in ARGV
95 :environment => environment, 95 :environment => environment,
96 :preferred_domain_id => get_domain(domain_name).id 96 :preferred_domain_id => get_domain(domain_name).id
97 ) 97 )
  98 + elsif SCRIPT_TYPE == 'import-cooperation.net-articles'
  99 + # only load the articles
  100 + profile = Profile[login]
98 else 101 else
99 # import as a user 102 # import as a user
100 103
@@ -177,18 +180,20 @@ for username in ARGV @@ -177,18 +180,20 @@ for username in ARGV
177 end 180 end
178 end 181 end
179 182
180 - # import menus  
181 - for i in [1,2]  
182 - links = []  
183 - data = Hash.from_xml(File.read(File.join(IMPORT_DIR, username, "menu#{i}.xml")))  
184 - data['menu']['items'].each do |item|  
185 - links << { :name => item['title'], :address => item['url'] } 183 + if SCRIPT_TYPE != 'import-cooperation.net-articles'
  184 + # import menus
  185 + for i in [1,2]
  186 + links = []
  187 + data = Hash.from_xml(File.read(File.join(IMPORT_DIR, username, "menu#{i}.xml")))
  188 + data['menu']['items'].each do |item|
  189 + links << { :name => item['title'], :address => item['url'] }
  190 + end
  191 + block = profile.blocks.select { |block| block.class == LinkListBlock }[i-1]
  192 + block.title = data['menu']['title']
  193 + block.links = links
  194 + block.save!
  195 + Progress.say "imported links: #{links.inspect}"
186 end 196 end
187 - block = profile.blocks.select { |block| block.class == LinkListBlock }[i-1]  
188 - block.title = data['menu']['title']  
189 - block.links = links  
190 - block.save!  
191 - Progress.say "imported links: #{links.inspect}"  
192 end 197 end
193 198
194 end 199 end
script/import-cooperation.net-articles 0 → 120000
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +import-cooperation.net
0 \ No newline at end of file 2 \ No newline at end of file
script/import-cooperation.net-groups 0 → 120000
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +import-cooperation.net
0 \ No newline at end of file 2 \ No newline at end of file