From 67fb7b0f00dac117dcd4a9e58ac708de63cc15b1 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Thu, 5 Dec 2024 15:16:45 -0600 Subject: [PATCH] adding working mission trip forms --- content/mt-church-form.md | 6 +- content/mt-form.md | 44 ++---- content/mt-parent-form.md | 6 +- content/mt-teacher-form.md | 6 +- justfile | 4 + layouts/shortcodes/mt-church-form.html | 8 +- layouts/shortcodes/mt-parent-form.html | 8 +- layouts/shortcodes/mt-teacher-form.html | 8 +- src/api/church_form.rs | 164 ---------------------- src/api/mod.rs | 3 - src/api/mt_church_form.rs | 20 +-- src/api/mt_parent_form.rs | 49 ++++--- src/api/mt_teacher_form.rs | 20 +-- src/api/parent_form.rs | 175 ------------------------ src/api/teacher_form.rs | 151 -------------------- src/main.rs | 13 +- 16 files changed, 104 insertions(+), 581 deletions(-) delete mode 100644 src/api/church_form.rs delete mode 100644 src/api/parent_form.rs delete mode 100644 src/api/teacher_form.rs diff --git a/content/mt-church-form.md b/content/mt-church-form.md index 033dcdb..62cf430 100644 --- a/content/mt-church-form.md +++ b/content/mt-church-form.md @@ -6,8 +6,8 @@ layout: simple sharingLinks: false --- -Mission Trip applications are closed until next year. + - +> This reference form will be confidential. If you need to, you can print this page and return it to TFC Connection 662 7th St Phillipsburg, KS 67661 by February 1st in order for your teen to be considered for Mission Trip. - +{{< mt-church-form >}} diff --git a/content/mt-form.md b/content/mt-form.md index ef059af..a847cb2 100644 --- a/content/mt-form.md +++ b/content/mt-form.md @@ -6,47 +6,31 @@ sharingLinks: false --- -Mission Trip applications are closed until next year. + If you are looking for the reference forms they are here, [parent](/mt-parent-form), [teacher](/mt-teacher-form), and [church-related](/mt-church-form)! Please click the appropriate one for them! Here is the [health form](/mt-health-form)! Also, if you need to pay please go [here](/donate). Thank you! ## Mission Trip Options -This year we have three options for mission trip! +This year we have two options for mission trip! -## Gallup, New Mexico - May 29 - June 10 - 8th Grade and above -This trip is designed for students who are ready for the challenge of leaving their personal desires behind as they follow Jesus and help meet the needs of others. This southwestern experience will find us making our home base at the 117-year-old campus of Rehoboth Christian school, where we will work with and serve the people in the community, making a difference in the lives of a variety of people. +## SPLASH 3.0 - June 3-10 - Highschool only +This trip is designed for students who are ready to be “sent out” as witnesses for Jesus Christ. Students applying for this trip should have reached a point in their relationship with Jesus where they want to be used by Jesus to help people be drawn into a relationship with Him. On this trip you might be sharing your testimony, involved in helping individuals understand the Word of God, and experience life on life ministry. You will learn what it is like to "be sent" by Jesus to draw people into a relationship with Him and it will challenge you to practice dependence on the Holy Spirit for direction and guidance. As a team we will learn how to follow Jesus as He opens our eyes to see the needs of people. -As a part of the Destination Rehoboth experience, we will volunteer at various locations in meaningful service projects both on and off of Rehoboth’s campus. Off-campus opportunities might include helping at the local food shelter, assisting Rehoboth families in need with home repair projects, or serving at churches on the reservation. Campus needs might include painting and minor repairs, or landscaping. +There will be no planned destination for this trip because we will follow the Holy Spirit to the places He wants us to serve during this time. This will be a stretch for many but will also be greatly rewarding as we learn to trust God to show us the needs of others! The team will include several TFC staff members, and we may end up traveling into the states bordering Kansas as we look for the places where Jesus wants us to serve Him. We will be self-contained including packing tools to work with and food for fixing our own meals, and we will either stay in churches or sleep in tents overnight. The trip will prepare team members to see how Jesus wants to use us in the world by meeting the needs of people and making disciples. As a team we will be provided opportunities to listen to the Holy Spirit’s leading as we pray and follow in obedience to where Jesus sends us. -Requirements for this team are a flexible attitude and a willingness to do hands-on labor. For more information about RCS and their current projects, check out their [website](https://www.rcsnm.org) and their [Facebook page](https://www.facebook.com/rcsnm). +- Estimated Support Goal of $700-$800 -- Estimated Support Goal of $850-$950 +## Tulsa, Oklahoma - May 24-30 - 8th Grade and above +This trip is designed for students who are ready for the challenge of leaving their personal desires behind as they follow Jesus and help meet the needs of others through the ministry of [Praying Pelican Missions in Tulsa, OK](https://www.ppm.org/mission-trips/tulsa-oklahoma). While Tulsa’s history as an oil boomtown is well-known, many are less aware that it was also once home to one of the most vibrant black communities in the U.S. prior to the Tulsa Race Massacre in 1921 when 10,000 Black people lost their homes, and an estimated 300 people died. It is considered by some to be “the single worst incident of racial violence in American history.” Now, just over 100 years later, we will be part of a renewed effort to heal deep wounds, come together as a community, and build up the local Church in Tulsa to reach across social, economic, racial, and spiritual divides. Our mission team will work alongside local church or ministry partners to meet real needs in the community and we will also have the opportunity to learn more about Tulsa’s deep history with diversity. -## Puerto Escondido, Mexico - *June 2 - 9 - Highschool only -This trip is designed for students who have a desire to be used by Jesus to draw others into a relationship with Him and they will be trained to go with the Gospel as His ambassadors. We will be working with the ministry of Roca Blanca Mission Base in Puerto Escondido, Mexico. There are a variety of ways to serve this ministry, we might lead a VBS, work in their orphanage, assist with village ministry, work on building projects, or possibly help deliver food or clothing. +- Estimated Support Goal of $800 - $900 -Requirements for this team are a willingness and desire to share the gospel of Jesus verbally, -relationally, and through physical work. Here is more information about [Roca Blanca](https://rocablanca.org). + + -- Estimated Support Goal of $1900-$2100 - -> You must have a passport for this trip. This will be an approximate $135 (including photo fee) additional personal expense. Allow for 6-8 weeks or pay an additional $60 for 2-3 week turn around. - -> \* Dates may vary slightly due to flight schedules - -### Mexico Travel Info -The Roca Blanca Mission Base is located in the safest and most secure area of Mexico, according to the US State Department, well and easily patrolled, virtually free from the drug and other violence issues that are plaguing the border towns and Mexico’s large cities. For more detailed official US State Department information [click here.](https://travel.state.gov/content/travel/en/traveladvisories/traveladvisories/mexico-travel-advisory.html) After a series of general warnings for Mexico they have a state by state listing. For reference, we’re located in the State of Oaxaca where there are no travel warnings in effect. - -With the same common sense precautions that you would take traveling anywhere, our coastal area is still the safe place to visit that it has been for many decades, safer than visiting many US cities. - -It’s easy to forget just how big Mexico is, and how far our location is from the warning areas! If you visit us, in most cases your flight will arrive directly to Huatulco (HUX), or by means of the Mexico City airport to Puerto Escondido (PXM), these being our nearest international airports. There we meet you at the airport and drive you here. You’re not within a thousand miles of a border town or hundreds of miles from a city with a warning. We also begin your stay here with an orientation, which includes safety tips to avoid any danger that might present itself. We live here and we raise our children here. You can trust our record of many years of safety for visitors and students. - -## 1-2 Day Local Trip - TBD -Formerly known as the SPLASH trip, this trip will be within 2 hours of the TFC office in Phillipsburg, KS and will be a 2 day trip where you can get a taste for a longer mission trip. If you don’t feel ready to go on a longer trip, or have scheduling conflicts with the other trips, this is the trip for you! You will still have the opportunity to serve and grow in your faith in Jesus. Click the button below to sign up for this trip! - -{{< button href="/local-trip-form">}} -Local Trip -{{< /button >}} + + + ## Mission Trip Agreement > In order to fill out the application, you must agree to the following! diff --git a/content/mt-parent-form.md b/content/mt-parent-form.md index 84a0e31..dcbc866 100644 --- a/content/mt-parent-form.md +++ b/content/mt-parent-form.md @@ -6,8 +6,8 @@ layout: simple sharingLinks: false --- -Mission Trip applications are closed until next year. + - +> This reference form is to help us understand your teenager better and it will be kept confidential. We consider it a privilege to work with your teenager, but as we consider them for this mission project, we would appreciate your valuable insight. If you need to, you can print this page and return it to TFC Connection 662 7th St Phillipsburg, KS 67661 by February 1st in order for your teen to be considered for Mission Trip. - +{{< mt-parent-form >}} diff --git a/content/mt-teacher-form.md b/content/mt-teacher-form.md index 005498a..7f2e9d1 100644 --- a/content/mt-teacher-form.md +++ b/content/mt-teacher-form.md @@ -6,8 +6,8 @@ layout: simple sharingLinks: false --- -Mission Trip applications are closed until next year. + - +> Thank you for taking the time to fill out the form. This reference form will be confidential. If you need to, you can print this page and return it to TFC Connection 662 7th St Phillipsburg, KS 67661 by February 1st in order for your teen to be considered for Mission Trip. - +{{< mt-teacher-form >}} diff --git a/justfile b/justfile index 88d2fdd..6833b54 100644 --- a/justfile +++ b/justfile @@ -15,3 +15,7 @@ clean: rm -rf bld/ test: RUST_LOG=debug cargo test --benches --tests --all-features -- --nocapture + +alias b:= build +alias r:= run +alias s:= server diff --git a/layouts/shortcodes/mt-church-form.html b/layouts/shortcodes/mt-church-form.html index e2c894b..be9f5bb 100644 --- a/layouts/shortcodes/mt-church-form.html +++ b/layouts/shortcodes/mt-church-form.html @@ -29,7 +29,13 @@
-
+

diff --git a/layouts/shortcodes/mt-parent-form.html b/layouts/shortcodes/mt-parent-form.html index 2b4abc4..671fa24 100644 --- a/layouts/shortcodes/mt-parent-form.html +++ b/layouts/shortcodes/mt-parent-form.html @@ -28,7 +28,13 @@
- +

diff --git a/layouts/shortcodes/mt-teacher-form.html b/layouts/shortcodes/mt-teacher-form.html index e04eb27..625276c 100644 --- a/layouts/shortcodes/mt-teacher-form.html +++ b/layouts/shortcodes/mt-teacher-form.html @@ -28,7 +28,13 @@
- +

diff --git a/src/api/church_form.rs b/src/api/church_form.rs deleted file mode 100644 index 254f6c9..0000000 --- a/src/api/church_form.rs +++ /dev/null @@ -1,164 +0,0 @@ -use actix_multipart::form::{text::Text, MultipartForm}; -use actix_web::{post, HttpResponse}; -use lettre::{message::MultiPart, Message}; -use tracing::info; - -use crate::email::send_email; - -#[derive(Debug, MultipartForm, Default)] -struct ChurchForm { - #[multipart(rename = "firstname")] - first_name: Option>, - #[multipart(rename = "lastname")] - last_name: Option>, - #[multipart(rename = "studentfirstname")] - student_first_name: Option>, - #[multipart(rename = "studentlastname")] - student_last_name: Option>, - relationship: Option>, - #[multipart(rename = "walk-with-jesus")] - walk: Option>, - commitment: Option>, - teachable: Option>, - #[multipart(rename = "pos-characteristics")] - positive: Option>, - #[multipart(rename = "neg-characteristics")] - negative: Option>, - #[multipart(rename = "extra-info")] - notes: Option>, -} - -#[post("/church-form")] -pub async fn church_form(MultipartForm(form): MultipartForm) -> HttpResponse { - let first = form.first_name.as_ref().unwrap().0.clone(); - let last = form.last_name.as_ref().unwrap().0.clone(); - let student = format!( - "{} {}", - form.student_first_name.as_ref().unwrap().0.clone(), - form.student_last_name.as_ref().unwrap().0.clone() - ); - let email_subject = format!( - "{} {} filled out a Church Reference form for {}!", - first, last, student - ); - let relationship = form - .relationship - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let walk = form - .walk - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let positive = form - .positive - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let negative = form - .negative - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let commitment = form - .commitment - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let teachable = form - .teachable - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let notes = form - .notes - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - info!("{first} {last} filled out a Church Reference form!"); - let email = markup::new! { - @markup::doctype() - html { - head { - title { @format!("{} {} filled out a Church Reference form for {}!", first, last, student) } - style { - "table { border-collapse: collapse; width: 100% }" - "td, th { padding: 8px }" - "td { text-align: left; width: 70%; word-wrap: break-word }" - "th { text-align: right; border-right: 1px solid #ddd }" - "tr { border-bottom: 1px solid #ddd }" - "h1 { text-align: center }" - } - } - body { - h1 { @format!("Church Reference form for {}!", student) } - hr; - table { - tr { - th { "Name" } - td { @format!("{} {}", first, last) } - } - tr { - th { "Student" } - td { @student } - } - tr { - th { "Relationship to teen" } - td { @relationship } - } - tr { - th { "Walk with Jesus" } - td { @walk } - } - tr { - th { "Commitment to church" } - td { @commitment } - } - tr { - th { "Teachable spirit" } - td { @teachable } - } - tr { - th { "Positive Attributes" } - td { @positive } - } - tr { - th { "Negaitive Attributes" } - td { @negative } - } - tr { - th { "Other Notes" } - td { @notes } - } - } - } - } - }; - let multi = MultiPart::alternative_plain_html(String::from("Testing"), email.to_string()); - - if let Ok(m) = Message::builder() - .from( - "TFC ADMIN " - .parse() - .unwrap(), - ) - .to("Chris Cochrun ".parse().unwrap()) - .to("Ethan Rose ".parse().unwrap()) - .subject(email_subject) - .multipart(multi) - { - let _ = send_email(m); - } else { - info!("Email incorrect"); - } - - HttpResponse::Ok().body("hi") -} diff --git a/src/api/mod.rs b/src/api/mod.rs index cf3ad64..dbb4844 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,5 +1,4 @@ pub mod camp_form; -pub mod church_form; // pub mod errors; pub mod health_form; pub mod local_trip_form; @@ -7,5 +6,3 @@ pub mod mt_church_form; pub mod mt_form; pub mod mt_parent_form; pub mod mt_teacher_form; -pub mod parent_form; -pub mod teacher_form; diff --git a/src/api/mt_church_form.rs b/src/api/mt_church_form.rs index 33f7824..2ad4f4a 100644 --- a/src/api/mt_church_form.rs +++ b/src/api/mt_church_form.rs @@ -65,7 +65,7 @@ impl MtChurchForm { meta charset="utf-8"; html { head { - title { (self.first_name.0) " " (self.last_name.0) " signed up for mission trip!" } + title { (self.first_name.0) " " (self.last_name.0) " filled out a church reference form for " (self.student_first_name.0) " " (self.student_last_name.0) "!" } style { "table { border-collapse: collapse; width: 100% }" "td, th { padding: 8px }" @@ -76,7 +76,7 @@ impl MtChurchForm { } } body { - h1 { "Mission trip form for " (self.first_name.0) " " (self.last_name.0) "!" } + h1 { "Church reference form for " (self.student_first_name.0) " " (self.student_last_name.0) "!" } hr; table { tr { @@ -148,10 +148,10 @@ impl MtChurchForm { } async fn send_email(&mut self) -> Result<()> { - let first = self.first_name.clone(); - let last = self.last_name.clone(); - let email_subject = format!("{} {} signed up for mission trip!", first, last); - info!("{first} {last} signed up for mission trip!"); + let first = self.student_first_name.clone(); + let last = self.student_last_name.clone(); + let email_subject = format!("Church reference form for {} {}!", first, last); + info!("{first} {last} church reference form!"); let email = self.build_email().await; let email = SinglePart::html(email.into_string()); @@ -172,8 +172,8 @@ impl MtChurchForm { } } -#[post("/api/mt-teacher-form")] -pub async fn mt_form(MultipartForm(mut form): MultipartForm) -> HttpResponse { +#[post("/api/mt-church-form")] +pub async fn mt_church_form(MultipartForm(mut form): MultipartForm) -> HttpResponse { match form.store_form().await { Ok(_) => info!("Successfully sent form to nextcloud!"), Err(e) => error!("There was an erroring sending form to nextcloud: {e}"), @@ -196,9 +196,9 @@ mod test { fn form() -> MtChurchForm { MtChurchForm { - first_name: Text(String::from("Frodo")), + first_name: Text(String::from("Bilbo")), last_name: Text(String::from("Braggins")), - student_first_name: Text(String::from("Bilbo")), + student_first_name: Text(String::from("Frodo")), student_last_name: Text(String::from("Braggins")), relationship: Text(String::from("Uncle")), positive: Text(String::from("Nimble and brave")), diff --git a/src/api/mt_parent_form.rs b/src/api/mt_parent_form.rs index ac9bc88..ba26fdc 100644 --- a/src/api/mt_parent_form.rs +++ b/src/api/mt_parent_form.rs @@ -22,6 +22,7 @@ struct MtParentForm { first_name: Text, #[multipart(rename = "lastname")] last_name: Text, + email: Text, #[multipart(rename = "studentfirstname")] student_first_name: Text, #[multipart(rename = "studentlastname")] @@ -42,18 +43,19 @@ struct MtParentForm { impl From<&MtParentForm> for HashMap { fn from(form: &MtParentForm) -> Self { let mut map = HashMap::new(); - map.insert(158, format!("{} {}", form.first_name.0, form.last_name.0)); + map.insert(167, format!("{} {}", form.first_name.0, form.last_name.0)); map.insert( - 159, + 168, format!("{} {}", form.student_first_name.0, form.student_last_name.0), ); - map.insert(160, form.authority.0.clone()); - map.insert(163, form.positive.0.clone()); - map.insert(164, form.negative.0.clone()); - map.insert(161, form.family.0.clone()); - map.insert(162, form.previous_trip.0.clone()); - map.insert(165, form.feelings.0.clone()); - map.insert(166, form.extra_info.0.clone()); + map.insert(169, form.authority.0.clone()); + map.insert(170, form.positive.0.clone()); + map.insert(171, form.negative.0.clone()); + map.insert(172, form.family.0.clone()); + map.insert(173, form.previous_trip.0.clone()); + map.insert(174, form.feelings.0.clone()); + map.insert(175, form.extra_info.0.clone()); + map.insert(176, form.email.0.clone()); map } } @@ -65,7 +67,7 @@ impl MtParentForm { meta charset="utf-8"; html { head { - title { (self.first_name.0) " " (self.last_name.0) " signed up for mission trip!" } + title { (self.first_name.0) " " (self.last_name.0) " filled out a parent form for " (self.student_first_name.0) " " (self.student_last_name.0) "!" } style { "table { border-collapse: collapse; width: 100% }" "td, th { padding: 8px }" @@ -76,7 +78,7 @@ impl MtParentForm { } } body { - h1 { "Mission trip form for " (self.first_name.0) " " (self.last_name.0) "!" } + h1 { "Parent reference form for " (self.student_first_name.0) " " (self.student_last_name.0) "!" } hr; table { tr { @@ -87,6 +89,10 @@ impl MtParentForm { th { "Student" } td { (self.student_first_name.0) " " (self.student_last_name.0) } } + tr { + th { "Email" } + td { (self.email.0) } + } tr { th { "Authority" } td { (self.authority.0) } @@ -127,9 +133,9 @@ impl MtParentForm { let mut json = HashMap::new(); json.insert("data", map); - let link = r#"https://staff.tfcconnection.org/apps/tables/#/table/13/row/757"#; + let link = r#"https://staff.tfcconnection.org/apps/tables/#/table/14/row/757"#; let res = client - .post("https://staff.tfcconnection.org/ocs/v2.php/apps/tables/api/2/tables/13/rows") + .post("https://staff.tfcconnection.org/ocs/v2.php/apps/tables/api/2/tables/14/rows") .basic_auth("chris", Some("2VHeGxeC^Zf9KqFK^G@Pt!zu2q^6@b")) .header("OCS-APIRequest", "true") .header("Content-Type", "application/json") @@ -148,10 +154,10 @@ impl MtParentForm { } async fn send_email(&mut self) -> Result<()> { - let first = self.first_name.clone(); - let last = self.last_name.clone(); - let email_subject = format!("{} {} signed up for mission trip!", first, last); - info!("{first} {last} signed up for mission trip!"); + let first = self.student_first_name.clone(); + let last = self.student_last_name.clone(); + let email_subject = format!("Parent reference form for {} {}!", first, last); + info!("{first} {last} parent reference form!"); let email = self.build_email().await; let email = SinglePart::html(email.into_string()); @@ -172,8 +178,8 @@ impl MtParentForm { } } -#[post("/api/mt-teacher-form")] -pub async fn mt_form(MultipartForm(mut form): MultipartForm) -> HttpResponse { +#[post("/api/mt-parent-form")] +pub async fn mt_parent_form(MultipartForm(mut form): MultipartForm) -> HttpResponse { match form.store_form().await { Ok(_) => info!("Successfully sent form to nextcloud!"), Err(e) => error!("There was an erroring sending form to nextcloud: {e}"), @@ -196,10 +202,11 @@ mod test { fn form() -> MtParentForm { MtParentForm { - first_name: Text(String::from("Frodo")), + first_name: Text(String::from("Bilbo")), last_name: Text(String::from("Braggins")), - student_first_name: Text(String::from("Bilbo")), + student_first_name: Text(String::from("Frodo")), student_last_name: Text(String::from("Braggins")), + email: Text(String::from("biblo@hobbits.us")), authority: Text(String::from("Uncle")), positive: Text(String::from("Nimble and brave")), negative: Text(String::from("Small")), diff --git a/src/api/mt_teacher_form.rs b/src/api/mt_teacher_form.rs index bfe41e0..16a436c 100644 --- a/src/api/mt_teacher_form.rs +++ b/src/api/mt_teacher_form.rs @@ -61,7 +61,7 @@ impl MtTeacherForm { meta charset="utf-8"; html { head { - title { (self.first_name.0) " " (self.last_name.0) " signed up for mission trip!" } + title { (self.first_name.0) " " (self.last_name.0) " filled out a teacher reference form for " (self.student_first_name.0) " " (self.student_last_name.0) "!" } style { "table { border-collapse: collapse; width: 100% }" "td, th { padding: 8px }" @@ -72,7 +72,7 @@ impl MtTeacherForm { } } body { - h1 { "Mission trip form for " (self.first_name.0) " " (self.last_name.0) "!" } + h1 { "Teacher reference form for " (self.student_first_name.0) " " (self.student_last_name.0) "!" } hr; table { tr { @@ -140,10 +140,10 @@ impl MtTeacherForm { } async fn send_email(&mut self) -> Result<()> { - let first = self.first_name.clone(); - let last = self.last_name.clone(); - let email_subject = format!("{} {} signed up for mission trip!", first, last); - info!("{first} {last} signed up for mission trip!"); + let first = self.student_first_name.clone(); + let last = self.student_last_name.clone(); + let email_subject = format!("Teacher reference form for {} {}!", first, last); + info!("{first} {last} teacher reference form!"); let email = self.build_email().await; let email = SinglePart::html(email.into_string()); @@ -165,7 +165,9 @@ impl MtTeacherForm { } #[post("/api/mt-teacher-form")] -pub async fn mt_form(MultipartForm(mut form): MultipartForm) -> HttpResponse { +pub async fn mt_teacher_form( + MultipartForm(mut form): MultipartForm, +) -> HttpResponse { match form.store_form().await { Ok(_) => info!("Successfully sent form to nextcloud!"), Err(e) => error!("There was an erroring sending form to nextcloud: {e}"), @@ -188,9 +190,9 @@ mod test { fn form() -> MtTeacherForm { MtTeacherForm { - first_name: Text(String::from("Frodo")), + first_name: Text(String::from("Bilbo")), last_name: Text(String::from("Braggins")), - student_first_name: Text(String::from("Bilbo")), + student_first_name: Text(String::from("Frodo")), student_last_name: Text(String::from("Braggins")), relationship: Text(String::from("Uncle")), positive: Text(String::from("Nimble and brave")), diff --git a/src/api/parent_form.rs b/src/api/parent_form.rs deleted file mode 100644 index e330474..0000000 --- a/src/api/parent_form.rs +++ /dev/null @@ -1,175 +0,0 @@ -use actix_multipart::form::{text::Text, MultipartForm}; -use actix_web::{post, HttpResponse}; -use lettre::{message::MultiPart, Message}; -use tracing::info; - -use crate::email::send_email; - -#[derive(Debug, MultipartForm, Default)] -struct ParentForm { - #[multipart(rename = "firstname")] - first_name: Option>, - #[multipart(rename = "lastname")] - last_name: Option>, - #[multipart(rename = "studentfirstname")] - student_first_name: Option>, - #[multipart(rename = "studentlastname")] - student_last_name: Option>, - email: Option>, - authority: Option>, - positive: Option>, - negative: Option>, - #[multipart(rename = "family-relation")] - family_relation: Option>, - #[multipart(rename = "previous-trip-info")] - previous_trip_info: Option>, - #[multipart(rename = "trip-feelings")] - trip_feelings: Option>, - #[multipart(rename = "extra-info")] - notes: Option>, -} - -#[post("/parent-form")] -pub async fn parent_form(MultipartForm(form): MultipartForm) -> HttpResponse { - let first = form.first_name.as_ref().unwrap().0.clone(); - let last = form.last_name.as_ref().unwrap().0.clone(); - let student = format!( - "{} {}", - form.student_first_name.as_ref().unwrap().0.clone(), - form.student_last_name.as_ref().unwrap().0.clone() - ); - let email_subject = format!( - "{} {} filled out a parent form for {}!", - first, last, student - ); - let email = form - .email - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let authority = form - .authority - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let positive = form - .positive - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let negative = form - .negative - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let family = form - .family_relation - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let previous_trip_info = form - .previous_trip_info - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let feelings = form - .trip_feelings - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let notes = form - .notes - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - info!("{first} {last} filled out a parent form!"); - let email = markup::new! { - @markup::doctype() - html { - head { - title { @format!("{} {} filled out a Parent Reference form for {}!", first, last, student) } - style { - "table { border-collapse: collapse; width: 100% }" - "td, th { padding: 8px }" - "td { text-align: left; width: 70%; word-wrap: break-word }" - "th { text-align: right; border-right: 1px solid #ddd }" - "tr { border-bottom: 1px solid #ddd }" - "h1 { text-align: center }" - } - } - body { - h1 { @format!("Parent Reference form for {}!", student) } - hr; - table { - tr { - th { "Name" } - td { @format!("{} {}", first, last) } - } - tr { - th { "Student" } - td { @student } - } - tr { - th { "Email" } - td { @email } - } - tr { - th { "Response to authority" } - td { @authority } - } - tr { - th { "Positive Attributes" } - td { @positive } - } - tr { - th { "Negaitive Attributes" } - td { @negative } - } - tr { - th { "Relations to Family" } - td { @family } - } - tr { - th { "Previous trip info" } - td { @previous_trip_info } - } - tr { - th { "Feelings about the trip" } - td { @feelings } - } - tr { - th { "Other Notes" } - td { @notes } - } - } - } - } - }; - let multi = MultiPart::alternative_plain_html(String::from("Testing"), email.to_string()); - - if let Ok(m) = Message::builder() - .from( - "TFC ADMIN " - .parse() - .unwrap(), - ) - .to("Chris Cochrun ".parse().unwrap()) - .to("Ethan Rose ".parse().unwrap()) - .subject(email_subject) - .multipart(multi) - { - let _ = send_email(m); - } else { - info!("Email incorrect"); - } - - HttpResponse::Ok().body("hi") -} diff --git a/src/api/teacher_form.rs b/src/api/teacher_form.rs deleted file mode 100644 index 29f6658..0000000 --- a/src/api/teacher_form.rs +++ /dev/null @@ -1,151 +0,0 @@ -use actix_multipart::form::{text::Text, MultipartForm}; -use actix_web::{post, HttpResponse}; -use lettre::{message::MultiPart, Message}; -use tracing::info; - -use crate::email::send_email; - -#[derive(Debug, MultipartForm, Default)] -struct TeacherForm { - #[multipart(rename = "firstname")] - first_name: Option>, - #[multipart(rename = "lastname")] - last_name: Option>, - #[multipart(rename = "studentfirstname")] - student_first_name: Option>, - #[multipart(rename = "studentlastname")] - student_last_name: Option>, - relationship: Option>, - attitudes: Option>, - positive: Option>, - negative: Option>, - #[multipart(rename = "team-challenges")] - team: Option>, - #[multipart(rename = "extra-info")] - notes: Option>, -} - -#[post("/teacher-form")] -pub async fn teacher_form(MultipartForm(form): MultipartForm) -> HttpResponse { - let first = form.first_name.as_ref().unwrap().0.clone(); - let last = form.last_name.as_ref().unwrap().0.clone(); - let student = format!( - "{} {}", - form.student_first_name.as_ref().unwrap().0.clone(), - form.student_last_name.as_ref().unwrap().0.clone() - ); - let email_subject = format!( - "{} {} filled out a teacher form for {}!", - first, last, student - ); - let relationship = form - .relationship - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let attitudes = form - .attitudes - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let positive = form - .positive - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let negative = form - .negative - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let team = form - .team - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - let notes = form - .notes - .as_ref() - .unwrap_or(&Text(String::from(""))) - .0 - .clone(); - info!("{first} {last} filled out a teacher form!"); - let email = markup::new! { - @markup::doctype() - html { - head { - title { @format!("{} {} filled out a teacher form for {}!", first, last, student) } - style { - "table { border-collapse: collapse; width: 100% }" - "td, th { padding: 8px }" - "td { text-align: left; width: 70%; word-wrap: break-word }" - "th { text-align: right; border-right: 1px solid #ddd }" - "tr { border-bottom: 1px solid #ddd }" - "h1 { text-align: center }" - } - } - body { - h1 { @format!("Teacher Reference form for {}!", student) } - hr; - table { - tr { - th { "Name" } - td { @format!("{} {}", first, last) } - } - tr { - th { "Student" } - td { @student } - } - tr { - th { "Relationship to teen" } - td { @relationship } - } - tr { - th { "Attitude in classroom" } - td { @attitudes } - } - tr { - th { "Positive Attributes" } - td { @positive } - } - tr { - th { "Negaitive Attributes" } - td { @negative } - } - tr { - th { "Teamwork" } - td { @team } - } - tr { - th { "Other Notes" } - td { @notes } - } - } - } - } - }; - let multi = MultiPart::alternative_plain_html(String::from("Testing"), email.to_string()); - - if let Ok(m) = Message::builder() - .from( - "TFC ADMIN " - .parse() - .unwrap(), - ) - .to("Chris Cochrun ".parse().unwrap()) - .to("Ethan Rose ".parse().unwrap()) - .subject(email_subject) - .multipart(multi) - { - let _ = send_email(m); - } else { - info!("Email incorrect"); - } - - HttpResponse::Ok().body("hi") -} diff --git a/src/main.rs b/src/main.rs index 39d1e1d..0522e3e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,12 +7,13 @@ use actix_web::body::MessageBody; use actix_web::dev::{ServiceRequest, ServiceResponse}; use actix_web::{web, App, Error, HttpServer}; use api::camp_form::camp_form; -use api::church_form::church_form; use api::health_form::health_form; use api::local_trip_form::local_form; use api::mt_form::mt_form; -use api::parent_form::parent_form; -use api::teacher_form::teacher_form; +use api::{ + mt_church_form::mt_church_form, mt_parent_form::mt_parent_form, + mt_teacher_form::mt_teacher_form, +}; use color_eyre::eyre::Context; use color_eyre::Result; use sqlx::{Connection, SqliteConnection}; @@ -89,9 +90,9 @@ async fn main() -> std::io::Result<()> { .app_data(TempFileConfig::default().directory("./tmp")) .service(mt_form) .service(health_form) - .service(parent_form) - .service(teacher_form) - .service(church_form) + .service(mt_parent_form) + .service(mt_teacher_form) + .service(mt_church_form) .service(local_form) .service(camp_form) .service(Files::new("/", "./public").index_file("index.html"))