misc additions, 'ban this sucker' buttons

This commit is contained in:
byte[] 2019-12-13 14:26:43 -05:00
parent fefb91644b
commit 6337b23dbe
8 changed files with 52 additions and 15 deletions

View file

@ -33,6 +33,11 @@ defmodule PhilomenaWeb.Admin.UserBanController do
load_bans(UserBan, conn)
end
def new(conn, %{"username" => username}) do
changeset = Bans.change_user(%UserBan{username: username})
render(conn, "new.html", changeset: changeset)
end
def new(conn, _params) do
changeset = Bans.change_user(%UserBan{})
render(conn, "new.html", changeset: changeset)

View file

@ -3,8 +3,17 @@ h1 Fingerprint Bans
- route = fn p -> Routes.admin_fingerprint_ban_path(@conn, :index, p) end
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @fingerprint_bans, route: route
= form_for :fingerprint_ban, Routes.admin_fingerprint_ban_path(@conn, :index), [method: "get", class: "hform"], fn f ->
.field
= text_input f, :q, name: "q", class: "hform__text input", placeholder: "Search"
= submit "Search", class: "button hform__button"
.block
.block__header
a href=Routes.admin_fingerprint_ban_path(@conn, :new)
i.fa.fa-plus>
' New fingerprint ban
= pagination
.block__content

View file

@ -3,8 +3,17 @@ h1 Subnet Bans
- route = fn p -> Routes.admin_subnet_ban_path(@conn, :index, p) end
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @subnet_bans, route: route
= form_for :subnet_ban, Routes.admin_subnet_ban_path(@conn, :index), [method: "get", class: "hform"], fn f ->
.field
= text_input f, :q, name: "q", class: "hform__text input", placeholder: "Search"
= submit "Search", class: "button hform__button"
.block
.block__header
a href=Routes.admin_subnet_ban_path(@conn, :new)
i.fa.fa-plus>
' New subnet ban
= pagination
.block__content

View file

@ -3,8 +3,17 @@ h1 User Bans
- route = fn p -> Routes.admin_user_ban_path(@conn, :index, p) end
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @user_bans, route: route
= form_for :user_ban, Routes.admin_user_ban_path(@conn, :index), [method: "get", class: "hform"], fn f ->
.field
= text_input f, :q, name: "q", class: "hform__text input", placeholder: "Search"
= submit "Search", class: "button hform__button"
.block
.block__header
a href=Routes.admin_user_ban_path(@conn, :new)
i.fa.fa-plus>
' New user ban
= pagination
.block__content

View file

@ -7,15 +7,15 @@ ul
li = link "View comments this fingerprint has posted", to: Routes.comment_path(@conn, :index, cq: "fingerprint:#{@fingerprint}")
li = link "View posts this fingerprint has made", to: Routes.post_path(@conn, :index, pq: "fingerprint:#{@fingerprint}")
/= render partial: "bans/ban_list", locals: { bans: @bans }
= render PhilomenaWeb.BanView, "_bans.html", bans: @fingerprint_bans, conn: @conn
h2 Administration Options
/ul
li = link "View tag changes", "/fingerprint_profiles/#{@fingerprint}/tag_changes"
li = link "View source URL history", "/fingerprint_profiles/#{@fingerprint}/source_changes"
li = link "View reports this fingerprint has made", admin_reports_path(rq: "ip:#{@fingerprint}")
li = link "View fingerprint ban history", admin_subnet_bans_path(q: @fingerprint)
li = link "Ban this sucker", new_admin_subnet_ban_path(fingerprint: @fingerprint)
/li = link "View tag changes", "/fingerprint_profiles/#{@fingerprint}/tag_changes"
/li = link "View source URL history", "/fingerprint_profiles/#{@fingerprint}/source_changes"
li = link "View reports this fingerprint has made", to: Routes.admin_report_path(@conn, :index, rq: "fingerprint:#{@fingerprint}")
li = link "View fingerprint ban history", to: Routes.admin_fingerprint_ban_path(@conn, :index, fingerprint: @fingerprint)
li = link "Ban this sucker", to: Routes.admin_fingerprint_ban_path(@conn, :new, fingerprint: @fingerprint)
h4 Observed users
table.table

View file

@ -7,15 +7,15 @@ ul
li = link "View comments this IP has posted", to: Routes.comment_path(@conn, :index, cq: "ip:#{@ip}")
li = link "View posts this IP has made", to: Routes.post_path(@conn, :index, pq: "ip:#{@ip}")
/= render partial: "bans/ban_list", locals: { bans: @bans }
= render PhilomenaWeb.BanView, "_bans.html", bans: @subnet_bans, conn: @conn
h2 Administration Options
/ul
li = link "View tag changes", "/ip_profiles/#{@ip}/tag_changes"
li = link "View source URL history", "/ip_profiles/#{@ip}/source_changes"
li = link "View reports this IP has made", admin_reports_path(rq: "ip:#{@ip}")
li = link "View IP ban history", admin_subnet_bans_path(q: @ip)
li = link "Ban this sucker", new_admin_subnet_ban_path(ip: @ip)
ul
/li = link "View tag changes", "/ip_profiles/#{@ip}/tag_changes"
/li = link "View source URL history", "/ip_profiles/#{@ip}/source_changes"
li = link "View reports this IP has made", to: Routes.admin_report_path(@conn, :index, rq: "ip:#{@ip}")
li = link "View IP ban history", to: Routes.admin_subnet_ban_path(@conn, :index, ip: to_string(@ip))
li = link "Ban this sucker", to: Routes.admin_subnet_ban_path(@conn, :new, specification: to_string(@ip))
h4 Observed users
table.table

View file

@ -22,6 +22,8 @@
li = link("Send message", to: Routes.conversation_path(@conn, :new, recipient: @user.name))
li = link("Our conversations", to: Routes.conversation_path(@conn, :index, with: @user.id))
li = link("Report this user", to: Routes.profile_report_path(@conn, :new, @user))
= if can_ban?(@conn) do
li = link("Ban this sucker", to: Routes.admin_user_ban_path(@conn, :new, username: @user.name))
ul.profile-top__options__column
li = link("Uploads", to: Routes.search_path(@conn, :index, q: "uploader_id:#{@user.id}"))

View file

@ -50,6 +50,9 @@ defmodule PhilomenaWeb.ProfileView do
Enum.map_join(tags, " || ", & &1.name)
end
def can_ban?(conn),
do: can?(conn, :index, Philomena.Bans.User)
def user_abbrv(conn, %{name: name} = user) do
abbrv = String.upcase(initials_abbrv(name) || uppercase_abbrv(name) || first_letters_abbrv(name))
abbrv = "(" <> abbrv <> ")"