mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
Fix error on user update form
This commit is contained in:
parent
4e7d1988ee
commit
14cfb3b06e
4 changed files with 15 additions and 7 deletions
|
@ -518,6 +518,10 @@ defmodule Philomena.Users do
|
|||
unsubscribe_restricted_actors(user)
|
||||
end)
|
||||
|> Repo.transaction()
|
||||
|> case do
|
||||
{:ok, %{user: user}} -> {:ok, user}
|
||||
{:error, :user, changeset, _} -> {:error, changeset}
|
||||
end
|
||||
end
|
||||
|
||||
defp clean_roles(nil), do: []
|
||||
|
|
|
@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Admin.UserController do
|
|||
id_field: "slug",
|
||||
preload: [:roles]
|
||||
|
||||
plug :load_roles when action in [:edit]
|
||||
plug :load_roles when action in [:edit, :update]
|
||||
|
||||
def index(conn, %{"q" => q}) do
|
||||
User
|
||||
|
@ -62,10 +62,10 @@ defmodule PhilomenaWeb.Admin.UserController do
|
|||
{:ok, user} ->
|
||||
conn
|
||||
|> put_flash(:info, "User successfully updated.")
|
||||
|> moderation_log(details: &log_details/3, data: user.user)
|
||||
|> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user))
|
||||
|> moderation_log(details: &log_details/3, data: user)
|
||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||
|
||||
{:error, %{user: changeset}} ->
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,10 +8,14 @@
|
|||
span.block__header__title Essential user details
|
||||
label.table-list__label
|
||||
.table-list__label__text Name:
|
||||
.table-list__label__input = text_input f, :name, class: "input"
|
||||
.table-list__label__input
|
||||
= error_tag f, :name
|
||||
= text_input f, :name, class: "input"
|
||||
label.table-list__label
|
||||
.table-list__label__text Email:
|
||||
.table-list__label__input = text_input f, :email, class: "input"
|
||||
.table-list__label__input
|
||||
= error_tag f, :email
|
||||
= text_input f, :email, class: "input"
|
||||
label.table-list__label
|
||||
.table-list__label__text Role:
|
||||
.table-list__label__input = select f, :role, ["user", "assistant", "moderator", "admin"], class: "input"
|
||||
|
|
|
@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Admin.UserView do
|
|||
id: input_id,
|
||||
checked_value: to_string(role.id),
|
||||
hidden_input: false,
|
||||
checked: Enum.member?(Enum.map(input_value(form, field), & &1.id), role.id)
|
||||
checked: Enum.member?(Enum.map(Map.get(form.data, field), & &1.id), role.id)
|
||||
)
|
||||
|
||||
content_tag(:li, class: "table-list__label") do
|
||||
|
|
Loading…
Reference in a new issue