mirror of
https://github.com/penpot/penpot.git
synced 2025-05-13 01:26:37 +02:00
✨ Adds commands to load data into user
This commit is contained in:
parent
8403352af8
commit
2e7f90f3cc
2 changed files with 47 additions and 29 deletions
|
@ -76,10 +76,14 @@
|
||||||
(tr/decode-stream input))))
|
(tr/decode-stream input))))
|
||||||
|
|
||||||
(defn create-profile-initial-data
|
(defn create-profile-initial-data
|
||||||
[conn profile]
|
([conn profile]
|
||||||
(when-let [initial-data-path (:initial-data-file cfg/config)]
|
(when-let [initial-data-path (:initial-data-file cfg/config)]
|
||||||
(when-let [{:keys [file file-library-rel file-media-object]} (read-initial-data initial-data-path)]
|
(create-profile-initial-data conn initial-data-path profile)))
|
||||||
|
|
||||||
|
([conn file profile]
|
||||||
|
(when-let [{:keys [file file-library-rel file-media-object]} (read-initial-data file)]
|
||||||
(let [sample-project-name (:initial-data-project-name cfg/config "Penpot Onboarding")
|
(let [sample-project-name (:initial-data-project-name cfg/config "Penpot Onboarding")
|
||||||
|
|
||||||
proj (projects/create-project conn {:profile-id (:id profile)
|
proj (projects/create-project conn {:profile-id (:id profile)
|
||||||
:team-id (:default-team-id profile)
|
:team-id (:default-team-id profile)
|
||||||
:name sample-project-name})
|
:name sample-project-name})
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.pages.migrations :as pmg]
|
[app.common.pages.migrations :as pmg]
|
||||||
|
[app.config :as cfg]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.db.profile-initial-data :as pid]
|
[app.db.profile-initial-data :as pid]
|
||||||
[app.main :refer [system]]
|
[app.main :refer [system]]
|
||||||
|
[app.rpc.queries.profile :as prof]
|
||||||
[app.srepl.dev :as dev]
|
[app.srepl.dev :as dev]
|
||||||
[app.util.blob :as blob]
|
[app.util.blob :as blob]
|
||||||
[clojure.pprint :refer [pprint]]))
|
[clojure.pprint :refer [pprint]]))
|
||||||
|
@ -58,3 +60,15 @@
|
||||||
([system project-id path]
|
([system project-id path]
|
||||||
(db/with-atomic [conn (:app.db/pool system)]
|
(db/with-atomic [conn (:app.db/pool system)]
|
||||||
(pid/create-initial-data-dump conn project-id path))))
|
(pid/create-initial-data-dump conn project-id path))))
|
||||||
|
|
||||||
|
(defn load-data-into-user
|
||||||
|
([system user-email]
|
||||||
|
(if-let [file (:initial-data-file cfg/config)]
|
||||||
|
(load-data-into-user system file user-email)
|
||||||
|
(prn "Data file not found in configuration")))
|
||||||
|
|
||||||
|
([system file user-email]
|
||||||
|
(db/with-atomic [conn (:app.db/pool system)]
|
||||||
|
(let [profile (prof/retrieve-profile-data-by-email conn user-email)
|
||||||
|
profile (merge profile (prof/retrieve-additional-data conn (:id profile)))]
|
||||||
|
(pid/create-profile-initial-data conn file profile)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue