diff --git a/repl-sessions/db.clj b/repl-sessions/db.clj index c9279f9..0330e09 100644 --- a/repl-sessions/db.clj +++ b/repl-sessions/db.clj @@ -14,12 +14,29 @@ (db/transact [[:db/retractEntity 17592186045468]])) (user/conn) +(db/transact [{:user/email "aa@gmail.com" + :user/handle "laurence.chen" + :user/name "Laurence"}]) + +(db/q + '[:find + [(pull ?e [*]) ...] + :where + [?e :user/email]] + (db/db)) + +(def session-eid 17592186045438) + +(db/transact [{:db/id session-eid + :session/participants 17592186045458}]) + +(first (:session/participants (db/entity session-eid))) ;; Test transact participants (def req {:identity {:user/email "ddd"} - :path-params {:id "17592186045455"}}) + :path-params {:id "17592186045438"}}) -(def session-eid 17592186045455) +(def session-eid 17592186045438) @(db/transact [[:db/add session-eid :session/capacity 14] [:db/add session-eid :session/signup 0]]) diff --git a/src/co/gaiwan/compass/html/sessions.clj b/src/co/gaiwan/compass/html/sessions.clj index 1f2958a..1e93c09 100644 --- a/src/co/gaiwan/compass/html/sessions.clj +++ b/src/co/gaiwan/compass/html/sessions.clj @@ -64,7 +64,7 @@ :hx-select (str "." session-card) :hx-swap "outerHTML" :on-click "event.stopPropagation()" - :hx-indicator (str ".c" (:db/id session)) } + :hx-indicator (str ".c" (:db/id session))} (if (session/participating? session user) "Leave" "Participate")] @@ -130,8 +130,9 @@ #_[:p.host "Organized by " organized]]])) (o/defstyled attendee :li - ([{:user/keys [name email handle uuid]}] - handle)) + ([{:db/keys [id]}] + (let [{:user/keys [name]} (session/attendee id)] + name))) (o/defstyled session-detail :div [capacity-gauge :w-100px] @@ -163,14 +164,13 @@ [:div "Location "] [:div (:location/name location)]] [:div.capacity - [:div "Location capacity:"] - [:div capacity]] - [:div.signup-count - [:div "Current Signup:"] - [:div signup-count]] - [:div.participants - [:div "Participants:"] - [:ol (map attendee participants)]] + [:div "Spots available:"] + [:div (- (or capacity 0) (or signup-count 0))]] + (when (session/organizing? organized user) + ;; Only show the participants' list to organizer. + [:div.participants + [:div "Participants:"] + [:ol (map attendee participants)]]) (when (:session/ticket-required? session) [:p "Required Ticket"]) [:div.actions @@ -184,6 +184,7 @@ "Leave"] [:button "Edit"]] #_[:p.host "Organized by " organized] + #_[:p (pr-str user)] #_[:p (pr-str session)]]])) (o/defstyled session-list :section#sessions diff --git a/src/co/gaiwan/compass/model/session.clj b/src/co/gaiwan/compass/model/session.clj index 645bfd6..d12f307 100644 --- a/src/co/gaiwan/compass/model/session.clj +++ b/src/co/gaiwan/compass/model/session.clj @@ -1,5 +1,15 @@ -(ns co.gaiwan.compass.model.session) +(ns co.gaiwan.compass.model.session + (:require + [co.gaiwan.compass.db :as db])) (defn participating? [session user] (some (comp #{(:db/id user)} :db/id) (:session/participants session))) + +(defn organizing? [organized user] + (and + (some? organized) + (= (:db/id user) (:db/id organized)))) + +(defn attendee [id] + (db/entity id))