diff --git a/lib/philomena_web/controllers/admin/user_ban_controller.ex b/lib/philomena_web/controllers/admin/user_ban_controller.ex index fbbe7091..5c6431be 100644 --- a/lib/philomena_web/controllers/admin/user_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/user_ban_controller.ex @@ -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) diff --git a/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime b/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime index ba74f8d8..3d46f242 100644 --- a/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime +++ b/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime @@ -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 diff --git a/lib/philomena_web/templates/admin/subnet_ban/index.html.slime b/lib/philomena_web/templates/admin/subnet_ban/index.html.slime index ed3cd6e3..bbcb4439 100644 --- a/lib/philomena_web/templates/admin/subnet_ban/index.html.slime +++ b/lib/philomena_web/templates/admin/subnet_ban/index.html.slime @@ -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 diff --git a/lib/philomena_web/templates/admin/user_ban/index.html.slime b/lib/philomena_web/templates/admin/user_ban/index.html.slime index 4c831921..94b25f6d 100644 --- a/lib/philomena_web/templates/admin/user_ban/index.html.slime +++ b/lib/philomena_web/templates/admin/user_ban/index.html.slime @@ -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 diff --git a/lib/philomena_web/templates/fingerprint_profile/show.html.slime b/lib/philomena_web/templates/fingerprint_profile/show.html.slime index 00b24778..9c31d7a9 100644 --- a/lib/philomena_web/templates/fingerprint_profile/show.html.slime +++ b/lib/philomena_web/templates/fingerprint_profile/show.html.slime @@ -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 diff --git a/lib/philomena_web/templates/ip_profile/show.html.slime b/lib/philomena_web/templates/ip_profile/show.html.slime index b0aca083..02f41a55 100644 --- a/lib/philomena_web/templates/ip_profile/show.html.slime +++ b/lib/philomena_web/templates/ip_profile/show.html.slime @@ -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 diff --git a/lib/philomena_web/templates/profile/show.html.slime b/lib/philomena_web/templates/profile/show.html.slime index c96362d8..018f7981 100644 --- a/lib/philomena_web/templates/profile/show.html.slime +++ b/lib/philomena_web/templates/profile/show.html.slime @@ -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}")) @@ -95,4 +97,4 @@ = render PhilomenaWeb.ProfileView, "_recent_images.html", title: "Recent Favorites", images: @recent_faves, view_all_path: Routes.search_path(@conn, :index, q: "faved_by_id:#{@user.id}"), conn: @conn = render PhilomenaWeb.ProfileView, "_recent_galleries.html", galleries: @recent_galleries, user: @user, conn: @conn = render PhilomenaWeb.ProfileView, "_recent_comments.html", comments: @recent_comments, user: @user, conn: @conn - = render PhilomenaWeb.ProfileView, "_recent_posts.html", posts: @recent_posts, user: @user, conn: @conn \ No newline at end of file + = render PhilomenaWeb.ProfileView, "_recent_posts.html", posts: @recent_posts, user: @user, conn: @conn diff --git a/lib/philomena_web/views/profile_view.ex b/lib/philomena_web/views/profile_view.ex index ddc19785..a7efde75 100644 --- a/lib/philomena_web/views/profile_view.ex +++ b/lib/philomena_web/views/profile_view.ex @@ -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 <> ")" @@ -94,4 +97,4 @@ defmodule PhilomenaWeb.ProfileView do defp badge_url_root do Application.get_env(:philomena, :badge_url_root) end -end \ No newline at end of file +end