From 18e932560d4384f2f27191bfa96470efd65ade98 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Thu, 6 Feb 2020 17:15:37 -0500 Subject: [PATCH] validate commission base price to be present, example image in directory listing to be present --- lib/philomena/commissions/item.ex | 2 +- .../templates/commission/_directory_results.html.slime | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/philomena/commissions/item.ex b/lib/philomena/commissions/item.ex index 15d08f09..220fc11e 100644 --- a/lib/philomena/commissions/item.ex +++ b/lib/philomena/commissions/item.ex @@ -21,7 +21,7 @@ defmodule Philomena.Commissions.Item do def changeset(item, attrs) do item |> 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(:add_ons, max: 500, count: :bytes) |> validate_number(:base_price, greater_than_or_equal_to: 0, less_than_or_equal_to: 500) diff --git a/lib/philomena_web/templates/commission/_directory_results.html.slime b/lib/philomena_web/templates/commission/_directory_results.html.slime index a52b1488..fa0c35fb 100644 --- a/lib/philomena_web/templates/commission/_directory_results.html.slime +++ b/lib/philomena_web/templates/commission/_directory_results.html.slime @@ -53,7 +53,7 @@ elixir: 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 p @@ -61,4 +61,4 @@ elixir: = link "More information", to: Routes.profile_commission_path(@conn, :show, c.user) - true -> - p We couldn't find any commission listings to display. Sorry! \ No newline at end of file + p We couldn't find any commission listings to display. Sorry!