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

@ -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<MtChurchForm>) -> HttpResponse {
#[post("/api/mt-church-form")]
pub async fn mt_church_form(MultipartForm(mut form): MultipartForm<MtChurchForm>) -> 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")),