mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
disable report limit for staff
This commit is contained in:
parent
389100dae2
commit
75e07bfb13
1 changed files with 14 additions and 4 deletions
|
@ -40,7 +40,7 @@ defmodule PhilomenaWeb.ReportController do
|
||||||
conn
|
conn
|
||||||
|> put_flash(
|
|> put_flash(
|
||||||
:error,
|
:error,
|
||||||
"You may not have more than 3 open reports at a time. Did you read the reporting tips?"
|
"You may not have more than #{max_reports()} open reports at a time. Did you read the reporting tips?"
|
||||||
)
|
)
|
||||||
|> redirect(to: "/")
|
|> redirect(to: "/")
|
||||||
|
|
||||||
|
@ -68,7 +68,13 @@ defmodule PhilomenaWeb.ReportController do
|
||||||
defp too_many_reports?(conn) do
|
defp too_many_reports?(conn) do
|
||||||
user = conn.assigns.current_user
|
user = conn.assigns.current_user
|
||||||
|
|
||||||
too_many_reports_user?(user) or too_many_reports_ip?(conn)
|
case user do
|
||||||
|
%{role: role} when role != "user" ->
|
||||||
|
false
|
||||||
|
|
||||||
|
_user ->
|
||||||
|
too_many_reports_user?(user) or too_many_reports_ip?(conn)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp too_many_reports_user?(nil), do: false
|
defp too_many_reports_user?(nil), do: false
|
||||||
|
@ -80,7 +86,7 @@ defmodule PhilomenaWeb.ReportController do
|
||||||
|> where([r], r.state in ["open", "in_progress"])
|
|> where([r], r.state in ["open", "in_progress"])
|
||||||
|> Repo.aggregate(:count, :id)
|
|> Repo.aggregate(:count, :id)
|
||||||
|
|
||||||
reports_open >= 3
|
reports_open >= max_reports()
|
||||||
end
|
end
|
||||||
|
|
||||||
defp too_many_reports_ip?(conn) do
|
defp too_many_reports_ip?(conn) do
|
||||||
|
@ -92,9 +98,13 @@ defmodule PhilomenaWeb.ReportController do
|
||||||
|> where([r], r.state in ["open", "in_progress"])
|
|> where([r], r.state in ["open", "in_progress"])
|
||||||
|> Repo.aggregate(:count, :id)
|
|> Repo.aggregate(:count, :id)
|
||||||
|
|
||||||
reports_open >= 3
|
reports_open >= max_reports()
|
||||||
end
|
end
|
||||||
|
|
||||||
defp redirect_path(_conn, nil), do: "/"
|
defp redirect_path(_conn, nil), do: "/"
|
||||||
defp redirect_path(conn, _user), do: Routes.report_path(conn, :index)
|
defp redirect_path(conn, _user), do: Routes.report_path(conn, :index)
|
||||||
|
|
||||||
|
defp max_reports do
|
||||||
|
3
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue