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:
parent
800eba4cca
commit
a4aa42bbda
2 changed files with 22 additions and 4 deletions
|
@ -6,6 +6,12 @@
|
||||||
[bbbg.user :as user]
|
[bbbg.user :as user]
|
||||||
[bbbg.util.core :as u]))
|
[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
|
(defn attendees-with-last-checks
|
||||||
[db attendees]
|
[db attendees]
|
||||||
(when (seq attendees)
|
(when (seq attendees)
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
(ns bbbg.handlers.attendee-checks
|
(ns bbbg.handlers.attendee-checks
|
||||||
(:require
|
(:require
|
||||||
[bbbg.attendee :as attendee]
|
[bbbg.attendee :as attendee]
|
||||||
|
[bbbg.attendee-check :as attendee-check]
|
||||||
[bbbg.db :as db]
|
[bbbg.db :as db]
|
||||||
|
[bbbg.db.attendee-check :as db.attendee-check]
|
||||||
[bbbg.handlers.core :refer [page-response wrap-auth-required]]
|
[bbbg.handlers.core :refer [page-response wrap-auth-required]]
|
||||||
|
[bbbg.user :as user]
|
||||||
[bbbg.util.display :refer [format-date]]
|
[bbbg.util.display :refer [format-date]]
|
||||||
[compojure.coercions :refer [as-uuid]]
|
[compojure.coercions :refer [as-uuid]]
|
||||||
[compojure.core :refer [context GET POST]]
|
[compojure.core :refer [context GET POST]]
|
||||||
[ring.util.response :refer [not-found]]
|
[ring.util.response :refer [not-found redirect]]
|
||||||
[bbbg.attendee-check :as attendee-check]
|
[bbbg.views.flash :as flash]))
|
||||||
[bbbg.user :as user]))
|
|
||||||
|
|
||||||
(defn- edit-attendee-checks-page [{:keys [existing-check]
|
(defn- edit-attendee-checks-page [{:keys [existing-check]
|
||||||
attendee-id ::attendee/id}]
|
attendee-id ::attendee/id}]
|
||||||
|
@ -53,4 +55,14 @@
|
||||||
{:existing-check existing-check
|
{:existing-check existing-check
|
||||||
::attendee/id attendee-id})))
|
::attendee/id attendee-id})))
|
||||||
(not-found "Attendee not found")))
|
(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"}))))))
|
||||||
|
|
Loading…
Reference in a new issue