forked from shibao/cannery
		
	fix dialyzer, credo and format
This commit is contained in:
		| @@ -1,7 +1,12 @@ | ||||
| defmodule Cannery.Containers.Container do | ||||
|   @moduledoc """ | ||||
|   A container that holds ammunition and belongs to a user. | ||||
|   """ | ||||
|  | ||||
|   use Ecto.Schema | ||||
|   import Ecto.Changeset | ||||
|   alias Cannery.{Accounts} | ||||
|   alias Ecto.{Changeset, UUID} | ||||
|   alias Cannery.{Accounts.User, Containers.Container} | ||||
|  | ||||
|   @primary_key {:id, :binary_id, autogenerate: true} | ||||
|   @foreign_key_type :binary_id | ||||
| @@ -11,27 +16,30 @@ defmodule Cannery.Containers.Container do | ||||
|     field :location, :string | ||||
|     field :type, :string | ||||
|  | ||||
|     belongs_to :user, Accounts.User | ||||
|     belongs_to :user, User | ||||
|  | ||||
|     timestamps() | ||||
|   end | ||||
|  | ||||
|   @type t :: %{ | ||||
|           id: Ecto.UUID.t(), | ||||
|   @type t :: %Container{ | ||||
|           id: UUID.t(), | ||||
|           name: String.t(), | ||||
|           desc: String.t(), | ||||
|           location: String.t(), | ||||
|           type: String.t(), | ||||
|           user: Accounts.User.t(), | ||||
|           user_id: Ecto.UUID.t(), | ||||
|           user: User.t(), | ||||
|           user_id: UUID.t(), | ||||
|           inserted_at: NaiveDateTime.t(), | ||||
|           updated_at: NaiveDateTime.t() | ||||
|         } | ||||
|  | ||||
|   @type new_container :: %Container{} | ||||
|  | ||||
|   @doc false | ||||
|   @spec changeset(Container.t() | Container.new_container(), map()) :: Changeset.t() | ||||
|   def changeset(container, attrs) do | ||||
|     container | ||||
|     |> cast(attrs, [:name, :desc, :type, :location, :user_id]) | ||||
|     |> validate_required([:name, :desc, :type, :location, :user_id]) | ||||
|     |> validate_required([:name, :type, :user_id]) | ||||
|   end | ||||
| end | ||||
|   | ||||
| @@ -1,28 +1,34 @@ | ||||
| defmodule Cannery.Containers.ContainerTag do | ||||
|   @moduledoc """ | ||||
|   Thru-table struct for associating Cannery.Containers.Container and | ||||
|   Cannery.Tags.Tag. | ||||
|   """ | ||||
|  | ||||
|   use Ecto.Schema | ||||
|   import Ecto.Changeset | ||||
|   alias Cannery.{Containers, Tags} | ||||
|   alias Cannery.{Containers.Container, Containers.ContainerTag, Tags.Tag} | ||||
|  | ||||
|   @primary_key {:id, :binary_id, autogenerate: true} | ||||
|   @foreign_key_type :binary_id | ||||
|   schema "container_tags" do | ||||
|     belongs_to :container, Containers.Container | ||||
|     belongs_to :tag, Tags.Tag | ||||
|     belongs_to :container, Container | ||||
|     belongs_to :tag, Tag | ||||
|  | ||||
|     timestamps() | ||||
|   end | ||||
|  | ||||
|   @type t :: %{ | ||||
|   @type t :: %ContainerTag{ | ||||
|           id: Ecto.UUID.t(), | ||||
|           container: Containers.Container.t(), | ||||
|           container: Container.t(), | ||||
|           container_id: Ecto.UUID.t(), | ||||
|           tag: Tags.Tag.t(), | ||||
|           tag: Tag.t(), | ||||
|           tag_id: Ecto.UUID.t(), | ||||
|           inserted_at: NaiveDateTime.t(), | ||||
|           updated_at: NaiveDateTime.t() | ||||
|         } | ||||
|  | ||||
|   @doc false | ||||
|   @spec changeset(ContainerTag.t(), map()) :: Ecto.Changeset.t() | ||||
|   def changeset(container_tag, attrs) do | ||||
|     container_tag | ||||
|     |> cast(attrs, [:tag_id, :container_id]) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user