add markdown as attr type, fix write permissions check

integration-tests
Josha von Gizycki 6 years ago
parent 436ff0a617
commit 1061e6566d

@ -5,10 +5,11 @@
(spec/def ::name
(spec/and string? not-empty))
(def types
#{"string" "date" "file" "markdown" "text"})
(spec/def ::type
(spec/and
string?
#(some (partial = %) ["date" "file", "string" "text"])))
(spec/and string? types))
(spec/def ::required
#(some (partial = %) ["on" nil 0 1 "0" "1"]))

@ -12,8 +12,7 @@
(let [schema-uuid (get-in req [:params :schema])]
(if (form/valid? view-schema/attr-form req)
(do
(domain/create-new!
(:params req)
(domain/create-new! (:params req)
schema-uuid
(get-in req [:session :uuid]))
(resp/redirect (path :schema-show {:uuid schema-uuid})))

@ -72,19 +72,7 @@
(resp/redirect (path :schema-show (:params req)))
:flash ["No write permission for schema"])))))
(defroutes routes
(GET "/403" [] {:status 403 :body "NE"})
(GET (register! :schema-overview "/schema")
[]
view-schema/overview!)
(GET (register! :schema-show "/schema/:uuid")
[uuid :as req]
(view! uuid req))
(POST (register! :schema-new "/schema/new")
[]
new!)
(wrap-allowed-to-write
(comp/routes
(defroutes write-routes
(POST (register! :schema-edit "/schema/edit") []
edit!)
(POST (register! :schema-assign-users "/schema/assign/users") []
@ -93,4 +81,15 @@
assign-schemas!)
(DELETE (register! :schema-delete "/schema/:uuid")
[uuid :as req]
(delete-schema! uuid (:session req))))))
(delete-schema! uuid (:session req))))
(defroutes routes
(GET (register! :schema-overview "/schema") []
view-schema/overview!)
(GET (register! :schema-show "/schema/:uuid")
[uuid :as req]
(view! uuid req))
(POST (register! :schema-new "/schema/new") []
new!)
(comp/wrap-routes write-routes
wrap-allowed-to-write))

@ -1,5 +1,6 @@
(ns wanijo.schema.view
(:require [hiccup.form :as hform]
(:require [clojure.string :refer [capitalize]]
[hiccup.form :as hform]
[ring.util.anti-forgery :refer [anti-forgery-field]]
[formulare.core :as form]
[wanijo.framework.view :as view]
@ -21,10 +22,8 @@
:type {:label "Type"
:required true
:spec ::attr-domain/type
:options [["String" "string"]
["Text" "text"]
["Date" "date"]
["File" "file"]]}
:options (map #(vector (capitalize %) %)
attr-domain/types)}
:required {:label "Required"
:required false
:spec ::attr-domain/required

Loading…
Cancel
Save