|
|
@ -39,8 +39,8 @@
|
|
|
|
instance (forms-inst/form-data->instance form-data
|
|
|
|
instance (forms-inst/form-data->instance form-data
|
|
|
|
req-attrs)]
|
|
|
|
req-attrs)]
|
|
|
|
(db/create! user-uuid
|
|
|
|
(db/create! user-uuid
|
|
|
|
schema-uuid
|
|
|
|
schema-uuid
|
|
|
|
instance)
|
|
|
|
instance)
|
|
|
|
(resp/redirect (path :instance-list
|
|
|
|
(resp/redirect (path :instance-list
|
|
|
|
(:params req))))
|
|
|
|
(:params req))))
|
|
|
|
(route-list! schema-uuid req))))
|
|
|
|
(route-list! schema-uuid req))))
|
|
|
@ -53,7 +53,7 @@
|
|
|
|
instance (assoc (instance! uuid)
|
|
|
|
instance (assoc (instance! uuid)
|
|
|
|
:starred
|
|
|
|
:starred
|
|
|
|
(db/is-starred! uuid
|
|
|
|
(db/is-starred! uuid
|
|
|
|
user-uuid))]
|
|
|
|
user-uuid))]
|
|
|
|
(show instance
|
|
|
|
(show instance
|
|
|
|
(domain-schema/accessible-schemas! user-uuid)
|
|
|
|
(domain-schema/accessible-schemas! user-uuid)
|
|
|
|
req)))
|
|
|
|
req)))
|
|
|
@ -71,7 +71,7 @@
|
|
|
|
(comment
|
|
|
|
(comment
|
|
|
|
(forms-inst/with-attributes
|
|
|
|
(forms-inst/with-attributes
|
|
|
|
(db-attr/find-by-instance!
|
|
|
|
(db-attr/find-by-instance!
|
|
|
|
"def4dacb-979f-4a0d-b1d6-535ac2a3f94b")))
|
|
|
|
"def4dacb-979f-4a0d-b1d6-535ac2a3f94b")))
|
|
|
|
|
|
|
|
|
|
|
|
(defn route-edit! [uuid req]
|
|
|
|
(defn route-edit! [uuid req]
|
|
|
|
(let [attrs (db-attr/find-by-instance! uuid)
|
|
|
|
(let [attrs (db-attr/find-by-instance! uuid)
|
|
|
@ -79,9 +79,7 @@
|
|
|
|
(if (form/valid? form-def req)
|
|
|
|
(if (form/valid? form-def req)
|
|
|
|
(let [form-data (form/form-data form-def req)
|
|
|
|
(let [form-data (form/form-data form-def req)
|
|
|
|
form-instance (forms-inst/form-data->instance form-data attrs)
|
|
|
|
form-instance (forms-inst/form-data->instance form-data attrs)
|
|
|
|
instance (assoc form-instance :uuid uuid)
|
|
|
|
instance (assoc form-instance :uuid uuid)]
|
|
|
|
_ (clojure.pprint/pprint instance)]
|
|
|
|
|
|
|
|
(clojure.pprint/pprint (files/persist-files! instance))
|
|
|
|
|
|
|
|
(db/edit! instance (domain/to-revision instance))
|
|
|
|
(db/edit! instance (domain/to-revision instance))
|
|
|
|
(resp/redirect (path :instance-show instance)))
|
|
|
|
(resp/redirect (path :instance-show instance)))
|
|
|
|
(route-show! uuid req))))
|
|
|
|
(route-show! uuid req))))
|
|
|
@ -124,12 +122,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
(defn route-mark-starred! [uuid req]
|
|
|
|
(defn route-mark-starred! [uuid req]
|
|
|
|
(db/mark-starred! uuid
|
|
|
|
(db/mark-starred! uuid
|
|
|
|
(-> req :session :uuid))
|
|
|
|
(-> req :session :uuid))
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
|
|
|
|
|
|
|
|
(defn route-remove-starred! [uuid req]
|
|
|
|
(defn route-remove-starred! [uuid req]
|
|
|
|
(db/remove-starred! uuid
|
|
|
|
(db/remove-starred! uuid
|
|
|
|
(-> req :session :uuid))
|
|
|
|
(-> req :session :uuid))
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
|
|
|
|
|
|
|
|
(defn route-list-starred! [req]
|
|
|
|
(defn route-list-starred! [req]
|
|
|
@ -155,11 +153,11 @@
|
|
|
|
; (clojure.pprint/pprint names)
|
|
|
|
; (clojure.pprint/pprint names)
|
|
|
|
; (clojure.pprint/pprint instances)
|
|
|
|
; (clojure.pprint/pprint instances)
|
|
|
|
; (clojure.pprint/pprint source-uuid)
|
|
|
|
; (clojure.pprint/pprint source-uuid)
|
|
|
|
#_ (clojure.pprint/pprint
|
|
|
|
#_(clojure.pprint/pprint
|
|
|
|
(map (fn [[target-schema target-instances]]
|
|
|
|
(map (fn [[target-schema target-instances]]
|
|
|
|
{:link-name (get names target-schema)
|
|
|
|
{:link-name (get names target-schema)
|
|
|
|
:instances target-instances})
|
|
|
|
:instances target-instances})
|
|
|
|
instances)))
|
|
|
|
instances)))
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
(resp/redirect (path :instance-show {:uuid uuid})))
|
|
|
|
|
|
|
|
|
|
|
|
(defn schema-uuid-by-instance [req]
|
|
|
|
(defn schema-uuid-by-instance [req]
|
|
|
@ -174,12 +172,12 @@
|
|
|
|
(-> (compojure/routes
|
|
|
|
(-> (compojure/routes
|
|
|
|
(GET (register! :instance-link-selection
|
|
|
|
(GET (register! :instance-link-selection
|
|
|
|
"/instance/:uuid/link/:schema-uuid")
|
|
|
|
"/instance/:uuid/link/:schema-uuid")
|
|
|
|
[uuid schema-uuid :as req]
|
|
|
|
[uuid schema-uuid :as req]
|
|
|
|
(route-link-selection! uuid schema-uuid req))
|
|
|
|
(route-link-selection! uuid schema-uuid req))
|
|
|
|
(POST (register! :instance-link-create
|
|
|
|
(POST (register! :instance-link-create
|
|
|
|
"/instance/:uuid/link/:schema-uuid")
|
|
|
|
"/instance/:uuid/link/:schema-uuid")
|
|
|
|
[uuid schema-uuid :as req]
|
|
|
|
[uuid schema-uuid :as req]
|
|
|
|
(route-create-link! uuid schema-uuid req)))
|
|
|
|
(route-create-link! uuid schema-uuid req)))
|
|
|
|
(wrap-routes
|
|
|
|
(wrap-routes
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
#(get-in % [:params :schema-uuid])))
|
|
|
|
#(get-in % [:params :schema-uuid])))
|
|
|
@ -191,32 +189,32 @@
|
|
|
|
(wrap-routes
|
|
|
|
(wrap-routes
|
|
|
|
(compojure/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))
|
|
|
|
(POST (register! :instance-edit "/instance/:uuid")
|
|
|
|
(POST (register! :instance-edit "/instance/:uuid")
|
|
|
|
[uuid :as req]
|
|
|
|
[uuid :as req]
|
|
|
|
(route-edit! uuid req))
|
|
|
|
(route-edit! uuid req))
|
|
|
|
(DELETE (register! :instance-delete "/instance/:uuid")
|
|
|
|
(DELETE (register! :instance-delete "/instance/:uuid")
|
|
|
|
[uuid]
|
|
|
|
[uuid]
|
|
|
|
(route-delete! uuid))
|
|
|
|
(route-delete! uuid))
|
|
|
|
(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]
|
|
|
|
(route-delete-link! uuid link-uuid))
|
|
|
|
(route-delete-link! uuid link-uuid))
|
|
|
|
(POST (register! :instance-mark-starred
|
|
|
|
(POST (register! :instance-mark-starred
|
|
|
|
"/instance/:uuid/starred")
|
|
|
|
"/instance/:uuid/starred")
|
|
|
|
[uuid :as req]
|
|
|
|
[uuid :as req]
|
|
|
|
(route-mark-starred! uuid req))
|
|
|
|
(route-mark-starred! uuid req))
|
|
|
|
(DELETE (register! :instance-remove-starred
|
|
|
|
(DELETE (register! :instance-remove-starred
|
|
|
|
"/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-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!
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
schema-uuid-by-instance)))
|
|
|
|
schema-uuid-by-instance)))
|
|
|
|
|
|
|
|
|
|
|
@ -225,29 +223,29 @@
|
|
|
|
(wrap-routes
|
|
|
|
(wrap-routes
|
|
|
|
(compojure/routes
|
|
|
|
(compojure/routes
|
|
|
|
(GET (register! :instance-list "/instance/list/:schema-uuid")
|
|
|
|
(GET (register! :instance-list "/instance/list/:schema-uuid")
|
|
|
|
[schema-uuid :as req]
|
|
|
|
[schema-uuid :as req]
|
|
|
|
(route-list! schema-uuid req)))
|
|
|
|
(route-list! schema-uuid req)))
|
|
|
|
(middleware-schema/wrap-allowed-to-read!
|
|
|
|
(middleware-schema/wrap-allowed-to-read!
|
|
|
|
schema-uuid-from-params))
|
|
|
|
schema-uuid-from-params))
|
|
|
|
(wrap-routes
|
|
|
|
(wrap-routes
|
|
|
|
(compojure/routes
|
|
|
|
(compojure/routes
|
|
|
|
(GET (register! :instance-show "/instance/:uuid")
|
|
|
|
(GET (register! :instance-show "/instance/:uuid")
|
|
|
|
[uuid :as req]
|
|
|
|
[uuid :as req]
|
|
|
|
(route-show! uuid req)))
|
|
|
|
(route-show! uuid req)))
|
|
|
|
(middleware-schema/wrap-allowed-to-read!
|
|
|
|
(middleware-schema/wrap-allowed-to-read!
|
|
|
|
schema-uuid-by-instance))
|
|
|
|
schema-uuid-by-instance))
|
|
|
|
(wrap-routes
|
|
|
|
(wrap-routes
|
|
|
|
(compojure/routes
|
|
|
|
(compojure/routes
|
|
|
|
(POST (register! :instance-new "/instance/new") []
|
|
|
|
(POST (register! :instance-new "/instance/new") []
|
|
|
|
route-new!))
|
|
|
|
route-new!))
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
(middleware-schema/wrap-allowed-to-write!
|
|
|
|
schema-uuid-from-params))
|
|
|
|
schema-uuid-from-params))
|
|
|
|
linking-routes
|
|
|
|
linking-routes
|
|
|
|
writing-routes-with-uuid-in-path
|
|
|
|
writing-routes-with-uuid-in-path
|
|
|
|
(GET (register! :instance-list-starred "/instance/starred/list")
|
|
|
|
(GET (register! :instance-list-starred "/instance/starred/list")
|
|
|
|
[:as req]
|
|
|
|
[:as req]
|
|
|
|
;; at some point someone will star an instance and then permissions to
|
|
|
|
;; at some point someone will star an instance and then permissions to
|
|
|
|
;; the schema will be revoked
|
|
|
|
;; the schema will be revoked
|
|
|
|
;; the instances will still be visible but can't be opened anymore
|
|
|
|
;; the instances will still be visible but can't be opened anymore
|
|
|
|
;; because of missing permissions, so they can't be unstared anymore
|
|
|
|
;; because of missing permissions, so they can't be unstared anymore
|
|
|
|
(route-list-starred! req)))
|
|
|
|
(route-list-starred! req)))
|
|
|
|