             [hiccup
              [core :refer [h]]
              [form :as form]]
+            [org.tobereplaced.nio.file :as nio.file]
             [ring.util
              [anti-forgery :refer [anti-forgery-field]]
              [response :as response]]

     ["Braille" :braille]]
    selected)])

(defn custom-form [request year issue]
  (let [identity (friend/identity request)]
    (layout/common
     identity
     year issue
     [:h1 "Katalog nach Mass"]
     (form/form-to
      {:enctype "multipart/form-data"}
      [:post (format "/%s/%s/custom-confirm" year issue)]
      (anti-forgery-field)
      (form/file-upload "file")
      (query-field nil)
      (customer-field nil)
      (format-field :pdf)
     (form/submit-button {:class "btn btn-default"} "Submit")))))

(defn custom-confirm [request year issue query customer fmt file]
  (let [{tempfile :tempfile} file
        path (.getPath tempfile)
        items (vubis/read-file path)
        items-collated (vubis/collate-all-duplicate-items items)
        checker (s/checker validation/CatalogItem)
        problems (keep #(when-let [error (checker %)] [error %]) items-collated)]
    (if (seq problems)
      (let [identity (friend/identity request)]
        (layout/common
         identity
         year issue
         [:h1 "Confirm Katalog nach Mass"]
         (error-table problems)
         (form/form-to
          {:enctype "multipart/form-data"}
          [:post (format "/%s/%s/custom" year issue)]
          (anti-forgery-field)
          (form/hidden-field "items" (prn-str items))
          (query-field query)
          (customer-field customer)
          (format-field fmt)
          (form/submit-button "Upload Anyway"))))
      (do
        ;; FIXME: add the file
        ;; and redirect to the index
        (response/redirect-after-post (format "/%s/%s" year issue))))))

(defmulti custom (fn [_ _ _ _ _ fmt _] fmt))


      [:div.col-md-6
       (upload-well "Upload Gesamtkatalog Hörfilm"
                    (format "/%s/%s/%s/upload-confirm" year issue (name :hörfilm))
                    (:hörfilm errors))]
      [:div.col-md-6
       (upload-well "Upload Gesamtkatalog Spiele"
                    (format "/%s/%s/%s/upload-confirm" year issue (name :ludo))
                    (:ludo errors))]]
     [:div.row
      [:div.col-md-6
       (upload-well "Upload Gesamtkatalog Taktile Bücher"
                    (format "/%s/%s/%s/upload-confirm" year issue (name :taktilesbuch))
                    (:taktilesbuch errors))]])))

(defn editorial-form [request fmt year issue]
  (let [identity (friend/identity request)
