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