Skip to content

Commit

Permalink
Delete session
Browse files Browse the repository at this point in the history
- with `hx-trigger` event to go back the the front page
- with access control
  • Loading branch information
humorless committed Aug 28, 2024
1 parent f16a02d commit 093746b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/co/gaiwan/compass/html/sessions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@
[:div.type (:session.type/name type)]

[:div.details
[:a
{:href "/"
:style {:display "none"}
:hx-trigger (str "session-" (:db/id session) "-deleted from:body")}]
[session-image+guage session user]
[:h3.title title]
[:h3.subtitle subtitle]
Expand Down
11 changes: 7 additions & 4 deletions src/co/gaiwan/compass/routes/sessions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,15 @@
{:status 404
:html/body [:p "Not found."]})))

(defn session-deleted-response [session-eid]
{:location :sessions/index
:hx/trigger (str "session-" session-eid "-deleted")})

(defn DELETE-session [{:keys [path-params identity]}]
(let [session-eid (parse-long (:id path-params))]
;; FIXME: orga should also be able to delete
(when (= (:db/id identity) (-> session-eid db/entity :session/organized :db/id))
@(db/transact [[:db.fn/retractEntity session-eid]])
(response/redirect "/"))))
(when (session/organizing? (db/entity session-eid) identity)
@(db/transact [[:db/retractEntity session-eid]])
(session-deleted-response session-eid))))

(defn session-updated-response [session-eid]
{:location :sessions/index
Expand Down

0 comments on commit 093746b

Please sign in to comment.