mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
mix format
This commit is contained in:
parent
8ef94e912b
commit
a36e2d7368
7 changed files with 39 additions and 7 deletions
|
@ -16,7 +16,12 @@ defmodule PhilomenaWeb.Image.CommentController do
|
||||||
edit: :create_comment,
|
edit: :create_comment,
|
||||||
update: :create_comment
|
update: :create_comment
|
||||||
|
|
||||||
plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true, preload: [:tags]
|
plug :load_and_authorize_resource,
|
||||||
|
model: Image,
|
||||||
|
id_name: "image_id",
|
||||||
|
persisted: true,
|
||||||
|
preload: [:tags]
|
||||||
|
|
||||||
plug :verify_authorized when action in [:show]
|
plug :verify_authorized when action in [:show]
|
||||||
plug PhilomenaWeb.FilterForcedUsersPlug when action in [:create, :edit, :update]
|
plug PhilomenaWeb.FilterForcedUsersPlug when action in [:create, :edit, :update]
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,13 @@ defmodule PhilomenaWeb.Image.FaveController do
|
||||||
|
|
||||||
plug PhilomenaWeb.FilterBannedUsersPlug
|
plug PhilomenaWeb.FilterBannedUsersPlug
|
||||||
plug PhilomenaWeb.CanaryMapPlug, create: :vote, delete: :vote
|
plug PhilomenaWeb.CanaryMapPlug, create: :vote, delete: :vote
|
||||||
plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true, preload: [:tags]
|
|
||||||
|
plug :load_and_authorize_resource,
|
||||||
|
model: Image,
|
||||||
|
id_name: "image_id",
|
||||||
|
persisted: true,
|
||||||
|
preload: [:tags]
|
||||||
|
|
||||||
plug PhilomenaWeb.FilterForcedUsersPlug
|
plug PhilomenaWeb.FilterForcedUsersPlug
|
||||||
|
|
||||||
def create(conn, _params) do
|
def create(conn, _params) do
|
||||||
|
|
|
@ -8,7 +8,13 @@ defmodule PhilomenaWeb.Image.VoteController do
|
||||||
|
|
||||||
plug PhilomenaWeb.FilterBannedUsersPlug
|
plug PhilomenaWeb.FilterBannedUsersPlug
|
||||||
plug PhilomenaWeb.CanaryMapPlug, create: :vote, delete: :vote
|
plug PhilomenaWeb.CanaryMapPlug, create: :vote, delete: :vote
|
||||||
plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true, preload: [:tags]
|
|
||||||
|
plug :load_and_authorize_resource,
|
||||||
|
model: Image,
|
||||||
|
id_name: "image_id",
|
||||||
|
persisted: true,
|
||||||
|
preload: [:tags]
|
||||||
|
|
||||||
plug PhilomenaWeb.FilterForcedUsersPlug
|
plug PhilomenaWeb.FilterForcedUsersPlug
|
||||||
|
|
||||||
def create(conn, params) do
|
def create(conn, params) do
|
||||||
|
|
|
@ -22,8 +22,17 @@ defmodule PhilomenaWeb.StaffController do
|
||||||
"Public Relations":
|
"Public Relations":
|
||||||
Enum.filter(users, &(&1.role != "admin" and &1.secondary_role == "Public Relations")),
|
Enum.filter(users, &(&1.role != "admin" and &1.secondary_role == "Public Relations")),
|
||||||
Moderators:
|
Moderators:
|
||||||
Enum.filter(users, &(&1.role == "moderator" and &1.secondary_role in [nil, ""] and &1.hide_default_role == false)),
|
Enum.filter(
|
||||||
Assistants: Enum.filter(users, &(&1.role == "assistant" and &1.secondary_role in [nil, ""] and &1.hide_default_role == false))
|
users,
|
||||||
|
&(&1.role == "moderator" and &1.secondary_role in [nil, ""] and
|
||||||
|
&1.hide_default_role == false)
|
||||||
|
),
|
||||||
|
Assistants:
|
||||||
|
Enum.filter(
|
||||||
|
users,
|
||||||
|
&(&1.role == "assistant" and &1.secondary_role in [nil, ""] and
|
||||||
|
&1.hide_default_role == false)
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
render(conn, "index.html", title: "Site Staff", categories: categories)
|
render(conn, "index.html", title: "Site Staff", categories: categories)
|
||||||
|
|
|
@ -20,11 +20,13 @@ defmodule PhilomenaWeb.FilterForcedUsersPlug do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_fetch_forced(conn, nil), do: conn
|
defp maybe_fetch_forced(conn, nil), do: conn
|
||||||
|
|
||||||
defp maybe_fetch_forced(conn, forced) do
|
defp maybe_fetch_forced(conn, forced) do
|
||||||
maybe_halt(conn, matches_filter?(conn.assigns.current_user, conn.assigns.image, forced))
|
maybe_halt(conn, matches_filter?(conn.assigns.current_user, conn.assigns.image, forced))
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_halt(conn, false), do: conn
|
defp maybe_halt(conn, false), do: conn
|
||||||
|
|
||||||
defp maybe_halt(conn, true) do
|
defp maybe_halt(conn, true) do
|
||||||
conn
|
conn
|
||||||
|> put_flash(:error, "You have been blocked from performing this action on this image.")
|
|> put_flash(:error, "You have been blocked from performing this action on this image.")
|
||||||
|
|
|
@ -16,6 +16,7 @@ defmodule PhilomenaWeb.ImageFilterPlug do
|
||||||
|
|
||||||
tag_exclusion = %{terms: %{tag_ids: filter.hidden_tag_ids ++ forced.hidden_tag_ids}}
|
tag_exclusion = %{terms: %{tag_ids: filter.hidden_tag_ids ++ forced.hidden_tag_ids}}
|
||||||
query_spoiler = invalid_filter_guard(user, filter.spoilered_complex_str)
|
query_spoiler = invalid_filter_guard(user, filter.spoilered_complex_str)
|
||||||
|
|
||||||
query_exclusion = %{
|
query_exclusion = %{
|
||||||
bool: %{
|
bool: %{
|
||||||
should: [
|
should: [
|
||||||
|
|
|
@ -366,7 +366,10 @@ defmodule PhilomenaWeb.Router do
|
||||||
resources "/downvotes", User.DownvoteController, only: [:delete], singleton: true
|
resources "/downvotes", User.DownvoteController, only: [:delete], singleton: true
|
||||||
resources "/votes", User.VoteController, only: [:delete], singleton: true
|
resources "/votes", User.VoteController, only: [:delete], singleton: true
|
||||||
resources "/wipe", User.WipeController, only: [:create], singleton: true
|
resources "/wipe", User.WipeController, only: [:create], singleton: true
|
||||||
resources "/force_filter", User.ForceFilterController, only: [:new, :create, :delete], singleton: true
|
|
||||||
|
resources "/force_filter", User.ForceFilterController,
|
||||||
|
only: [:new, :create, :delete],
|
||||||
|
singleton: true
|
||||||
end
|
end
|
||||||
|
|
||||||
resources "/batch/tags", Batch.TagController, only: [:update], singleton: true
|
resources "/batch/tags", Batch.TagController, only: [:update], singleton: true
|
||||||
|
|
Loading…
Reference in a new issue