[Git][noosfero/noosfero][master] 3 commits: Migration to article invalid in Suggest Article

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


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
c64ad49c by mendesiasmin at 2017-06-07T14:07:51-03:00
Migration to article invalid in Suggest Article

- - - - -
a3453a21 by mendesiasmin at 2017-06-27T17:34:25-03:00
Refactor migrate

- - - - -
341a8922 by Rodrigo Souto at 2017-06-29T12:50:37+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/compare/48db84b1d97f5537039f75bf136a956310094c89...341a89222210a633c44cdd14b286889930d55e58

---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/48db84b1d97f5537039f75bf136a956310094c89...341a89222210a633c44cdd14b286889930d55e58
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/f2b7ced8/attachment-0001.html>


More information about the Noosfero-dev mailing list