respect user preference to be anonymous by default

This commit is contained in:
byte[] 2019-11-30 00:52:05 -05:00
parent 9572ad0f21
commit 4796d3d628
8 changed files with 30 additions and 7 deletions

View file

@ -26,5 +26,7 @@
.block__content.communication-edit__actions
=> submit "Post", class: "button"
= checkbox f, :anonymous
= label f, :anonymous, "Anonymous"
= if @conn.assigns.current_user do
= checkbox f, :anonymous, value: anonymous_by_default?(@conn)
= label f, :anonymous, "Anonymous"

View file

@ -85,7 +85,7 @@
= if @conn.assigns.current_user do
.field
= label f, :anonymous, "Post anonymously"
= checkbox f, :anonymous, class: "checkbox"
= checkbox f, :anonymous, class: "checkbox", value: anonymous_by_default?(@conn)
.actions
= submit "Upload", class: "button", autocomplete: "off", data: [disable_with: "Please wait..."]

View file

@ -24,9 +24,10 @@
= textarea fp, :body, class: "input input--wide input--text js-preview-input js-toolbar-input", placeholder: "Please read the site rules before posting and use [spoiler][/spoiler] for NSFW stuff in SFW forums.", required: true
= error_tag fp, :body
.field
=> checkbox f, :anonymous
= label f, :anonymous, "Post anonymously"
= if @conn.assigns.current_user do
.field
=> checkbox f, :anonymous, value: anonymous_by_default?(@conn)
= label f, :anonymous, "Post anonymously"
= inputs_for f, :poll, fn fp ->
#add-poll

View file

@ -25,4 +25,8 @@
' [Loading preview...]
.block__content.communication-edit__actions
= submit "Post", class: "button"
= submit "Post", class: "button"
= if @conn.assigns.current_user do
= checkbox f, :anonymous, value: anonymous_by_default?(@conn)
= label f, :anonymous, "Anonymous"

View file

@ -1,3 +1,7 @@
defmodule PhilomenaWeb.Image.CommentView do
use PhilomenaWeb, :view
def anonymous_by_default?(conn) do
conn.assigns.current_user.anonymous_by_default
end
end

View file

@ -83,6 +83,10 @@ defmodule PhilomenaWeb.ImageView do
def scope(conn), do: Philomena.ImageScope.scope(conn)
def anonymous_by_default?(conn) do
conn.assigns.current_user.anonymous_by_default
end
defp thumb_format("svg"), do: "png"
defp thumb_format(format), do: format
end

View file

@ -1,3 +1,7 @@
defmodule PhilomenaWeb.Topic.PostView do
use PhilomenaWeb, :view
def anonymous_by_default?(conn) do
conn.assigns.current_user.anonymous_by_default
end
end

View file

@ -1,3 +1,7 @@
defmodule PhilomenaWeb.TopicView do
use PhilomenaWeb, :view
def anonymous_by_default?(conn) do
conn.assigns.current_user.anonymous_by_default
end
end