user reporting

This commit is contained in:
byte[] 2019-12-04 08:25:10 -05:00
parent c3d6a3817e
commit 3f6322ca81
3 changed files with 40 additions and 4 deletions

View file

@ -0,0 +1,34 @@
defmodule PhilomenaWeb.Profile.ReportController do
use PhilomenaWeb, :controller
alias PhilomenaWeb.ReportController
alias PhilomenaWeb.ReportView
alias Philomena.Users.User
alias Philomena.Reports.Report
alias Philomena.Reports
plug PhilomenaWeb.FilterBannedUsersPlug
plug PhilomenaWeb.UserAttributionPlug
plug PhilomenaWeb.CaptchaPlug when action in [:create]
plug PhilomenaWeb.CanaryMapPlug, new: :show, create: :show
plug :load_and_authorize_resource, model: User, id_name: "profile_id", id_field: "slug", persisted: true
def new(conn, _params) do
user = conn.assigns.user
action = Routes.profile_report_path(conn, :create, user)
changeset =
%Report{reportable_type: "User", reportable_id: user.id}
|> Reports.change_report()
conn
|> put_view(ReportView)
|> render("new.html", reportable: user, changeset: changeset, action: action)
end
def create(conn, params) do
user = conn.assigns.user
action = Routes.profile_report_path(conn, :create, user)
ReportController.create(conn, action, user, "User", params)
end
end

View file

@ -165,7 +165,9 @@ defmodule PhilomenaWeb.Router do
resources "/current", CurrentController, only: [:update], singleton: true resources "/current", CurrentController, only: [:update], singleton: true
end end
resources "/filters", FilterController resources "/filters", FilterController
resources "/profiles", ProfileController, only: [:show] resources "/profiles", ProfileController, only: [:show] do
resources "/reports", Profile.ReportController, only: [:new, :create]
end
resources "/captchas", CaptchaController, only: [:create] resources "/captchas", CaptchaController, only: [:create]
scope "/posts", Post, as: :post do scope "/posts", Post, as: :post do
resources "/preview", PreviewController, only: [:create] resources "/preview", PreviewController, only: [:create]

View file

@ -12,9 +12,9 @@
.profile-top__options .profile-top__options
ul.profile-top__options__column ul.profile-top__options__column
li = link("Send message", to: "#") li = link("Send message", to: Routes.conversation_path(@conn, :new, recipient: @user.name))
li = link("Our conversations", to: "#") li = link("Our conversations", to: Routes.conversation_path(@conn, :index, with: @user.id))
li = link("Report this user", to: "#") li = link("Report this user", to: Routes.profile_report_path(@conn, :new, @user))
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}"))