From 5e96eae9767d7d2bac884d6a5ce31a3edc9120ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexa=20Valentov=C3=A1?= <git@imaniti.org>
Date: Mon, 17 Feb 2025 18:38:12 +0100
Subject: [PATCH 1/3] add recipient email

---
 main/models.py | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/main/models.py b/main/models.py
index c752cd33..b7344365 100644
--- a/main/models.py
+++ b/main/models.py
@@ -620,7 +620,26 @@ class MainCareerPage(
                 for file in form.cleaned_data["other_files"]:
                     other_files_names += f"        - {file.name}\n"
 
-                email = EmailMessage(
+                recipient_email = EmailMessage(
+                    # Subject
+                    f"Potvrzení přihlášky k pracovní pozici {self.title}",
+                    # Message
+                    f"""
+Dobrý den,
+
+potvrzujeme přijetí Vaší přihlášky k pracovní pozici '{self.title}'.
+Budeme vás co nejdříve kontaktovat s dalšími informacemi.
+
+Děkujeme,
+Pirátská Strana
+""",
+                    # From email
+                    "vyberka@pirati.cz",
+                    # To email
+                    form.cleaned_data['email']
+                )
+
+                administrator_email = EmailMessage(
                     # Subject
                     f"Nová přihláška k pracovní pozici {self.title} - {form.cleaned_data['name']} {form.cleaned_data['surname']}",
                     # Message
@@ -654,14 +673,14 @@ Při otevírání souborů buďte opatrní, virový proběhl, ale nemusí být p
                 )
 
                 form.cleaned_data["cv_file"].seek(0)
-                email.attach(
+                administrator_email.attach(
                     form.cleaned_data["cv_file"].name,
                     form.cleaned_data["cv_file"].read(),
                     form.cleaned_data["cv_file"].content_type,
                 )
 
                 form.cleaned_data["cover_letter_file"].seek(0)
-                email.attach(
+                administrator_email.attach(
                     form.cleaned_data["cover_letter_file"].name,
                     form.cleaned_data["cover_letter_file"].read(),
                     form.cleaned_data["cover_letter_file"].content_type,
@@ -669,9 +688,12 @@ Při otevírání souborů buďte opatrní, virový proběhl, ale nemusí být p
 
                 for file in form.cleaned_data["other_files"]:
                     file.seek(0)
-                    email.attach(file.name, file.read(), file.content_type)
+                    administrator_email.attach(file.name, file.read(), file.content_type)
 
-                sent_successfully = email.send()
+                sent_successfully = (
+                    administrator_email.send()
+                    and recipient_email.send()
+                )
 
                 if sent_successfully:
                     messages.add_message(
-- 
GitLab


From 9afb5b55b9a0f012328ec6eb07d79c9762d55a79 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexa=20Valentov=C3=A1?= <git@imaniti.org>
Date: Mon, 17 Feb 2025 19:07:55 +0100
Subject: [PATCH 2/3] fix recipients

---
 main/models.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main/models.py b/main/models.py
index b7344365..ff64d2be 100644
--- a/main/models.py
+++ b/main/models.py
@@ -669,7 +669,7 @@ Při otevírání souborů buďte opatrní, virový proběhl, ale nemusí být p
                     # From email
                     "vyberka@pirati.cz",
                     # Recipient list
-                    self.recipient_emails.split(","),
+                    [self.recipient_emails.split(",")],
                 )
 
                 form.cleaned_data["cv_file"].seek(0)
-- 
GitLab


From 245eff74a7add24ea0434dc3fedc87b9289f5dc3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexa=20Valentov=C3=A1?= <git@imaniti.org>
Date: Mon, 17 Feb 2025 19:26:30 +0100
Subject: [PATCH 3/3] fix recipients (again)

---
 main/models.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/main/models.py b/main/models.py
index ff64d2be..d23252bb 100644
--- a/main/models.py
+++ b/main/models.py
@@ -636,7 +636,7 @@ Pirátská Strana
                     # From email
                     "vyberka@pirati.cz",
                     # To email
-                    form.cleaned_data['email']
+                    [form.cleaned_data['email']],
                 )
 
                 administrator_email = EmailMessage(
@@ -669,7 +669,7 @@ Při otevírání souborů buďte opatrní, virový proběhl, ale nemusí být p
                     # From email
                     "vyberka@pirati.cz",
                     # Recipient list
-                    [self.recipient_emails.split(",")],
+                    self.recipient_emails.split(","),
                 )
 
                 form.cleaned_data["cv_file"].seek(0)
-- 
GitLab