diff options
-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"})))))) |