mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +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
|
||||
current_filter = conn.assigns.current_filter
|
||||
current_user = conn.assigns.current_user
|
||||
user = conn.assigns.user
|
||||
user = Repo.preload(conn.assigns.user, [:forced_filter])
|
||||
|
||||
{:ok, {recent_uploads, _tags}} =
|
||||
ImageLoader.search_string(
|
||||
|
@ -140,6 +140,8 @@ defmodule PhilomenaWeb.ProfileController do
|
|||
interactions =
|
||||
Interactions.user_interactions([recent_uploads, recent_faves, recent_artwork], current_user)
|
||||
|
||||
forced = user.forced_filter
|
||||
|
||||
bans =
|
||||
Bans.User
|
||||
|> where(user_id: ^user.id)
|
||||
|
@ -163,6 +165,7 @@ defmodule PhilomenaWeb.ProfileController do
|
|||
about_me: about_me,
|
||||
scratchpad: scratchpad,
|
||||
tags: tags,
|
||||
forced: forced,
|
||||
bans: bans,
|
||||
layout_class: "layout--medium",
|
||||
title: "#{user.name}'s profile"
|
||||
|
@ -223,9 +226,8 @@ defmodule PhilomenaWeb.ProfileController do
|
|||
defp set_admin_metadata(conn, _opts) do
|
||||
case Canada.Can.can?(conn.assigns.current_user, :index, User) do
|
||||
true ->
|
||||
user = Repo.preload(conn.assigns.user, [:current_filter, :forced_filter])
|
||||
user = Repo.preload(conn.assigns.user, [:current_filter])
|
||||
filter = user.current_filter
|
||||
forced = user.forced_filter
|
||||
|
||||
last_ip =
|
||||
UserIp
|
||||
|
@ -243,7 +245,6 @@ defmodule PhilomenaWeb.ProfileController do
|
|||
|
||||
conn
|
||||
|> assign(:filter, filter)
|
||||
|> assign(:forced, forced)
|
||||
|> assign(:last_ip, last_ip)
|
||||
|> assign(:last_fp, last_fp)
|
||||
|
||||
|
|
|
@ -12,12 +12,6 @@
|
|||
em
|
||||
' (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
|
||||
i.far.fa-fw.fa-clock>
|
||||
' Last seen
|
||||
|
@ -79,7 +73,7 @@ a.label.label--primary.label--block href="#" data-click-toggle=".js-admin__optio
|
|||
|
||||
ul.profile-admin__options__column
|
||||
= if can?(@conn, :edit, @user) do
|
||||
li
|
||||
li
|
||||
= link to: Routes.admin_user_path(@conn, :edit, @user) do
|
||||
i.fas.fa-fw.fa-edit
|
||||
span.admin__button Edit User
|
||||
|
@ -106,36 +100,36 @@ a.label.label--primary.label--block href="#" data-click-toggle=".js-admin__optio
|
|||
i.fa.fa-fw.fa-times
|
||||
span.admin__button Deactivate Account
|
||||
|
||||
li
|
||||
li
|
||||
= link to: Routes.admin_user_wipe_path(@conn, :create, @user), data: [confirm: "This is irreversible, destroying all identifying information including email. Are you sure?", method: "post"] do
|
||||
i.fas.fa-fw.fa-eraser
|
||||
span.admin__button Wipe PII
|
||||
|
||||
|
||||
= if can?(@conn, :index, Philomena.Users.User) do
|
||||
li
|
||||
li
|
||||
= link to: Routes.admin_user_vote_path(@conn, :delete, @user), data: [confirm: "Are you really, really sure?", method: "delete"] do
|
||||
i.far.fa-fw.fa-file-excel
|
||||
span.admin__button Remove All Votes/Faves
|
||||
|
||||
li
|
||||
li
|
||||
= link to: Routes.admin_user_downvote_path(@conn, :delete, @user), data: [confirm: "Are you really, really sure?", method: "delete"] do
|
||||
i.fa.fa-fw.fa-arrow-down
|
||||
span.admin__button Remove All Downvotes
|
||||
|
||||
= if can?(@conn, :index, %Philomena.Donations.Donation{}) do
|
||||
li
|
||||
li
|
||||
= link to: Routes.admin_donation_user_path(@conn, :show, @user) do
|
||||
i.fas.fa-fw.fa-dollar-sign
|
||||
span.admin__button Donations
|
||||
|
||||
= if can?(@conn, :edit, %Philomena.UserLinks.UserLink{}) do
|
||||
li
|
||||
li
|
||||
= link to: Routes.profile_user_link_path(@conn, :new, @user) do
|
||||
i.fa.fa-fw.fa-link
|
||||
span.admin__button Add User Link
|
||||
|
||||
= if can?(@conn, :create, Philomena.Bans.User) do
|
||||
li
|
||||
li
|
||||
= link to: Routes.admin_user_ban_path(@conn, :new, username: @user.name) do
|
||||
i.fa.fa-fw.fa-ban
|
||||
span.admin__button Ban this sucker
|
||||
|
|
|
@ -43,6 +43,12 @@
|
|||
.js-staff-action
|
||||
= 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
|
||||
.block
|
||||
.block__header--single-item
|
||||
|
|
Loading…
Reference in a new issue