Skip to content

Commit

Permalink
Show locations if they do not have an ident
Browse files Browse the repository at this point in the history
  • Loading branch information
plexus committed Sep 13, 2024
1 parent 088575c commit 27df051
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/co/gaiwan/compass/db/queries.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@

#_(set! *print-namespace-maps* false)

(defn ?resolve-ident
"Maybe resolve ident
We gave some entities idents, which messes up `db/entity`, which thinks you're
dealing with an enum, and 'helpfully' returns a keyword."
[o]
(if (keyword? o)
(db/entity o)
o))

(defn session [id]
(let [e (db/entity id)]
(-> (into {:db/id (:db/id e)} e)
(update :session/type db/entity)
(update :session/location db/entity)
(update :session/type ?resolve-ident)
(update :session/location ?resolve-ident)
(assoc :session/signup-count (count (:session/participants e))))))

(defn all-sessions
Expand Down
6 changes: 4 additions & 2 deletions src/co/gaiwan/compass/routes/sessions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@
duration (str "PT" duration-time "M")]
(cond-> {:db/id "session"
:session/title title
:session/subtitle subtitle
:session/time start
:session/duration duration
:session/description description
:session/type (or (some-> type parse-long) :session.type/activity)
:session/location (or (some-> location parse-long) :location.type/hal5-long-table)
:session/organized (parse-long organizer-id)
:session/capacity (parse-long capacity)}

subtitle
(assoc :session/subtitle subtitle)
(= ticket-required? "on")
(assoc :session/ticket-required? true)
(= published? "on")
Expand All @@ -88,7 +90,7 @@
:ticket-required? \"on\"
:published? \"on\"}"
[{:keys [params]}]
(let [{:keys [tempids]} @(db/transact [(params->session-data params)])]
(let [{:keys [tempids]} @(db/transact [(doto (params->session-data params) prn)])]
(response/redirect ["/sessions" (get tempids "session")]
{:flash "Successfully created!"})))

Expand Down

0 comments on commit 27df051

Please sign in to comment.