forked from shibao/cannery
		
	add models, context and liveviews
This commit is contained in:
		
							
								
								
									
										25
									
								
								lib/cannery/ammo/ammo_group.ex
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								lib/cannery/ammo/ammo_group.ex
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| defmodule Cannery.Ammo.AmmoGroup do | ||||
|   use Ecto.Schema | ||||
|   import Ecto.Changeset | ||||
|  | ||||
|   @primary_key {:id, :binary_id, autogenerate: true} | ||||
|   @foreign_key_type :binary_id | ||||
|   schema "ammo_groups" do | ||||
|     field :count, :integer | ||||
|     field :notes, :string | ||||
|     field :price_paid, :float | ||||
|     field :tag_id, :binary_id | ||||
|     field :ammo_type_id, :binary_id | ||||
|     field :container_id, :binary_id | ||||
|     field :user_id, :binary_id | ||||
|  | ||||
|     timestamps() | ||||
|   end | ||||
|  | ||||
|   @doc false | ||||
|   def changeset(ammo_group, attrs) do | ||||
|     ammo_group | ||||
|     |> cast(attrs, [:count, :price_paid, :notes]) | ||||
|     |> validate_required([:count, :price_paid, :notes]) | ||||
|   end | ||||
| end | ||||
							
								
								
									
										24
									
								
								lib/cannery/ammo/ammo_type.ex
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								lib/cannery/ammo/ammo_type.ex
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| defmodule Cannery.Ammo.AmmoType do | ||||
|   use Ecto.Schema | ||||
|   import Ecto.Changeset | ||||
|  | ||||
|   @primary_key {:id, :binary_id, autogenerate: true} | ||||
|   @foreign_key_type :binary_id | ||||
|   schema "ammo_types" do | ||||
|     field :bullet_type, :string | ||||
|     field :case_material, :string | ||||
|     field :desc, :string | ||||
|     field :manufacturer, :string | ||||
|     field :name, :string | ||||
|     field :weight, :float | ||||
|  | ||||
|     timestamps() | ||||
|   end | ||||
|  | ||||
|   @doc false | ||||
|   def changeset(ammo_type, attrs) do | ||||
|     ammo_type | ||||
|     |> cast(attrs, [:name, :desc, :case_material, :bullet_type, :weight, :manufacturer]) | ||||
|     |> validate_required([:name, :desc, :case_material, :bullet_type, :weight, :manufacturer]) | ||||
|   end | ||||
| end | ||||
		Reference in New Issue
	
	Block a user