fixed the lisp server. Now to decide between the two

This commit is contained in:
Chris Cochrun 2024-01-09 14:20:48 -06:00
parent c669c12311
commit 6ad7472d83

View file

@ -282,11 +282,12 @@
with the image attached to us"
(uiop:println form)
(let ((first-name (cdr (assoc "firstname" form :test 'string=)))
(last-name (cdr (assoc "lastname" form :test 'string=))))
(last-name (cdr (assoc "lastname" form :test 'string=)))
(form (reverse form)))
(not (cl-smtp:send-email
"mail.tfcconnection.org"
"no-reply@mail.tfcconnection.org"
"chris@cochrun.xyz"
'("chris@cochrun.xyz" "chris@tfcconnection.org")
(format nil "~a ~a filled out a Mission Trip Form!" first-name last-name)
(format nil "Mission Trip Form for ~a ~a" first-name last-name)
:display-name "TFC ADMIN"
@ -309,71 +310,7 @@ with the image attached to us"
(:td (trim-whitespace
(cdr row)))))))))))))
(cl-smtp:send-email
"mail.tfcconnection.org"
"TFC-ADMIN <no-reply@mail.tfcconnection.org>"
"chris@cochrun.xyz"
(format nil "~a ~a filled out a Mission Trip Form!" "Chris" "Ccohrun")
"hi"
:html-message
;; (with-html-string (:h1 "hi"))
(let ((form '(("age" . "150")
("registration" . "later")
("final-agreement" . "yes")
("relevant-notes" . "")
("attitude-toward-work" . "")
("previous-trip-info" . "")
("weaknesses" . "")
("strengths" . "")
("reasons-for-trip-choice" . "")
("involvement-with-group" . "")
("testimony" . "")
("relationship-with-jesus" . "")
("tripnotes" . "")
("trip" . "New Mexico")
("shirt" . "small")
("tfcgroup" . "Phillipsburg")
("churchattendanceother" . "")
("churchattendance" . "yes")
("church" . "")
("pastorphone" . "9991112222")
("pastorlastname" . "The White")
("pastorfirstname" . "Gandalf")
("grade" . "sophomore")
("school" . "A cool one")
("parentemail" . "bilbosmells@braggins.xyz")
("email" . "chris@cochrun.xyz")
("parentphone" . "8889990000")
("cellphone" . "7853021664")
("zip" . "67661")
("state" . "Middle Earth")
("city" . "The Shire")
("street" . "1234 Bag End, 98 Hobbiton")
("gender" . "Male")
("birthdate" . "1873-11-23")
("parentlastname" . "Braggins")
("parentfirstname" . "Bilbo")
("lastname" . "Braggins")
("firstname" . "Frodo"))))
(with-html-string
(:doctype)
(:html
(:head (:title "TFC Mission Trip Form")
(:style (apply #'lass:compile-and-write *mail-css*)))
(:body
(:h1 (format nil "Mission Trip Form for ~a ~a" "Chris" "Ccohrun"))
(:hr)
(:table
(loop for row in form
do (:tr
(:th (trim-whitespace (car row)))
(:td (trim-whitespace
(cdr row))))))))))
:ssl :tls
:authentication '(:login "no-reply@mail.tfcconnection.org" "r9f36mNZFtiW4f")
)
(defun mail-form (form attachment)
(defun mail-health-form (form attachment)
"Takes the form as an alist and sends a table formatted email
with the image attached"
(let ((first-name (serapeum:trim-whitespace
@ -389,113 +326,33 @@ with the image attached"
" "
(serapeum:trim-whitespace
(cdr (assoc "parentlastname" form
:test 'string=)))))
(birthdate (trim-whitespace
(cdr (assoc "birthdate" form
:test 'string=))))
(city (trim-whitespace
(cdr (assoc "city" form
:test 'string=))))
(street (trim-whitespace
(cdr (assoc "street" form
:test 'string=))))
(state (trim-whitespace
(cdr (assoc "state" form
:test 'string=))))
(zip (trim-whitespace
(cdr (assoc "zip" form
:test 'string=))))
(cellphone (trim-whitespace
(cdr (assoc "cellphone" form
:test 'string=))))
(homephone (trim-whitespace
(cdr (assoc "homephone" form
:test 'string=))))
(emergency-contact (trim-whitespace
(cdr (assoc "emergency-contact" form
:test 'string=))))
(additional-contact (trim-whitespace
(cdr (assoc "add-emergency-contact-phone" form
:test 'string=))))
(doctor (trim-whitespace
(cdr (assoc "doctor" form
:test 'string=))))
(doctor-city (trim-whitespace
(cdr (assoc "doctor-city" form
:test 'string=))))
(doctor-phone (trim-whitespace
(cdr (assoc "doctor-phone" form
:test 'string=))))
(medical-coverage (trim-whitespace
(cdr (assoc "medical-coverage" form
:test 'string=))))
(insurance (trim-whitespace
(cdr (assoc "insurance-name" form
:test 'string=))))
(policy-number (trim-whitespace
(cdr (assoc "policy-number" form
:test 'string=))))
(image (trim-whitespace
(cdr (assoc "image" form
:test 'string=))))
(agreement (trim-whitespace
(cdr (assoc "agreement" form
:test 'string=))))
(allergies (trim-whitespace
(cdr (assoc "allergies" form
:test 'string=))))
(allergies-other (trim-whitespace
(cdr (assoc "allergies-other" form
:test 'string=))))
(specific-allergies (trim-whitespace
(cdr (assoc "specific-allergies" form
:test 'string=))))
(allergy-treatments (trim-whitespace
(cdr (assoc "allergy-treatments" form
:test 'string=))))
(conditions (trim-whitespace
(cdr (assoc "conditions" form
:test 'string=))))
(tetanus (trim-whitespace
(cdr (assoc "tetanus-shot-date" form
:test 'string=))))
(swimming (trim-whitespace
(cdr (assoc "swimming-ability" form
:test 'string=))))
(medication (trim-whitespace
(cdr (assoc "medication-schedule" form
:test 'string=))))
(other (trim-whitespace
(cdr (assoc "other-notes" form
:test 'string=))))
(age (trim-whitespace
(cdr (assoc "age" form
:test 'string=)))))
(not (cl-smtp:send-email
"mail.tfcconnection.org"
"no-reply@mail.tfcconnection.org"
'("chris@tfcconnection.org" "ethan@tfcconnection.org")
(format nil "~a ~a filled out a Health Form!" first-name last-name)
(format nil "Health Form for ~a ~a" first-name last-name)
:display-name "TFC ADMIN"
:ssl :tls
:authentication '(:login "no-reply@mail.tfcconnection.org" "r9f36mNZFtiW4f")
:attachments attachment
:html-message
(with-html-string
(:doctype)
(:html
(:head (:title "TFC Health Form")
(:style (apply #'lass:compile-and-write *mail-css*)))
(:body
(:h1 (format nil "Health Form for ~a ~a" first-name last-name))
(:hr)
(:table
(loop for row in form
do (:tr
(:th (car row))
(:td (trim-whitespace
(cdr row)))))))))))))
:test 'string=))))))
(let ((form (reverse form)))
(not (cl-smtp:send-email
"mail.tfcconnection.org"
"no-reply@mail.tfcconnection.org"
'("chris@tfcconnection.org" "ethan@tfcconnection.org")
(format nil "~a ~a filled out a Health Form!" first-name last-name)
(format nil "Health Form for ~a ~a" first-name last-name)
:display-name "TFC ADMIN"
:ssl :tls
:authentication '(:login "no-reply@mail.tfcconnection.org" "r9f36mNZFtiW4f")
:attachments attachment
:html-message
(with-html-string
(:doctype)
(:html
(:head (:title "TFC Health Form")
(:style (apply #'lass:compile-and-write *mail-css*)))
(:body
(:h1 (format nil "Health Form for ~a ~a" first-name last-name))
(:hr)
(:table
(loop for row in form
do (:tr
(:th (car row))
(:td (trim-whitespace
(cdr row))))))))))))))
(hunchentoot:define-easy-handler (respond :uri "/mt-form") ()
(setf (hunchentoot:content-type*) "plain/text")
@ -505,7 +362,8 @@ with the image attached"
(boundary (let ((position (position #\= content-type)))
(when position
(subseq content-type (1+ position)))))
(string-data (flexi-streams:octets-to-string (hunchentoot:raw-post-data :request req)))
(string-data (flexi-streams:octets-to-string
(hunchentoot:raw-post-data :request req)))
(parts (ppcre:split boundary string-data))
(form-list nil)
(attachment nil))
@ -678,7 +536,7 @@ with the image attached"
(setq *last-list-data*
(append *last-list-data* form-list))))
(post-health-form *last-list-data*)
(if (mail-form *last-list-data* attachment)
(if (mail-health-form *last-list-data* attachment)
(format nil "thankyou")))))))
(defun main ()