adding working mission trip forms

This commit is contained in:
Chris Cochrun 2024-12-05 15:16:45 -06:00
parent 6603d2c6bc
commit 67fb7b0f00
16 changed files with 104 additions and 581 deletions

View file

@ -6,8 +6,8 @@ layout: simple
sharingLinks: false sharingLinks: false
--- ---
Mission Trip applications are closed until next year. <!-- 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. --> > 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 >}} --> {{< mt-church-form >}}

View file

@ -6,47 +6,31 @@ sharingLinks: false
--- ---
Mission Trip applications are closed until next year. <!-- 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! 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 ## 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 ## SPLASH 3.0 - June 3-10 - Highschool only
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. 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 Rehoboths 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 Spirits 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 Tulsas 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 Tulsas deep history with diversity.
## Puerto Escondido, Mexico - *June 2 - 9 - Highschool only - Estimated Support Goal of $800 - $900
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.
Requirements for this team are a willingness and desire to share the gospel of Jesus verbally, <!-- ## 1-2 Day Local Trip - TBD -->
relationally, and through physical work. Here is more information about [Roca Blanca](https://rocablanca.org). <!-- 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 dont 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! -->
- Estimated Support Goal of $1900-$2100 <!-- {{< button href="/local-trip-form">}} -->
<!-- Local Trip -->
> 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. <!-- {{< /button >}} -->
> \* 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 Mexicos 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, were 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.
Its 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. Youre 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 dont 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 ## Mission Trip Agreement
> In order to fill out the application, you must agree to the following! > In order to fill out the application, you must agree to the following!

View file

@ -6,8 +6,8 @@ layout: simple
sharingLinks: false sharingLinks: false
--- ---
Mission Trip applications are closed until next year. <!-- 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. --> > 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 >}} --> {{< mt-parent-form >}}

View file

@ -6,8 +6,8 @@ layout: simple
sharingLinks: false sharingLinks: false
--- ---
Mission Trip applications are closed until next year. <!-- 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. --> > 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 >}} --> {{< mt-teacher-form >}}

View file

@ -15,3 +15,7 @@ clean:
rm -rf bld/ rm -rf bld/
test: test:
RUST_LOG=debug cargo test --benches --tests --all-features -- --nocapture RUST_LOG=debug cargo test --benches --tests --all-features -- --nocapture
alias b:= build
alias r:= run
alias s:= server

View file

@ -29,7 +29,13 @@
</script> </script>
<div id="mt-form" class="form text-lg w-full"> <div id="mt-form" class="form text-lg w-full">
<form id='form' onsubmit="submitForm(event)" autocomplete="on" method="post" target="_parent" class="w-full items-center flex flex-wrap"> <form id='form'
hx-post="/api/mt-church-form"
hx-encoding="multipart/form-data"
autocomplete="on"
method="post"
target="_parent"
class="w-full items-center flex flex-wrap">
<div class="basis-full flex flex-wrap my-4"> <div class="basis-full flex flex-wrap my-4">
<label for="firstname" class="basis-full">What is your first and last name?</label> <label for="firstname" class="basis-full">What is your first and last name?</label>
<br/> <br/>

View file

@ -28,7 +28,13 @@
</script> </script>
<div id="mt-form" class="form text-lg w-full"> <div id="mt-form" class="form text-lg w-full">
<form id='form' onsubmit="submitForm(event)" autocomplete="on" method="post" target="_parent" class="w-full items-center flex flex-wrap"> <form id='form'
hx-post="/api/mt-parent-form"
hx-encoding="multipart/form-data"
autocomplete="on"
method="post"
target="_parent"
class="w-full items-center flex flex-wrap">
<div class="basis-full flex flex-wrap my-4"> <div class="basis-full flex flex-wrap my-4">
<label for="firstname" class="basis-full">What is your first and last name?</label> <label for="firstname" class="basis-full">What is your first and last name?</label>
<br/> <br/>

View file

@ -28,7 +28,13 @@
</script> </script>
<div id="mt-form" class="form text-lg w-full"> <div id="mt-form" class="form text-lg w-full">
<form id='form' onsubmit="submitForm(event)" autocomplete="on" method="post" target="_parent" class="w-full items-center flex flex-wrap"> <form id='form'
hx-post="/api/mt-teacher-form"
hx-encoding="multipart/form-data"
autocomplete="on"
method="post"
target="_parent"
class="w-full items-center flex flex-wrap">
<div class="basis-full flex flex-wrap my-4"> <div class="basis-full flex flex-wrap my-4">
<label for="firstname" class="basis-full">What is your first and last name?</label> <label for="firstname" class="basis-full">What is your first and last name?</label>
<br/> <br/>

View file

@ -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<Text<String>>,
#[multipart(rename = "lastname")]
last_name: Option<Text<String>>,
#[multipart(rename = "studentfirstname")]
student_first_name: Option<Text<String>>,
#[multipart(rename = "studentlastname")]
student_last_name: Option<Text<String>>,
relationship: Option<Text<String>>,
#[multipart(rename = "walk-with-jesus")]
walk: Option<Text<String>>,
commitment: Option<Text<String>>,
teachable: Option<Text<String>>,
#[multipart(rename = "pos-characteristics")]
positive: Option<Text<String>>,
#[multipart(rename = "neg-characteristics")]
negative: Option<Text<String>>,
#[multipart(rename = "extra-info")]
notes: Option<Text<String>>,
}
#[post("/church-form")]
pub async fn church_form(MultipartForm(form): MultipartForm<ChurchForm>) -> 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 <no-reply@mail.tfcconnection.org>"
.parse()
.unwrap(),
)
.to("Chris Cochrun <chris@tfcconnection.org>".parse().unwrap())
.to("Ethan Rose <ethan@tfcconnection.org>".parse().unwrap())
.subject(email_subject)
.multipart(multi)
{
let _ = send_email(m);
} else {
info!("Email incorrect");
}
HttpResponse::Ok().body("hi")
}

View file

@ -1,5 +1,4 @@
pub mod camp_form; pub mod camp_form;
pub mod church_form;
// pub mod errors; // pub mod errors;
pub mod health_form; pub mod health_form;
pub mod local_trip_form; pub mod local_trip_form;
@ -7,5 +6,3 @@ pub mod mt_church_form;
pub mod mt_form; pub mod mt_form;
pub mod mt_parent_form; pub mod mt_parent_form;
pub mod mt_teacher_form; pub mod mt_teacher_form;
pub mod parent_form;
pub mod teacher_form;

View file

@ -65,7 +65,7 @@ impl MtChurchForm {
meta charset="utf-8"; meta charset="utf-8";
html { html {
head { 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 { style {
"table { border-collapse: collapse; width: 100% }" "table { border-collapse: collapse; width: 100% }"
"td, th { padding: 8px }" "td, th { padding: 8px }"
@ -76,7 +76,7 @@ impl MtChurchForm {
} }
} }
body { 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; hr;
table { table {
tr { tr {
@ -148,10 +148,10 @@ impl MtChurchForm {
} }
async fn send_email(&mut self) -> Result<()> { async fn send_email(&mut self) -> Result<()> {
let first = self.first_name.clone(); let first = self.student_first_name.clone();
let last = self.last_name.clone(); let last = self.student_last_name.clone();
let email_subject = format!("{} {} signed up for mission trip!", first, last); let email_subject = format!("Church reference form for {} {}!", first, last);
info!("{first} {last} signed up for mission trip!"); info!("{first} {last} church reference form!");
let email = self.build_email().await; let email = self.build_email().await;
let email = SinglePart::html(email.into_string()); let email = SinglePart::html(email.into_string());
@ -172,8 +172,8 @@ impl MtChurchForm {
} }
} }
#[post("/api/mt-teacher-form")] #[post("/api/mt-church-form")]
pub async fn mt_form(MultipartForm(mut form): MultipartForm<MtChurchForm>) -> HttpResponse { pub async fn mt_church_form(MultipartForm(mut form): MultipartForm<MtChurchForm>) -> HttpResponse {
match form.store_form().await { match form.store_form().await {
Ok(_) => info!("Successfully sent form to nextcloud!"), Ok(_) => info!("Successfully sent form to nextcloud!"),
Err(e) => error!("There was an erroring sending form to nextcloud: {e}"), Err(e) => error!("There was an erroring sending form to nextcloud: {e}"),
@ -196,9 +196,9 @@ mod test {
fn form() -> MtChurchForm { fn form() -> MtChurchForm {
MtChurchForm { MtChurchForm {
first_name: Text(String::from("Frodo")), first_name: Text(String::from("Bilbo")),
last_name: Text(String::from("Braggins")), 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")), student_last_name: Text(String::from("Braggins")),
relationship: Text(String::from("Uncle")), relationship: Text(String::from("Uncle")),
positive: Text(String::from("Nimble and brave")), positive: Text(String::from("Nimble and brave")),

View file

@ -22,6 +22,7 @@ struct MtParentForm {
first_name: Text<String>, first_name: Text<String>,
#[multipart(rename = "lastname")] #[multipart(rename = "lastname")]
last_name: Text<String>, last_name: Text<String>,
email: Text<String>,
#[multipart(rename = "studentfirstname")] #[multipart(rename = "studentfirstname")]
student_first_name: Text<String>, student_first_name: Text<String>,
#[multipart(rename = "studentlastname")] #[multipart(rename = "studentlastname")]
@ -42,18 +43,19 @@ struct MtParentForm {
impl From<&MtParentForm> for HashMap<i32, String> { impl From<&MtParentForm> for HashMap<i32, String> {
fn from(form: &MtParentForm) -> Self { fn from(form: &MtParentForm) -> Self {
let mut map = HashMap::new(); 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( map.insert(
159, 168,
format!("{} {}", form.student_first_name.0, form.student_last_name.0), format!("{} {}", form.student_first_name.0, form.student_last_name.0),
); );
map.insert(160, form.authority.0.clone()); map.insert(169, form.authority.0.clone());
map.insert(163, form.positive.0.clone()); map.insert(170, form.positive.0.clone());
map.insert(164, form.negative.0.clone()); map.insert(171, form.negative.0.clone());
map.insert(161, form.family.0.clone()); map.insert(172, form.family.0.clone());
map.insert(162, form.previous_trip.0.clone()); map.insert(173, form.previous_trip.0.clone());
map.insert(165, form.feelings.0.clone()); map.insert(174, form.feelings.0.clone());
map.insert(166, form.extra_info.0.clone()); map.insert(175, form.extra_info.0.clone());
map.insert(176, form.email.0.clone());
map map
} }
} }
@ -65,7 +67,7 @@ impl MtParentForm {
meta charset="utf-8"; meta charset="utf-8";
html { html {
head { 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 { style {
"table { border-collapse: collapse; width: 100% }" "table { border-collapse: collapse; width: 100% }"
"td, th { padding: 8px }" "td, th { padding: 8px }"
@ -76,7 +78,7 @@ impl MtParentForm {
} }
} }
body { 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; hr;
table { table {
tr { tr {
@ -87,6 +89,10 @@ impl MtParentForm {
th { "Student" } th { "Student" }
td { (self.student_first_name.0) " " (self.student_last_name.0) } td { (self.student_first_name.0) " " (self.student_last_name.0) }
} }
tr {
th { "Email" }
td { (self.email.0) }
}
tr { tr {
th { "Authority" } th { "Authority" }
td { (self.authority.0) } td { (self.authority.0) }
@ -127,9 +133,9 @@ impl MtParentForm {
let mut json = HashMap::new(); let mut json = HashMap::new();
json.insert("data", map); 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 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")) .basic_auth("chris", Some("2VHeGxeC^Zf9KqFK^G@Pt!zu2q^6@b"))
.header("OCS-APIRequest", "true") .header("OCS-APIRequest", "true")
.header("Content-Type", "application/json") .header("Content-Type", "application/json")
@ -148,10 +154,10 @@ impl MtParentForm {
} }
async fn send_email(&mut self) -> Result<()> { async fn send_email(&mut self) -> Result<()> {
let first = self.first_name.clone(); let first = self.student_first_name.clone();
let last = self.last_name.clone(); let last = self.student_last_name.clone();
let email_subject = format!("{} {} signed up for mission trip!", first, last); let email_subject = format!("Parent reference form for {} {}!", first, last);
info!("{first} {last} signed up for mission trip!"); info!("{first} {last} parent reference form!");
let email = self.build_email().await; let email = self.build_email().await;
let email = SinglePart::html(email.into_string()); let email = SinglePart::html(email.into_string());
@ -172,8 +178,8 @@ impl MtParentForm {
} }
} }
#[post("/api/mt-teacher-form")] #[post("/api/mt-parent-form")]
pub async fn mt_form(MultipartForm(mut form): MultipartForm<MtParentForm>) -> HttpResponse { pub async fn mt_parent_form(MultipartForm(mut form): MultipartForm<MtParentForm>) -> HttpResponse {
match form.store_form().await { match form.store_form().await {
Ok(_) => info!("Successfully sent form to nextcloud!"), Ok(_) => info!("Successfully sent form to nextcloud!"),
Err(e) => error!("There was an erroring sending form to nextcloud: {e}"), Err(e) => error!("There was an erroring sending form to nextcloud: {e}"),
@ -196,10 +202,11 @@ mod test {
fn form() -> MtParentForm { fn form() -> MtParentForm {
MtParentForm { MtParentForm {
first_name: Text(String::from("Frodo")), first_name: Text(String::from("Bilbo")),
last_name: Text(String::from("Braggins")), 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")), student_last_name: Text(String::from("Braggins")),
email: Text(String::from("biblo@hobbits.us")),
authority: Text(String::from("Uncle")), authority: Text(String::from("Uncle")),
positive: Text(String::from("Nimble and brave")), positive: Text(String::from("Nimble and brave")),
negative: Text(String::from("Small")), negative: Text(String::from("Small")),

View file

@ -61,7 +61,7 @@ impl MtTeacherForm {
meta charset="utf-8"; meta charset="utf-8";
html { html {
head { 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 { style {
"table { border-collapse: collapse; width: 100% }" "table { border-collapse: collapse; width: 100% }"
"td, th { padding: 8px }" "td, th { padding: 8px }"
@ -72,7 +72,7 @@ impl MtTeacherForm {
} }
} }
body { 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; hr;
table { table {
tr { tr {
@ -140,10 +140,10 @@ impl MtTeacherForm {
} }
async fn send_email(&mut self) -> Result<()> { async fn send_email(&mut self) -> Result<()> {
let first = self.first_name.clone(); let first = self.student_first_name.clone();
let last = self.last_name.clone(); let last = self.student_last_name.clone();
let email_subject = format!("{} {} signed up for mission trip!", first, last); let email_subject = format!("Teacher reference form for {} {}!", first, last);
info!("{first} {last} signed up for mission trip!"); info!("{first} {last} teacher reference form!");
let email = self.build_email().await; let email = self.build_email().await;
let email = SinglePart::html(email.into_string()); let email = SinglePart::html(email.into_string());
@ -165,7 +165,9 @@ impl MtTeacherForm {
} }
#[post("/api/mt-teacher-form")] #[post("/api/mt-teacher-form")]
pub async fn mt_form(MultipartForm(mut form): MultipartForm<MtTeacherForm>) -> HttpResponse { pub async fn mt_teacher_form(
MultipartForm(mut form): MultipartForm<MtTeacherForm>,
) -> HttpResponse {
match form.store_form().await { match form.store_form().await {
Ok(_) => info!("Successfully sent form to nextcloud!"), Ok(_) => info!("Successfully sent form to nextcloud!"),
Err(e) => error!("There was an erroring sending form to nextcloud: {e}"), Err(e) => error!("There was an erroring sending form to nextcloud: {e}"),
@ -188,9 +190,9 @@ mod test {
fn form() -> MtTeacherForm { fn form() -> MtTeacherForm {
MtTeacherForm { MtTeacherForm {
first_name: Text(String::from("Frodo")), first_name: Text(String::from("Bilbo")),
last_name: Text(String::from("Braggins")), 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")), student_last_name: Text(String::from("Braggins")),
relationship: Text(String::from("Uncle")), relationship: Text(String::from("Uncle")),
positive: Text(String::from("Nimble and brave")), positive: Text(String::from("Nimble and brave")),

View file

@ -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<Text<String>>,
#[multipart(rename = "lastname")]
last_name: Option<Text<String>>,
#[multipart(rename = "studentfirstname")]
student_first_name: Option<Text<String>>,
#[multipart(rename = "studentlastname")]
student_last_name: Option<Text<String>>,
email: Option<Text<String>>,
authority: Option<Text<String>>,
positive: Option<Text<String>>,
negative: Option<Text<String>>,
#[multipart(rename = "family-relation")]
family_relation: Option<Text<String>>,
#[multipart(rename = "previous-trip-info")]
previous_trip_info: Option<Text<String>>,
#[multipart(rename = "trip-feelings")]
trip_feelings: Option<Text<String>>,
#[multipart(rename = "extra-info")]
notes: Option<Text<String>>,
}
#[post("/parent-form")]
pub async fn parent_form(MultipartForm(form): MultipartForm<ParentForm>) -> 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 <no-reply@mail.tfcconnection.org>"
.parse()
.unwrap(),
)
.to("Chris Cochrun <chris@tfcconnection.org>".parse().unwrap())
.to("Ethan Rose <ethan@tfcconnection.org>".parse().unwrap())
.subject(email_subject)
.multipart(multi)
{
let _ = send_email(m);
} else {
info!("Email incorrect");
}
HttpResponse::Ok().body("hi")
}

View file

@ -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<Text<String>>,
#[multipart(rename = "lastname")]
last_name: Option<Text<String>>,
#[multipart(rename = "studentfirstname")]
student_first_name: Option<Text<String>>,
#[multipart(rename = "studentlastname")]
student_last_name: Option<Text<String>>,
relationship: Option<Text<String>>,
attitudes: Option<Text<String>>,
positive: Option<Text<String>>,
negative: Option<Text<String>>,
#[multipart(rename = "team-challenges")]
team: Option<Text<String>>,
#[multipart(rename = "extra-info")]
notes: Option<Text<String>>,
}
#[post("/teacher-form")]
pub async fn teacher_form(MultipartForm(form): MultipartForm<TeacherForm>) -> 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 <no-reply@mail.tfcconnection.org>"
.parse()
.unwrap(),
)
.to("Chris Cochrun <chris@tfcconnection.org>".parse().unwrap())
.to("Ethan Rose <ethan@tfcconnection.org>".parse().unwrap())
.subject(email_subject)
.multipart(multi)
{
let _ = send_email(m);
} else {
info!("Email incorrect");
}
HttpResponse::Ok().body("hi")
}

View file

@ -7,12 +7,13 @@ use actix_web::body::MessageBody;
use actix_web::dev::{ServiceRequest, ServiceResponse}; use actix_web::dev::{ServiceRequest, ServiceResponse};
use actix_web::{web, App, Error, HttpServer}; use actix_web::{web, App, Error, HttpServer};
use api::camp_form::camp_form; use api::camp_form::camp_form;
use api::church_form::church_form;
use api::health_form::health_form; use api::health_form::health_form;
use api::local_trip_form::local_form; use api::local_trip_form::local_form;
use api::mt_form::mt_form; use api::mt_form::mt_form;
use api::parent_form::parent_form; use api::{
use api::teacher_form::teacher_form; 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::eyre::Context;
use color_eyre::Result; use color_eyre::Result;
use sqlx::{Connection, SqliteConnection}; use sqlx::{Connection, SqliteConnection};
@ -89,9 +90,9 @@ async fn main() -> std::io::Result<()> {
.app_data(TempFileConfig::default().directory("./tmp")) .app_data(TempFileConfig::default().directory("./tmp"))
.service(mt_form) .service(mt_form)
.service(health_form) .service(health_form)
.service(parent_form) .service(mt_parent_form)
.service(teacher_form) .service(mt_teacher_form)
.service(church_form) .service(mt_church_form)
.service(local_form) .service(local_form)
.service(camp_form) .service(camp_form)
.service(Files::new("/", "./public").index_file("index.html")) .service(Files::new("/", "./public").index_file("index.html"))