From cca468675d1f78a60d91c88334889069cba30062 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Fri, 26 Apr 2024 06:49:46 -0500 Subject: [PATCH] posting data to the nextcloud tables form catcher --- src/main.lisp | 68 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/src/main.lisp b/src/main.lisp index 95282c5..ee03257 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -244,12 +244,65 @@ (defun post-camp-data (data) "Takes the camp data as an alist and sends it to nextcloud tables to be input" - (let ((new-data '((63 . "Frodo Braggins") (64 . "Bilbo Braggins")))) + (let ((new-data `((63 . ,(concat + (cdr + (assoc "first-name" + data :test 'string=)) + " " + (cdr + (assoc "last-name" + data :test 'string=)))) + (64 . ,(concat + (cdr + (assoc "parent-first-name" + data :test 'string=)) + " " + (cdr + (assoc "parent-last-name" + data :test 'string=)))) + (65 . ,(cdr + (assoc "parent-phone" + data :test 'string=))) + (66 . ,(cdr + (assoc "parent-email" + data :test 'string=))) + (67 . ,(cdr + (assoc "birth-date" + data :test 'string=))) + (69 . ,(cdr + (assoc "gender" + data :test 'string=))) + (70 . ,(cdr + (assoc "street" + data :test 'string=))) + (71 . ,(cdr + (assoc "city" + data :test 'string=))) + (72 . ,(cdr + (assoc "state" + data :test 'string=))) + (73 . ,(cdr + (assoc "zip" + data :test 'string=))) + (74 . ,(cdr + (assoc "grade" + data :test 'string=))) + (75 . ,(cdr + (assoc "week" + data :test 'string=))) + (76 . ,(cdr + (assoc "shirt" + data :test 'string=))) + (77 . ,(cdr + (assoc "registration" + data :test 'string=)))))) (log:info new-data) - (dex:post "https://staff.tfcconnection.org/apps/tables/api/1/tables/5/rows" - :basic-auth '("chris" . "2VHeGxeC^Zf9KqFK^G@Pt!zu2q^6@b") - :content `(("data" . ,(stringify new-data))) - :verbose t))) + (bt:make-thread + (lambda () + (dex:post "https://staff.tfcconnection.org/apps/tables/api/1/tables/5/rows" + :basic-auth '("chris" . "2VHeGxeC^Zf9KqFK^G@Pt!zu2q^6@b") + :content `(("data" . ,(stringify new-data))) + :verbose t))))) (defun mail-mt-form (form attachment) "Takes the form as an alist and sends a table formatted email @@ -430,7 +483,8 @@ with the image attached" (log:info data) ;; This is extremely necessary so that cors is right (setf (tbnl:header-out :access-control-expose-headers) "*") - (if (string= health "later") + (post-camp-data data) + (if (string= health "bleh") (progn (uiop:println "Selected health later") (cond ((string= registration "now") (setf (hunchentoot:header-out :HX-Redirect) "https://secure.myvanco.com/L-Z772/campaign/C-13JPJ") @@ -454,7 +508,7 @@ with the image attached" (:p "Can't wait to see you at camp!!") (:p :class "text-md" "If you'd like to pay for your registration go to the donate tab in the top right when you are ready and find the camp registration option."))))))) - (when (string= health "now") + (when (string= health "bleh") (setf (tbnl:header-out :HX-Redirect) (format nil "/camp-health-form/?registration=~A" registration)) (log:info (tbnl:headers-out*)) (mail-camp-form data nil)))))