posting data to the nextcloud tables form catcher
This commit is contained in:
		
							parent
							
								
									47f31fc62b
								
							
						
					
					
						commit
						cca468675d
					
				
					 1 changed files with 61 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -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)))))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue