add created_by connection to instances

integration-tests
Josha von Gizycki 6 years ago
parent c72569ae90
commit 8416789f31

@ -20,8 +20,10 @@
{:uuid schema-uuid}))) {:uuid schema-uuid})))
(neo4j/defquery create-instance (neo4j/defquery create-instance
"MATCH (s:schema {uuid:{schema_uuid}}) "MATCH (s:schema {uuid:{schema_uuid}}),
CREATE (i:instance {uuid:{uuid}})-[:of]->(s) (u:user {uuid:{user_uuid}})
CREATE (i:instance {uuid:{uuid}})-[:of]->(s),
(i)-[:created_by]->(u)
SET i.name = {name}, SET i.name = {name},
i.created_at = {created_at}, i.created_at = {created_at},
i.updated_at = {created_at}") i.updated_at = {created_at}")
@ -35,14 +37,15 @@
p.created_at = {created_at}, p.created_at = {created_at},
p.updated_at = {updated_at}") p.updated_at = {updated_at}")
(defn create! [schema-uuid instance] (defn create! [user-uuid schema-uuid instance]
(let [instance-uuid (neo4j/uuid) (let [instance-uuid (neo4j/uuid)
now (neo4j/now-str) now (neo4j/now-str)
instance-tuple [create-instance instance-tuple [create-instance
{:schema_uuid schema-uuid {:schema_uuid schema-uuid
:name (:name instance) :name (:name instance)
:uuid instance-uuid :uuid instance-uuid
:created_at now}] :created_at now
:user_uuid user-uuid}]
prop-tuples (for [{:keys [attribute value]} (:properties instance)] prop-tuples (for [{:keys [attribute value]} (:properties instance)]
[create-property [create-property
{:uuid instance-uuid {:uuid instance-uuid

@ -21,6 +21,7 @@
(defn new! [req] (defn new! [req]
(let [schema-uuid (get-in req [:params :schema-uuid]) (let [schema-uuid (get-in req [:params :schema-uuid])
user-uuid (get-in req [:session :uuid])
req-attrs (domain-attr/required! schema-uuid) req-attrs (domain-attr/required! schema-uuid)
form-def (forms-inst/with-attributes req-attrs)] form-def (forms-inst/with-attributes req-attrs)]
(if (form/valid? form-def req) (if (form/valid? form-def req)
@ -28,7 +29,8 @@
req-attrs (domain-attr/required! schema-uuid) req-attrs (domain-attr/required! schema-uuid)
instance (forms-inst/form-data->instance form-data instance (forms-inst/form-data->instance form-data
req-attrs)] req-attrs)]
(domain/create! schema-uuid (domain/create! user-uuid
schema-uuid
instance) instance)
(resp/redirect (path :instance-list (resp/redirect (path :instance-list
(:params req)))) (:params req))))

Loading…
Cancel
Save