Commit 2efdf80b19f665654a09ee86a6974034464d7ce4
Exists in
staging
and in
2 other branches
Merge branch 'production' into staging
Conflicts: Gemfile.lock db/schema.rb plugins/community_hub
Showing
1 changed file
with
37 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +#!/usr/bin/env ruby | ||
2 | +require File.dirname(__FILE__) + '/../config/environment' | ||
3 | +require 'csv' | ||
4 | + | ||
5 | +author = User.find_by_email('3confjuvetapanacional@gmail.com').person | ||
6 | +#discussion = ProposalsDiscussionPlugin::Discussion.first | ||
7 | +topic = nil | ||
8 | + | ||
9 | +count = 0 | ||
10 | +filepath = File.dirname(__FILE__) + '/../tmp/propostas.csv' | ||
11 | +CSV.foreach(filepath, {:col_sep => ';', :force_quotes => true}) do |row| | ||
12 | + count += 1 | ||
13 | + puts row.inspect | ||
14 | + topic_name, proposal_body = row | ||
15 | + next if proposal_body.nil? | ||
16 | + topic_name = topic_name.chomp | ||
17 | + proposal_body = proposal_body.chomp | ||
18 | +puts count.inspect | ||
19 | +puts topic_name.inspect | ||
20 | +puts proposal_body.inspect | ||
21 | + topic = ProposalsDiscussionPlugin::Topic.find_by_slug(topic_name) if topic.nil? || topic.name != topic_name | ||
22 | + | ||
23 | +puts topic.inspect | ||
24 | + | ||
25 | + proposal = ProposalsDiscussionPlugin::Proposal.new | ||
26 | + proposal.author = author | ||
27 | + proposal.topic = topic | ||
28 | + proposal.abstract = proposal_body | ||
29 | +# proposal.name = count.to_s + ' - ' + proposal_body[0..36].titleize | ||
30 | + proposal.name = proposal_body[0..37].titleize + '...' | ||
31 | + proposal.profile = topic.profile | ||
32 | + proposal.save! | ||
33 | + | ||
34 | +puts proposal.inspect | ||
35 | +end | ||
36 | + | ||
37 | + |