|
|
@ -1,6 +1,7 @@
|
|
|
|
(ns wanijo.instance.routes
|
|
|
|
(ns wanijo.instance.routes
|
|
|
|
(:require [compojure.core :refer [defroutes wrap-routes
|
|
|
|
(:require [compojure.core :refer [defroutes wrap-routes
|
|
|
|
GET POST DELETE]]
|
|
|
|
GET POST DELETE]
|
|
|
|
|
|
|
|
:as compojure]
|
|
|
|
[ring.util.response :as resp]
|
|
|
|
[ring.util.response :as resp]
|
|
|
|
[formulare.core :as form]
|
|
|
|
[formulare.core :as form]
|
|
|
|
[wanijo.instance.view
|
|
|
|
[wanijo.instance.view
|
|
|
@ -150,18 +151,34 @@
|
|
|
|
instances)))
|
|
|
|
instances)))
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
|
|
|
|
|
|
|
|
(defroutes routes
|
|
|
|
(defn schema-uuid-by-instance [req]
|
|
|
|
|
|
|
|
(-> (get-in req [:params :schema-uuid])
|
|
|
|
|
|
|
|
(domain-schema/find-by-instance!)
|
|
|
|
|
|
|
|
:uuid))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn schema-uuid-from-params [req]
|
|
|
|
|
|
|
|
(get-in req [:params :schema-uuid]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(def linking-routes
|
|
|
|
|
|
|
|
(-> (compojure/routes
|
|
|
|
|
|
|
|
(GET (register! :instance-link-selection
|
|
|
|
|
|
|
|
"/instance/:uuid/link/:schema-uuid")
|
|
|
|
|
|
|
|
[uuid schema-uuid :as req]
|
|
|
|
|
|
|
|
(route-link-selection! uuid schema-uuid req))
|
|
|
|
|
|
|
|
(POST (register! :instance-link-create
|
|
|
|
|
|
|
|
"/instance/:uuid/link/:schema-uuid")
|
|
|
|
|
|
|
|
[uuid schema-uuid :as req]
|
|
|
|
|
|
|
|
(route-create-link! uuid schema-uuid req)))
|
|
|
|
(wrap-routes
|
|
|
|
(wrap-routes
|
|
|
|
(GET (register! :instance-list "/instance/list/:schema-uuid")
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
[schema-uuid :as req]
|
|
|
|
|
|
|
|
(route-list! schema-uuid req))
|
|
|
|
|
|
|
|
(middleware-schema/wrap-allowed-to-read!
|
|
|
|
|
|
|
|
#(get-in % [:params :schema-uuid])))
|
|
|
|
#(get-in % [:params :schema-uuid])))
|
|
|
|
(POST (register! :instance-new "/instance/new") []
|
|
|
|
(wrap-routes
|
|
|
|
route-new!)
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
(GET (register! :instance-show "/instance/:uuid")
|
|
|
|
schema-uuid-by-instance))))
|
|
|
|
[uuid :as req]
|
|
|
|
|
|
|
|
(route-show! uuid req))
|
|
|
|
(def writing-routes-with-uuid-in-path
|
|
|
|
|
|
|
|
(wrap-routes
|
|
|
|
|
|
|
|
(compojure/routes
|
|
|
|
(GET (register! :instance-edit-form "/instance/:uuid/edit")
|
|
|
|
(GET (register! :instance-edit-form "/instance/:uuid/edit")
|
|
|
|
[uuid :as req]
|
|
|
|
[uuid :as req]
|
|
|
|
(route-edit-form! uuid req))
|
|
|
|
(route-edit-form! uuid req))
|
|
|
@ -171,14 +188,6 @@
|
|
|
|
(DELETE (register! :instance-delete "/instance/:uuid")
|
|
|
|
(DELETE (register! :instance-delete "/instance/:uuid")
|
|
|
|
[uuid]
|
|
|
|
[uuid]
|
|
|
|
(route-delete! uuid))
|
|
|
|
(route-delete! uuid))
|
|
|
|
(GET (register! :instance-link-selection
|
|
|
|
|
|
|
|
"/instance/:uuid/link/:schema-uuid")
|
|
|
|
|
|
|
|
[uuid schema-uuid :as req]
|
|
|
|
|
|
|
|
(route-link-selection! uuid schema-uuid req))
|
|
|
|
|
|
|
|
(POST (register! :instance-link-create
|
|
|
|
|
|
|
|
"/instance/:uuid/link/:schema-uuid")
|
|
|
|
|
|
|
|
[uuid schema-uuid :as req]
|
|
|
|
|
|
|
|
(route-create-link! uuid schema-uuid req))
|
|
|
|
|
|
|
|
(DELETE (register! :instance-link-delete
|
|
|
|
(DELETE (register! :instance-link-delete
|
|
|
|
"/instance/:uuid/link/:link-uuid")
|
|
|
|
"/instance/:uuid/link/:link-uuid")
|
|
|
|
[uuid link-uuid]
|
|
|
|
[uuid link-uuid]
|
|
|
@ -191,12 +200,43 @@
|
|
|
|
"/instance/:uuid/starred")
|
|
|
|
"/instance/:uuid/starred")
|
|
|
|
[uuid :as req]
|
|
|
|
[uuid :as req]
|
|
|
|
(route-remove-starred! uuid req))
|
|
|
|
(route-remove-starred! uuid req))
|
|
|
|
(GET (register! :instance-list-starred "/instance/starred/list")
|
|
|
|
|
|
|
|
[:as req]
|
|
|
|
|
|
|
|
(route-list-starred! req))
|
|
|
|
|
|
|
|
(GET (register! :instance-bulk-link-selection "/instance/:uuid/bulk-link")
|
|
|
|
(GET (register! :instance-bulk-link-selection "/instance/:uuid/bulk-link")
|
|
|
|
[uuid :as req]
|
|
|
|
[uuid :as req]
|
|
|
|
(route-bulk-link-selection! uuid req))
|
|
|
|
(route-bulk-link-selection! uuid req))
|
|
|
|
(POST (register! :instance-bulk-link-create "/instance/:uuid/bulk-link")
|
|
|
|
(POST (register! :instance-bulk-link-create "/instance/:uuid/bulk-link")
|
|
|
|
[uuid :as req]
|
|
|
|
[uuid :as req]
|
|
|
|
(route-create-bulk-link! uuid req)))
|
|
|
|
(route-create-bulk-link! uuid req)))
|
|
|
|
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
|
|
|
|
schema-uuid-by-instance)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defroutes routes
|
|
|
|
|
|
|
|
;; read routes with :schema-uuid
|
|
|
|
|
|
|
|
(wrap-routes
|
|
|
|
|
|
|
|
(compojure/routes
|
|
|
|
|
|
|
|
(GET (register! :instance-list "/instance/list/:schema-uuid")
|
|
|
|
|
|
|
|
[schema-uuid :as req]
|
|
|
|
|
|
|
|
(route-list! schema-uuid req)))
|
|
|
|
|
|
|
|
(middleware-schema/wrap-allowed-to-read!
|
|
|
|
|
|
|
|
schema-uuid-from-params))
|
|
|
|
|
|
|
|
(wrap-routes
|
|
|
|
|
|
|
|
(compojure/routes
|
|
|
|
|
|
|
|
(GET (register! :instance-show "/instance/:uuid")
|
|
|
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
|
|
|
(route-show! uuid req)))
|
|
|
|
|
|
|
|
(middleware-schema/wrap-allowed-to-read!
|
|
|
|
|
|
|
|
schema-uuid-by-instance))
|
|
|
|
|
|
|
|
(wrap-routes
|
|
|
|
|
|
|
|
(compojure/routes
|
|
|
|
|
|
|
|
(POST (register! :instance-new "/instance/new") []
|
|
|
|
|
|
|
|
route-new!))
|
|
|
|
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
|
|
|
|
schema-uuid-from-params))
|
|
|
|
|
|
|
|
linking-routes
|
|
|
|
|
|
|
|
writing-routes-with-uuid-in-path
|
|
|
|
|
|
|
|
(GET (register! :instance-list-starred "/instance/starred/list")
|
|
|
|
|
|
|
|
[:as req]
|
|
|
|
|
|
|
|
;; at some point someone will star an instance and then permissions to
|
|
|
|
|
|
|
|
;; the schema will be revoked
|
|
|
|
|
|
|
|
;; the instances will still be visible but can't be opened anymore
|
|
|
|
|
|
|
|
;; because of missing permissions, so they can't be unstared anymore
|
|
|
|
|
|
|
|
(route-list-starred! req)))
|
|
|
|