|
|
|
@ -107,6 +107,11 @@
|
|
|
|
|
(resp/redirect (path :instance-edit-form {:uuid uuid})))
|
|
|
|
|
(route-link-selection! uuid schema-uuid req))))
|
|
|
|
|
|
|
|
|
|
(comment
|
|
|
|
|
(form/valid? (link-form! "6e7009e3-724b-4fce-afe0-7cf50f0bfcff")
|
|
|
|
|
{:params {:name "link-name"
|
|
|
|
|
:instances ["4bb90cc3-54d1-4d7d-bc30-c357777613ef"]}}))
|
|
|
|
|
|
|
|
|
|
(defn route-delete-link! [uuid link-uuid]
|
|
|
|
|
(domain-link/delete! link-uuid)
|
|
|
|
|
(resp/redirect (path :instance-edit-form {:uuid uuid})))
|
|
|
|
@ -141,14 +146,14 @@
|
|
|
|
|
(let [names (-> req :params :name)
|
|
|
|
|
instances (-> req :params :instances)
|
|
|
|
|
source-uuid (-> req :params :source-uuid)]
|
|
|
|
|
; (clojure.pprint/pprint names)
|
|
|
|
|
; (clojure.pprint/pprint instances)
|
|
|
|
|
; (clojure.pprint/pprint source-uuid)
|
|
|
|
|
#_ (clojure.pprint/pprint
|
|
|
|
|
(map (fn [[target-schema target-instances]]
|
|
|
|
|
{:link-name (get names target-schema)
|
|
|
|
|
:instances target-instances})
|
|
|
|
|
instances)))
|
|
|
|
|
; (clojure.pprint/pprint names)
|
|
|
|
|
; (clojure.pprint/pprint instances)
|
|
|
|
|
; (clojure.pprint/pprint source-uuid)
|
|
|
|
|
#_ (clojure.pprint/pprint
|
|
|
|
|
(map (fn [[target-schema target-instances]]
|
|
|
|
|
{:link-name (get names target-schema)
|
|
|
|
|
:instances target-instances})
|
|
|
|
|
instances)))
|
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
|
|
|
|
|
|
(defn schema-uuid-by-instance [req]
|
|
|
|
@ -161,82 +166,82 @@
|
|
|
|
|
|
|
|
|
|
(def linking-routes
|
|
|
|
|
(-> (compojure/routes
|
|
|
|
|
(GET (register! :instance-link-selection
|
|
|
|
|
(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-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)))
|
|
|
|
|
(route-create-link! uuid schema-uuid req)))
|
|
|
|
|
(wrap-routes
|
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
|
#(get-in % [:params :schema-uuid])))
|
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
|
#(get-in % [:params :schema-uuid])))
|
|
|
|
|
(wrap-routes
|
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
|
schema-uuid-by-instance))))
|
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
|
schema-uuid-by-instance))))
|
|
|
|
|
|
|
|
|
|
(def writing-routes-with-uuid-in-path
|
|
|
|
|
(wrap-routes
|
|
|
|
|
(compojure/routes
|
|
|
|
|
(GET (register! :instance-edit-form "/instance/:uuid/edit")
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
(route-edit-form! uuid req))
|
|
|
|
|
(POST (register! :instance-edit "/instance/:uuid")
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
(route-edit! uuid req))
|
|
|
|
|
(DELETE (register! :instance-delete "/instance/:uuid")
|
|
|
|
|
[uuid]
|
|
|
|
|
(route-delete! uuid))
|
|
|
|
|
(DELETE (register! :instance-link-delete
|
|
|
|
|
"/instance/:uuid/link/:link-uuid")
|
|
|
|
|
[uuid link-uuid]
|
|
|
|
|
(route-delete-link! uuid link-uuid))
|
|
|
|
|
(POST (register! :instance-mark-starred
|
|
|
|
|
(compojure/routes
|
|
|
|
|
(GET (register! :instance-edit-form "/instance/:uuid/edit")
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
(route-edit-form! uuid req))
|
|
|
|
|
(POST (register! :instance-edit "/instance/:uuid")
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
(route-edit! uuid req))
|
|
|
|
|
(DELETE (register! :instance-delete "/instance/:uuid")
|
|
|
|
|
[uuid]
|
|
|
|
|
(route-delete! uuid))
|
|
|
|
|
(DELETE (register! :instance-link-delete
|
|
|
|
|
"/instance/:uuid/link/:link-uuid")
|
|
|
|
|
[uuid link-uuid]
|
|
|
|
|
(route-delete-link! uuid link-uuid))
|
|
|
|
|
(POST (register! :instance-mark-starred
|
|
|
|
|
"/instance/:uuid/starred")
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
(route-mark-starred! uuid req))
|
|
|
|
|
(DELETE (register! :instance-remove-starred
|
|
|
|
|
"/instance/:uuid/starred")
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
(route-mark-starred! uuid req))
|
|
|
|
|
(DELETE (register! :instance-remove-starred
|
|
|
|
|
"/instance/:uuid/starred")
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
(route-remove-starred! uuid req))
|
|
|
|
|
(GET (register! :instance-bulk-link-selection "/instance/:uuid/bulk-link")
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
(route-bulk-link-selection! uuid req))
|
|
|
|
|
(POST (register! :instance-bulk-link-create "/instance/:uuid/bulk-link")
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
(route-create-bulk-link! uuid req)))
|
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
|
schema-uuid-by-instance)))
|
|
|
|
|
(route-remove-starred! uuid req))
|
|
|
|
|
(GET (register! :instance-bulk-link-selection "/instance/:uuid/bulk-link")
|
|
|
|
|
[uuid :as req]
|
|
|
|
|
(route-bulk-link-selection! uuid req))
|
|
|
|
|
(POST (register! :instance-bulk-link-create "/instance/:uuid/bulk-link")
|
|
|
|
|
[uuid :as 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))
|
|
|
|
|
(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))
|
|
|
|
|
(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))
|
|
|
|
|
(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
|
|
|
|
|
;; 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)))
|
|
|
|
|