mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
remove role from context
This commit is contained in:
parent
abd4de0b4d
commit
31d637cca0
1 changed files with 4 additions and 96 deletions
|
@ -8,6 +8,10 @@ defmodule Philomena.Users do
|
|||
|
||||
alias Philomena.Users.User
|
||||
|
||||
use Pow.Ecto.Context,
|
||||
repo: Repo,
|
||||
user: User
|
||||
|
||||
@doc """
|
||||
Returns the list of users.
|
||||
|
||||
|
@ -101,100 +105,4 @@ defmodule Philomena.Users do
|
|||
def change_user(%User{} = user) do
|
||||
User.changeset(user, %{})
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue