diff options
author | Griffin Smith <grfn@gws.fyi> | 2021-12-26T15·15-0500 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2021-12-26T16·04+0000 |
commit | a4aa42bbdacb154dc1a3abd3a8ef20be4736ba6a (patch) | |
tree | de9a4b7efbbfbc0d97b5483b374f70c9c3e1c61c /users/grfn | |
parent | 800eba4ccab5050784abecbd41e2ac3c798154a1 (diff) |
feat(grfn/bbbg): Allow actually saving checks r/3417
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
Diffstat (limited to 'users/grfn')
-rw-r--r-- | users/grfn/bbbg/src/bbbg/db/attendee_check.clj | 6 | ||||
-rw-r--r-- | users/grfn/bbbg/src/bbbg/handlers/attendee_checks.clj | 20 |
2 files changed, 22 insertions, 4 deletions
diff --git a/users/grfn/bbbg/src/bbbg/db/attendee_check.clj b/users/grfn/bbbg/src/bbbg/db/attendee_check.clj index 33ed98d4ffbd..492f786bd660 100644 --- a/users/grfn/bbbg/src/bbbg/db/attendee_check.clj +++ b/users/grfn/bbbg/src/bbbg/db/attendee_check.clj @@ -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) diff --git a/users/grfn/bbbg/src/bbbg/handlers/attendee_checks.clj b/users/grfn/bbbg/src/bbbg/handlers/attendee_checks.clj index af56002bd1c0..d7307c40673b 100644 --- a/users/grfn/bbbg/src/bbbg/handlers/attendee_checks.clj +++ b/users/grfn/bbbg/src/bbbg/handlers/attendee_checks.clj @@ -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"})))))) |