feat(grfn/bbbg): Allow actually saving checks

Change-Id: I1654631ad4d3ec471a9110b2fd0d03b964c80d1e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4635
Reviewed-by: grfn <grfn@gws.fyi>
Autosubmit: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
This commit is contained in:
Griffin Smith 2021-12-26 10:15:17 -05:00 committed by clbot
parent 800eba4cca
commit a4aa42bbda
2 changed files with 22 additions and 4 deletions

View file

@ -6,6 +6,12 @@
[bbbg.user :as user]
[bbbg.util.core :as u]))
(defn create! [db params]
(db/insert! db :attendee-check
(select-keys params [::attendee/id
::user/id
::attendee-check/last-dose-at])))
(defn attendees-with-last-checks
[db attendees]
(when (seq attendees)

View file

@ -1,14 +1,16 @@
(ns bbbg.handlers.attendee-checks
(:require
[bbbg.attendee :as attendee]
[bbbg.attendee-check :as attendee-check]
[bbbg.db :as db]
[bbbg.db.attendee-check :as db.attendee-check]
[bbbg.handlers.core :refer [page-response wrap-auth-required]]
[bbbg.user :as user]
[bbbg.util.display :refer [format-date]]
[compojure.coercions :refer [as-uuid]]
[compojure.core :refer [context GET POST]]
[ring.util.response :refer [not-found]]
[bbbg.attendee-check :as attendee-check]
[bbbg.user :as user]))
[ring.util.response :refer [not-found redirect]]
[bbbg.views.flash :as flash]))
(defn- edit-attendee-checks-page [{:keys [existing-check]
attendee-id ::attendee/id}]
@ -53,4 +55,14 @@
{:existing-check existing-check
::attendee/id attendee-id})))
(not-found "Attendee not found")))
(POST "/" []))))
(POST "/" {{:keys [last-dose-at]} :params
{user-id ::user/id} :session}
(db.attendee-check/create!
db
{::attendee/id attendee-id
::user/id user-id
::attendee-check/last-dose-at last-dose-at})
(-> (redirect "/attendees")
(flash/add-flash
#:flash{:type :success
:message "Successfully updated vaccination status"}))))))