remove role from context

This commit is contained in:
byte[] 2019-11-14 20:15:07 -05:00
parent abd4de0b4d
commit 31d637cca0

View file

@ -8,6 +8,10 @@ defmodule Philomena.Users do
alias Philomena.Users.User alias Philomena.Users.User
use Pow.Ecto.Context,
repo: Repo,
user: User
@doc """ @doc """
Returns the list of users. Returns the list of users.
@ -101,100 +105,4 @@ defmodule Philomena.Users do
def change_user(%User{} = user) do def change_user(%User{} = user) do
User.changeset(user, %{}) User.changeset(user, %{})
end end
alias Philomena.Users.Role
@doc """
Returns the list of users_roles.
## Examples
iex> list_users_roles()
[%Role{}, ...]
"""
def list_users_roles do
Repo.all(Role)
end
@doc """
Gets a single role.
Raises `Ecto.NoResultsError` if the Role does not exist.
## Examples
iex> get_role!(123)
%Role{}
iex> get_role!(456)
** (Ecto.NoResultsError)
"""
def get_role!(id), do: Repo.get!(Role, id)
@doc """
Creates a role.
## Examples
iex> create_role(%{field: value})
{:ok, %Role{}}
iex> create_role(%{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def create_role(attrs \\ %{}) do
%Role{}
|> Role.changeset(attrs)
|> Repo.insert()
end
@doc """
Updates a role.
## Examples
iex> update_role(role, %{field: new_value})
{:ok, %Role{}}
iex> update_role(role, %{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def update_role(%Role{} = role, attrs) do
role
|> Role.changeset(attrs)
|> Repo.update()
end
@doc """
Deletes a Role.
## Examples
iex> delete_role(role)
{:ok, %Role{}}
iex> delete_role(role)
{:error, %Ecto.Changeset{}}
"""
def delete_role(%Role{} = role) do
Repo.delete(role)
end
@doc """
Returns an `%Ecto.Changeset{}` for tracking role changes.
## Examples
iex> change_role(role)
%Ecto.Changeset{source: %Role{}}
"""
def change_role(%Role{} = role) do
Role.changeset(role, %{})
end
end end