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/def ::name
(spec/and string? not-empty)) (spec/and string? not-empty))
(def types
#{"string" "date" "file" "markdown" "text"})
(spec/def ::type (spec/def ::type
(spec/and (spec/and string? types))
string?
#(some (partial = %) ["date" "file", "string" "text"])))
(spec/def ::required (spec/def ::required
#(some (partial = %) ["on" nil 0 1 "0" "1"])) #(some (partial = %) ["on" nil 0 1 "0" "1"]))

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

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

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

Loading…
Cancel
Save