validate commission base price to be present, example image in directory listing to be present

This commit is contained in:
byte[] 2020-02-06 17:15:37 -05:00
parent 4c0b440f58
commit 18e932560d
2 changed files with 3 additions and 3 deletions

View file

@ -21,7 +21,7 @@ defmodule Philomena.Commissions.Item do
def changeset(item, attrs) do def changeset(item, attrs) do
item item
|> cast(attrs, [:item_type, :description, :base_price, :add_ons, :example_image_id]) |> cast(attrs, [:item_type, :description, :base_price, :add_ons, :example_image_id])
|> validate_required([:commission_id, :item_type, :description]) |> validate_required([:commission_id, :base_price, :item_type, :description])
|> validate_length(:description, max: 300, count: :bytes) |> validate_length(:description, max: 300, count: :bytes)
|> validate_length(:add_ons, max: 500, count: :bytes) |> validate_length(:add_ons, max: 500, count: :bytes)
|> validate_number(:base_price, greater_than_or_equal_to: 0, less_than_or_equal_to: 500) |> validate_number(:base_price, greater_than_or_equal_to: 0, less_than_or_equal_to: 500)

View file

@ -53,7 +53,7 @@ elixir:
br br
= for item <- Enum.take_random(c.items, 5) do = for item <- Enum.take_random(c.items, 5), not is_nil(item.example_image) do
= render PhilomenaWeb.ImageView, "_image_container.html", image: item.example_image, size: :thumb_small, conn: @conn = render PhilomenaWeb.ImageView, "_image_container.html", image: item.example_image, size: :thumb_small, conn: @conn
p p
@ -61,4 +61,4 @@ elixir:
= link "More information", to: Routes.profile_commission_path(@conn, :show, c.user) = link "More information", to: Routes.profile_commission_path(@conn, :show, c.user)
- true -> - true ->
p We couldn't find any commission listings to display. Sorry! p We couldn't find any commission listings to display. Sorry!