Skip to content

Commit

Permalink
Enable the skeleton of "Create Activity"
Browse files Browse the repository at this point in the history
- add the new locations into Datomic location schema
- add the new session schemas
  - signup
  - ticket-required?
  - published?
  • Loading branch information
humorless committed Jul 20, 2024
1 parent 514327f commit c02bea5
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 12 deletions.
19 changes: 18 additions & 1 deletion src/co/gaiwan/compass/db/data.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,26 @@
(defn locations []
[{:location/name "Het Depot"
:db/ident :location.type/depot}
{:location/name "Het Depot - main stage"
:db/ident :location.type/depot-main-stage}
{:location/name "Het Depot - Bar"
:db/ident :location.type/depot-bar}
{:location/name "Hal 5"
:db/ident :location.type/hal5}
])
{:location/name "Hal 5 - zone A"
:db/ident :location.type/hal5-zone-a}
{:location/name "Hal 5 - zone B"
:db/ident :location.type/hal5-zone-b}
{:location/name "Hal 5 - HoC Café"
:db/ident :location.type/hal5-hoc-cafe}
{:location/name "Hal 5 - Foodcourt"
:db/ident :location.type/hal5-foodcourt}
{:location/name "Hal 5 - park"
:db/ident :location.type/hal5-park}
{:location/name "Hal 5 - outside seating"
:db/ident :location.type/hal5-outside-seating}
{:location/name "Hal 5 - long table"
:db/ident :location.type/hal5-long-table}])

(defn session-types []
[{:session.type/name "Talk"
Expand Down
3 changes: 3 additions & 0 deletions src/co/gaiwan/compass/db/schema.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
[:session/location :ref "Where does the session take place"]
[:session/image :string "Image URL, either absolute, or relative to compass root"]
[:session/capacity :long "Number of people that are able to join this session"]
[:session/signup :long "Number of people that are currently signing up this session"]
[:session/ticket-required? :boolean "If this session requires a ticket"]
[:session/published? :boolean "If this session is published/visible?"]

[:session.type/name :string "Type of session, e.g. talk, activity"]
[:session.type/color :string "CSS color or var reference used for rendering"]
Expand Down
12 changes: 4 additions & 8 deletions src/co/gaiwan/compass/html/sessions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,13 @@
[:div
[:label {:for "type"} "Type"]
[:select {:id "type" :name "type"}
[:option {:value "talk"} "talk"]
[:option {:value "workshop"} "workshop"]
[:option {:value "keynote"} "keynote"]
[:option {:value "office-hours"} "office-hours"]
[:option {:value "session"} "session"]]]
[:option {:value "activity"} "activity"]]]

[:div
[:label {:for "location"} "Location"]
[:select {:id "location" :name "location"}
[:option {:value "depot-main-stage"} "Het Depot - main stage"]
[:option {:value "depot-baar"} "Het Depot - Bar"]
[:option {:value "depot-bar"} "Het Depot - Bar"]
[:option {:value "hal5-zone-a"} "Hal 5 - zone A"]
[:option {:value "hal5-zone-b"} "Hal 5 - zone B"]
[:option {:value "hal5-hoc-cafe"} "Hal 5 - HoC Café"]
Expand All @@ -114,8 +110,8 @@
[:textarea {:id "description" :name "description"}]]

[:div
[:label {:for "requires_ticket"} "Requires Ticket?"]
[:input {:id "requires_ticket" :name "requires-ticket?" :type "checkbox"}]]
[:label {:for "ticket"} "Requires Ticket?"]
[:input {:id "ticket" :name "ticket-required?" :type "checkbox"}]]

[:div
[:label {:for "published"} "Published/Visible?"]
Expand Down
26 changes: 23 additions & 3 deletions src/co/gaiwan/compass/routes/sessions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,36 @@
{:html/head [:title "Create new session"]
:html/body [h/session-form {}]}))

(defn params->session-data
"convert the Http Post Params to data ready for DB transaction"
[{:keys [name description
type location
capacity
ticket-required? published?]}]
(cond-> {:session/title name
:session/description description
:session/type (keyword "session.type" type)
:session/location (keyword "location.type" location)
:session/capacity (Integer/parseInt capacity)}
(= ticket-required? "on")
(assoc :session/ticket-required? true)
(= published? "on")
(assoc :session/published? true)))

(defn save-session
"Save session to Datomic
The typical params is:
{:name \"dsafa\", :type \"talk\",
:location \"depot-main-stage\", :capacity \"34\",
:description \"dsafa\", :requires-ticket? \"on\"
{:name \"dsafa\",
:description \"dsafa\",
:type \"activity\",
:location \"depot-main-stage\",
:capacity \"34\",
:ticket-required? \"on\"
:published? \"on\"}"
[{:keys [params]}]
;; TODO save to datomic
(db/transact [(params->session-data params)])
{:html/body [:p "OK " (pr-str params)]})

(defn routes []
Expand Down

0 comments on commit c02bea5

Please sign in to comment.