   (:require [environ.core :refer [env]]
             [ring.util.response :refer :all]
             [hiccup.core :refer :all]
+            [clojure.tools.logging :as log]
             [clj-money.util :refer [format-number]]
             [clj-money.web.shared :refer :all]
             [clj-money.validation :as validation]

  (let [result (commodities/update (env :db)
                                   (select-keys
                                     params
                                     [:id :name :symbol :exchange]))]
    (if (validation/has-error? result)
      (edit {} result)
      (redirect (format "/entities/%s/commodities" (:entity-id result))))))

  (html
    [:div.row
     [:div.col-sm-6
      (select-field commodity :type (options-for-select [:currency :stock] name identity))]
     [:div.col-sm-6
      (select-field commodity :exchange (options-for-select commodities/exchanges name identity))]]
    [:div.row
     [:div.col-sm-6
      (text-input-field commodity :name {:autofocus true})]
     [:div.col-sm-6
      (text-input-field commodity :symbol)]]
    [:input.btn.btn-primary {:type :submit
                             :value "Save"
                             :title "Click here to save this commodity"}]
