2019-11-29 23:01:54 +01:00
|
|
|
defmodule PhilomenaWeb.StaffController do
|
|
|
|
use PhilomenaWeb, :controller
|
|
|
|
|
|
|
|
alias Philomena.Users.User
|
|
|
|
alias Philomena.Repo
|
|
|
|
import Ecto.Query
|
|
|
|
|
|
|
|
def index(conn, _params) do
|
|
|
|
users =
|
|
|
|
User
|
|
|
|
|> where([u], u.role in ["admin", "moderator", "assistant"])
|
|
|
|
|> order_by(asc: :name)
|
|
|
|
|> Repo.all()
|
|
|
|
|
2019-11-29 23:04:59 +01:00
|
|
|
categories = [
|
2020-06-08 04:32:04 +02:00
|
|
|
Administrators: Enum.filter(users, &(&1.role == "admin" and &1.hide_default_role == false)),
|
2020-01-11 05:20:19 +01:00
|
|
|
"Technical Team":
|
|
|
|
Enum.filter(
|
|
|
|
users,
|
|
|
|
&(&1.role != "admin" and &1.secondary_role in ["Site Developer", "System Administrator"])
|
|
|
|
),
|
|
|
|
"Public Relations":
|
|
|
|
Enum.filter(users, &(&1.role != "admin" and &1.secondary_role == "Public Relations")),
|
|
|
|
Moderators:
|
2020-06-12 19:00:59 +02:00
|
|
|
Enum.filter(
|
|
|
|
users,
|
|
|
|
&(&1.role == "moderator" and &1.secondary_role in [nil, ""] and
|
|
|
|
&1.hide_default_role == false)
|
|
|
|
),
|
|
|
|
Assistants:
|
|
|
|
Enum.filter(
|
|
|
|
users,
|
|
|
|
&(&1.role == "assistant" and &1.secondary_role in [nil, ""] and
|
|
|
|
&1.hide_default_role == false)
|
|
|
|
)
|
2019-11-29 23:04:59 +01:00
|
|
|
]
|
2019-11-29 23:01:54 +01:00
|
|
|
|
2019-12-25 19:32:24 +01:00
|
|
|
render(conn, "index.html", title: "Site Staff", categories: categories)
|
2019-11-29 23:01:54 +01:00
|
|
|
end
|
|
|
|
end
|