support seeding static pages

This commit is contained in:
Nick Kanel 2020-04-04 19:33:03 -04:00 committed by byte[]
parent 658472f16b
commit 19442633c6
2 changed files with 12 additions and 2 deletions

View file

@ -21,7 +21,8 @@ alias Philomena.{
Reports.Report, Reports.Report,
Roles.Role, Roles.Role,
Tags.Tag, Tags.Tag,
Users.User Users.User,
StaticPages.StaticPage
} }
alias Philomena.Elasticsearch alias Philomena.Elasticsearch
@ -88,6 +89,14 @@ for role_def <- resources["roles"] do
|> Repo.insert(on_conflict: :nothing) |> Repo.insert(on_conflict: :nothing)
end 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") IO.puts("---- Indexing content")
Elasticsearch.reindex(Tag |> preload(^Tags.indexing_preloads()), Tag) Elasticsearch.reindex(Tag |> preload(^Tags.indexing_preloads()), Tag)

View file

@ -91,5 +91,6 @@
{"name": "moderator", "resource_type": "Topic"}, {"name": "moderator", "resource_type": "Topic"},
{"name": "admin", "resource_type": "Advert"}, {"name": "admin", "resource_type": "Advert"},
{"name": "admin", "resource_type": "StaticPage"} {"name": "admin", "resource_type": "StaticPage"}
] ],
"pages": []
} }