Commit cf24a67713893f9738fdfb222bb7033181cb5e5d
1 parent
6d52e0cb
Exists in
master
and in
29 other branches
ActionItem1165: adding the possibility of only importing articles
Showing
4 changed files
with
19 additions
and
13 deletions
Show diff stats
script/group-import-cooperation.net
script/import-cooperation.net
... | ... | @@ -84,7 +84,7 @@ for username in ARGV |
84 | 84 | end |
85 | 85 | |
86 | 86 | profile = nil |
87 | - if SCRIPT_TYPE == 'group-import-cooperation.net' | |
87 | + if SCRIPT_TYPE == 'import-cooperation.net-groups' | |
88 | 88 | # import as a group |
89 | 89 | imported_data = Hash.from_xml(File.read(File.join(IMPORT_DIR, username + '.xml')))['person'] |
90 | 90 | profile = Community.create!( |
... | ... | @@ -95,6 +95,9 @@ for username in ARGV |
95 | 95 | :environment => environment, |
96 | 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 | 101 | else |
99 | 102 | # import as a user |
100 | 103 | |
... | ... | @@ -177,18 +180,20 @@ for username in ARGV |
177 | 180 | end |
178 | 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 | 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 | 197 | end |
193 | 198 | |
194 | 199 | end | ... | ... |