From 19442633c676dff5337906a363afa3d9f8ee5aea Mon Sep 17 00:00:00 2001 From: Nick Kanel Date: Sat, 4 Apr 2020 19:33:03 -0400 Subject: [PATCH] support seeding static pages --- priv/repo/seeds.exs | 11 ++++++++++- priv/repo/seeds.json | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/priv/repo/seeds.exs b/priv/repo/seeds.exs index 25584b8b..13ebd626 100644 --- a/priv/repo/seeds.exs +++ b/priv/repo/seeds.exs @@ -21,7 +21,8 @@ alias Philomena.{ Reports.Report, Roles.Role, Tags.Tag, - Users.User + Users.User, + StaticPages.StaticPage } alias Philomena.Elasticsearch @@ -88,6 +89,14 @@ for role_def <- resources["roles"] do |> Repo.insert(on_conflict: :nothing) end +IO.puts("---- Generating static pages") + +for page_def <- resources["pages"] do + %StaticPage{title: page_def["title"], slug: page_def["slug"], body: page_def["body"]} + |> StaticPage.changeset(%{}) + |> Repo.insert(on_conflict: :nothing) +end + IO.puts("---- Indexing content") Elasticsearch.reindex(Tag |> preload(^Tags.indexing_preloads()), Tag) diff --git a/priv/repo/seeds.json b/priv/repo/seeds.json index a0bcdfd6..ac40820d 100644 --- a/priv/repo/seeds.json +++ b/priv/repo/seeds.json @@ -91,5 +91,6 @@ {"name": "moderator", "resource_type": "Topic"}, {"name": "admin", "resource_type": "Advert"}, {"name": "admin", "resource_type": "StaticPage"} - ] + ], + "pages": [] }