[Git][noosfero/noosfero][stable-1.8] Merge branch 'suggest_article_migrate' into 'master'

Rodrigo Souto gitlab at mg.gitlab.com
Thu Jun 29 09:51:51 BRT 2017


Rodrigo Souto pushed to branch stable-1.8 at Noosfero / noosfero


Commits:
31cd251e by Rodrigo Souto at 2017-06-29T12:51:11+00:00
Merge branch 'suggest_article_migrate' into 'master'

Migration to article invalid in Suggest Article

Closes #261

See merge request !1232
- - - - -


1 changed file:

- + db/migrate/20170607131552_update_suggest_article_data.rb


Changes:

=====================================
db/migrate/20170607131552_update_suggest_article_data.rb
=====================================
--- /dev/null
+++ b/db/migrate/20170607131552_update_suggest_article_data.rb
@@ -0,0 +1,23 @@
+class UpdateSuggestArticleData < ActiveRecord::Migration
+  def change
+    say_with_time "Updating suggest article datas..." do
+      SuggestArticle.pending.find_each do |suggest_article|
+          if suggest_article.data[:article_body].present?
+            article = {name: suggest_article.data[:article_name],
+                        source_name: suggest_article.data[:source_name],
+                        source: suggest_article.data[:source],
+                        abstract: suggest_article.data[:article_abstract],
+                        body: suggest_article.data[:article_body]
+                      }
+            suggest_article.data[:article] = article
+
+            [:article_name, :source_name, :source, :article_abstract, :article_body].each do |key|
+              suggest_article.data.delete(key)
+            end
+
+            suggest_article.save!
+          end
+      end
+    end
+  end
+end



View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/31cd251ef57456159a3fc821242eae9a8eb1afb2

---
View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/31cd251ef57456159a3fc821242eae9a8eb1afb2
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170629/657d7fde/attachment.html>


More information about the Noosfero-dev mailing list