                       (authorize :new))))
   ([{{entity :entity} :params} grant]
    (with-layout (format "User grants for entity %s" (:name entity)) {}
+     (when (validation/has-error? grant)
+       [:div.alert.alert-danger
+        (prn-str (validation/error-messages grant))])
      [:div.row
       [:div.col-md-6
        (form (format "/entities/%s/grants" (:id entity)) {}

            [clj-money.validation :as validation]
            [clj-money.inflection :refer [humanize]]
            [clj-money.models.entities :as entities]
            [clj-money.models.grants :as grants])
  (:use [clj-money.web.shared :refer :all]))

(defn- grant-row
  [grant]
  [:tr
   [:td (:email grant)]
   [:td (:email grant)]])

(defn index
  [{{entity :entity} :params}]
  (with-layout (format "User grants for entity %s" (:name entity)) {}
    ; TODO apply scope
    (let [grants (grants/search (env :db) {:entity-id (:id entity)})]
      [:div.row
       [:div.col-md-6
        [:table.table.table-striped

            [:label
             [:input {:type "checkbox"
                      :name (permission-key resource-type action)
                      :checked (grants/has-permission grant resource-type action)
                      :value 1}]
             (humanize action)]])
         grants/actions)]])

