mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
misc additions, 'ban this sucker' buttons
This commit is contained in:
parent
fefb91644b
commit
6337b23dbe
8 changed files with 52 additions and 15 deletions
|
@ -33,6 +33,11 @@ defmodule PhilomenaWeb.Admin.UserBanController do
|
||||||
load_bans(UserBan, conn)
|
load_bans(UserBan, conn)
|
||||||
end
|
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
|
def new(conn, _params) do
|
||||||
changeset = Bans.change_user(%UserBan{})
|
changeset = Bans.change_user(%UserBan{})
|
||||||
render(conn, "new.html", changeset: changeset)
|
render(conn, "new.html", changeset: changeset)
|
||||||
|
|
|
@ -3,8 +3,17 @@ h1 Fingerprint Bans
|
||||||
- route = fn p -> Routes.admin_fingerprint_ban_path(@conn, :index, p) end
|
- route = fn p -> Routes.admin_fingerprint_ban_path(@conn, :index, p) end
|
||||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @fingerprint_bans, route: route
|
- 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
|
||||||
.block__header
|
.block__header
|
||||||
|
a href=Routes.admin_fingerprint_ban_path(@conn, :new)
|
||||||
|
i.fa.fa-plus>
|
||||||
|
' New fingerprint ban
|
||||||
|
|
||||||
= pagination
|
= pagination
|
||||||
|
|
||||||
.block__content
|
.block__content
|
||||||
|
|
|
@ -3,8 +3,17 @@ h1 Subnet Bans
|
||||||
- route = fn p -> Routes.admin_subnet_ban_path(@conn, :index, p) end
|
- route = fn p -> Routes.admin_subnet_ban_path(@conn, :index, p) end
|
||||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @subnet_bans, route: route
|
- 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
|
||||||
.block__header
|
.block__header
|
||||||
|
a href=Routes.admin_subnet_ban_path(@conn, :new)
|
||||||
|
i.fa.fa-plus>
|
||||||
|
' New subnet ban
|
||||||
|
|
||||||
= pagination
|
= pagination
|
||||||
|
|
||||||
.block__content
|
.block__content
|
||||||
|
|
|
@ -3,8 +3,17 @@ h1 User Bans
|
||||||
- route = fn p -> Routes.admin_user_ban_path(@conn, :index, p) end
|
- route = fn p -> Routes.admin_user_ban_path(@conn, :index, p) end
|
||||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @user_bans, route: route
|
- 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
|
||||||
.block__header
|
.block__header
|
||||||
|
a href=Routes.admin_user_ban_path(@conn, :new)
|
||||||
|
i.fa.fa-plus>
|
||||||
|
' New user ban
|
||||||
|
|
||||||
= pagination
|
= pagination
|
||||||
|
|
||||||
.block__content
|
.block__content
|
||||||
|
|
|
@ -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 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}")
|
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
|
h2 Administration Options
|
||||||
/ul
|
/ul
|
||||||
li = link "View tag changes", "/fingerprint_profiles/#{@fingerprint}/tag_changes"
|
/li = link "View tag changes", "/fingerprint_profiles/#{@fingerprint}/tag_changes"
|
||||||
li = link "View source URL history", "/fingerprint_profiles/#{@fingerprint}/source_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 reports this fingerprint has made", to: Routes.admin_report_path(@conn, :index, rq: "fingerprint:#{@fingerprint}")
|
||||||
li = link "View fingerprint ban history", admin_subnet_bans_path(q: @fingerprint)
|
li = link "View fingerprint ban history", to: Routes.admin_fingerprint_ban_path(@conn, :index, fingerprint: @fingerprint)
|
||||||
li = link "Ban this sucker", new_admin_subnet_ban_path(fingerprint: @fingerprint)
|
li = link "Ban this sucker", to: Routes.admin_fingerprint_ban_path(@conn, :new, fingerprint: @fingerprint)
|
||||||
|
|
||||||
h4 Observed users
|
h4 Observed users
|
||||||
table.table
|
table.table
|
||||||
|
|
|
@ -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 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}")
|
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
|
h2 Administration Options
|
||||||
/ul
|
ul
|
||||||
li = link "View tag changes", "/ip_profiles/#{@ip}/tag_changes"
|
/li = link "View tag changes", "/ip_profiles/#{@ip}/tag_changes"
|
||||||
li = link "View source URL history", "/ip_profiles/#{@ip}/source_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 reports this IP has made", to: Routes.admin_report_path(@conn, :index, rq: "ip:#{@ip}")
|
||||||
li = link "View IP ban history", admin_subnet_bans_path(q: @ip)
|
li = link "View IP ban history", to: Routes.admin_subnet_ban_path(@conn, :index, ip: to_string(@ip))
|
||||||
li = link "Ban this sucker", new_admin_subnet_ban_path(ip: @ip)
|
li = link "Ban this sucker", to: Routes.admin_subnet_ban_path(@conn, :new, specification: to_string(@ip))
|
||||||
|
|
||||||
h4 Observed users
|
h4 Observed users
|
||||||
table.table
|
table.table
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
li = link("Send message", to: Routes.conversation_path(@conn, :new, recipient: @user.name))
|
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("Our conversations", to: Routes.conversation_path(@conn, :index, with: @user.id))
|
||||||
li = link("Report this user", to: Routes.profile_report_path(@conn, :new, @user))
|
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
|
ul.profile-top__options__column
|
||||||
li = link("Uploads", to: Routes.search_path(@conn, :index, q: "uploader_id:#{@user.id}"))
|
li = link("Uploads", to: Routes.search_path(@conn, :index, q: "uploader_id:#{@user.id}"))
|
||||||
|
|
|
@ -50,6 +50,9 @@ defmodule PhilomenaWeb.ProfileView do
|
||||||
Enum.map_join(tags, " || ", & &1.name)
|
Enum.map_join(tags, " || ", & &1.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_ban?(conn),
|
||||||
|
do: can?(conn, :index, Philomena.Bans.User)
|
||||||
|
|
||||||
def user_abbrv(conn, %{name: name} = user) do
|
def user_abbrv(conn, %{name: name} = user) do
|
||||||
abbrv = String.upcase(initials_abbrv(name) || uppercase_abbrv(name) || first_letters_abbrv(name))
|
abbrv = String.upcase(initials_abbrv(name) || uppercase_abbrv(name) || first_letters_abbrv(name))
|
||||||
abbrv = "(" <> abbrv <> ")"
|
abbrv = "(" <> abbrv <> ")"
|
||||||
|
|
Loading…
Reference in a new issue