-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
René Föhring
committed
Apr 8, 2018
1 parent
3fa2a2b
commit bc628db
Showing
14 changed files
with
279 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ erl_crash.dump | |
/config/logger.extension.exs | ||
.envrc | ||
.tool-versions-e | ||
lib/elixir_status_moderation.ex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
defmodule ElixirStatusModerationSample do | ||
def moderation_reasons(posting, author) do | ||
[ | ||
String.starts_with?(posting.title, "!!! ") && "Title starts with three exclamation marks" | ||
] | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
priv/repo/migrations/20180408074127_add_moderation_to_postings.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule ElixirStatus.Repo.Migrations.AddModerationToPostings do | ||
use Ecto.Migration | ||
|
||
def change do | ||
alter table(:postings) do | ||
add(:moderation_key, :string) | ||
add(:awaiting_moderation, :boolean, default: false) | ||
add(:metadata, :map) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<%= if @posting.metadata["moderated_at"] do %> | ||
<p> | ||
This post has already been moderated at <%= @posting.metadata["moderated_at"] |> human_readable_date(false) %>. | ||
</p> | ||
<% end %> | ||
<%= if @posting.metadata["marked_as_spam_at"] do %> | ||
<p> | ||
This post has been marked as spam and unpublished at <%= @posting.metadata["marked_as_spam_at"] |> human_readable_date(false) %>. | ||
</p> | ||
<% end %> | ||
|
||
<p> | ||
<%= link "Publish", to: posting_path(@conn, :moderate_publish, @posting.moderation_key), class: "btn", method: :post %> | ||
</p> | ||
<p> | ||
<%= link "Do not publish", to: posting_path(@conn, :moderate_mark_as_spam, @posting.moderation_key), class: "btn btn--danger", method: :post %> | ||
</p> | ||
|
||
<pre><%= inspect @posting.metadata["moderation_reasons"], pretty: true %></pre> | ||
|
||
|
||
<%= render ElixirStatus.PostingView, "posting.html", conn: @conn, | ||
posting: @posting, | ||
belongs_to_me?: false, | ||
just_created_by_me?: false | ||
%> | ||
|
||
<pre><%= inspect @posting, pretty: true %></pre> |
Oops, something went wrong.