mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
Make forced filters visible to affected users if used
This commit is contained in:
parent
ef55b8c4ae
commit
6e4bd79843
3 changed files with 19 additions and 18 deletions
|
@ -36,7 +36,7 @@ defmodule PhilomenaWeb.ProfileController do
|
||||||
def show(conn, _params) do
|
def show(conn, _params) do
|
||||||
current_filter = conn.assigns.current_filter
|
current_filter = conn.assigns.current_filter
|
||||||
current_user = conn.assigns.current_user
|
current_user = conn.assigns.current_user
|
||||||
user = conn.assigns.user
|
user = Repo.preload(conn.assigns.user, [:forced_filter])
|
||||||
|
|
||||||
{:ok, {recent_uploads, _tags}} =
|
{:ok, {recent_uploads, _tags}} =
|
||||||
ImageLoader.search_string(
|
ImageLoader.search_string(
|
||||||
|
@ -140,6 +140,8 @@ defmodule PhilomenaWeb.ProfileController do
|
||||||
interactions =
|
interactions =
|
||||||
Interactions.user_interactions([recent_uploads, recent_faves, recent_artwork], current_user)
|
Interactions.user_interactions([recent_uploads, recent_faves, recent_artwork], current_user)
|
||||||
|
|
||||||
|
forced = user.forced_filter
|
||||||
|
|
||||||
bans =
|
bans =
|
||||||
Bans.User
|
Bans.User
|
||||||
|> where(user_id: ^user.id)
|
|> where(user_id: ^user.id)
|
||||||
|
@ -163,6 +165,7 @@ defmodule PhilomenaWeb.ProfileController do
|
||||||
about_me: about_me,
|
about_me: about_me,
|
||||||
scratchpad: scratchpad,
|
scratchpad: scratchpad,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
|
forced: forced,
|
||||||
bans: bans,
|
bans: bans,
|
||||||
layout_class: "layout--medium",
|
layout_class: "layout--medium",
|
||||||
title: "#{user.name}'s profile"
|
title: "#{user.name}'s profile"
|
||||||
|
@ -223,9 +226,8 @@ defmodule PhilomenaWeb.ProfileController do
|
||||||
defp set_admin_metadata(conn, _opts) do
|
defp set_admin_metadata(conn, _opts) do
|
||||||
case Canada.Can.can?(conn.assigns.current_user, :index, User) do
|
case Canada.Can.can?(conn.assigns.current_user, :index, User) do
|
||||||
true ->
|
true ->
|
||||||
user = Repo.preload(conn.assigns.user, [:current_filter, :forced_filter])
|
user = Repo.preload(conn.assigns.user, [:current_filter])
|
||||||
filter = user.current_filter
|
filter = user.current_filter
|
||||||
forced = user.forced_filter
|
|
||||||
|
|
||||||
last_ip =
|
last_ip =
|
||||||
UserIp
|
UserIp
|
||||||
|
@ -243,7 +245,6 @@ defmodule PhilomenaWeb.ProfileController do
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> assign(:filter, filter)
|
|> assign(:filter, filter)
|
||||||
|> assign(:forced, forced)
|
|
||||||
|> assign(:last_ip, last_ip)
|
|> assign(:last_ip, last_ip)
|
||||||
|> assign(:last_fp, last_fp)
|
|> assign(:last_fp, last_fp)
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,6 @@
|
||||||
em
|
em
|
||||||
' (none)
|
' (none)
|
||||||
|
|
||||||
= if @forced do
|
|
||||||
br
|
|
||||||
i.fa.fa-fw.fa-filter>
|
|
||||||
strong.comment_deleted> Forced Filter:
|
|
||||||
= link @forced.name, to: Routes.filter_path(@conn, :show, @forced)
|
|
||||||
|
|
||||||
br
|
br
|
||||||
i.far.fa-fw.fa-clock>
|
i.far.fa-fw.fa-clock>
|
||||||
' Last seen
|
' Last seen
|
||||||
|
|
|
@ -43,6 +43,12 @@
|
||||||
.js-staff-action
|
.js-staff-action
|
||||||
= render PhilomenaWeb.ProfileView, "_admin_block.html", assigns
|
= render PhilomenaWeb.ProfileView, "_admin_block.html", assigns
|
||||||
|
|
||||||
|
= if @forced && (current?(@user, @conn.assigns.current_user) or can_index_user?(@conn)) do
|
||||||
|
.block
|
||||||
|
i.fa.fa-fw.fa-filter>
|
||||||
|
strong.comment_deleted> Forced Filter:
|
||||||
|
= link @forced.name, to: Routes.filter_path(@conn, :show, @forced)
|
||||||
|
|
||||||
= if (current?(@user, @conn.assigns.current_user) or can?(@conn, :index, Philomena.Bans.User)) and Enum.any?(@bans) do
|
= if (current?(@user, @conn.assigns.current_user) or can?(@conn, :index, Philomena.Bans.User)) and Enum.any?(@bans) do
|
||||||
.block
|
.block
|
||||||
.block__header--single-item
|
.block__header--single-item
|
||||||
|
|
Loading…
Reference in a new issue