|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
(ns wanijo.attribute.routes
|
|
|
|
|
(:require [compojure.core :refer [defroutes GET POST DELETE]]
|
|
|
|
|
(:require [compojure.core :refer [defroutes GET POST DELETE] :as comp]
|
|
|
|
|
[clojure.pprint :refer [pprint]]
|
|
|
|
|
[ring.util.response :as resp]
|
|
|
|
|
[formulare.core :as form]
|
|
|
|
|
[wanijo.framework.routing :refer [register! path]]
|
|
|
|
@ -31,9 +32,16 @@
|
|
|
|
|
(domain/delete-by-uuid! uuid)
|
|
|
|
|
(resp/redirect (path :schema-show {:uuid (get-in req [:params :schema])})))
|
|
|
|
|
|
|
|
|
|
(defroutes routes
|
|
|
|
|
(POST (register! :attribute-new "/attribute/new")
|
|
|
|
|
[]
|
|
|
|
|
(defn wrap-allowed-to-write []
|
|
|
|
|
(schema-routes/write-permission-middleware
|
|
|
|
|
#(or (get-in % [:params :schema])
|
|
|
|
|
(get-in % [:route-params :schema])
|
|
|
|
|
(-> (get-in % [:route-params :uuid])
|
|
|
|
|
(domain/schema-of!)
|
|
|
|
|
:uuid))))
|
|
|
|
|
|
|
|
|
|
(defroutes write-routes
|
|
|
|
|
(POST (register! :attribute-new "/attribute/new") []
|
|
|
|
|
new!)
|
|
|
|
|
(POST (register! :attribute-edit "/attribute/edit/:schema")
|
|
|
|
|
[schema :as req]
|
|
|
|
@ -41,3 +49,7 @@
|
|
|
|
|
(DELETE (register! :attribute-delete "/attribute/:uuid/delete")
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
(delete! uuid req)))
|
|
|
|
|
|
|
|
|
|
(defroutes routes
|
|
|
|
|
(comp/wrap-routes write-routes
|
|
|
|
|
(wrap-allowed-to-write)))
|
|
|
|
|