diff --git a/Dockerfile b/Dockerfile index a8a7883..05ef630 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,26 @@ -FROM python:3.11-alpine +FROM node:20-alpine AS email_builder + +RUN npm install -g mjml +RUN mkdir -p /app/templates/html + +COPY ./src/emails/templates/mjml /app/templates +RUN mjml /app/templates/* -o /app/templates/html/ + + +FROM python:3.11-alpine AS app RUN apk update && \ apk add --no-cache tzdata mariadb-client mariadb-dev && \ pip install --upgrade pip -# protoze xfs uzivatel ma id=33 + \ + # protoze xfs uzivatel ma id=33 RUN deluser xfs # uzivatel www-data v alpine neexistuje RUN delgroup www-data && addgroup -g 33 -S www-data && adduser -u 33 -D -S -G www-data www-data COPY requirements.txt /app/requirements.txt +COPY --from=email_builder /app/templates/html/ /app/src/email/templates/html/ # required packages for pip (becasue of yarl lib) ENV INSTALL_PACKAGES build-base linux-headers diff --git a/src/background_jobs/send_email.py b/src/background_jobs/send_email.py new file mode 100644 index 0000000..b8d9334 --- /dev/null +++ b/src/background_jobs/send_email.py @@ -0,0 +1,2 @@ +async def send_email(email): + pass \ No newline at end of file diff --git a/src/emails/templates/html/contact_form.html b/src/emails/templates/html/contact_form.html new file mode 100644 index 0000000..a4a5be0 --- /dev/null +++ b/src/emails/templates/html/contact_form.html @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + + + +
+
Hello World!
+
+
+ +
+
+ +
+ + + diff --git a/src/emails/templates/html/reset_password.html b/src/emails/templates/html/reset_password.html new file mode 100644 index 0000000..f8fc142 --- /dev/null +++ b/src/emails/templates/html/reset_password.html @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + + + +
+
Hello World!
+
+
+ +
+
+ +
+ + + diff --git a/src/emails/templates/html/welcome.html b/src/emails/templates/html/welcome.html new file mode 100644 index 0000000..f8fc142 --- /dev/null +++ b/src/emails/templates/html/welcome.html @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + + + +
+
Hello World!
+
+
+ +
+
+ +
+ + + diff --git a/src/emails/templates/mjml/contact_form.mjml b/src/emails/templates/mjml/contact_form.mjml new file mode 100644 index 0000000..9cdcb87 --- /dev/null +++ b/src/emails/templates/mjml/contact_form.mjml @@ -0,0 +1,22 @@ + + + + + + + + Zpráva z kontaktního formuláře | Polétání.cz + + + + Od: [from] + + + [content] + + + + + + + diff --git a/src/emails/templates/mjml/reset_password.mjml b/src/emails/templates/mjml/reset_password.mjml new file mode 100644 index 0000000..3873b41 --- /dev/null +++ b/src/emails/templates/mjml/reset_password.mjml @@ -0,0 +1,29 @@ + + + + + + + + Zapomenuté heslo | Polétání.cz + + + + +

+ Ahoj, +
+ Každý občas zapomíná. Heslo je to nejmenší. Klikni na následující tlačítko pro přihlášení do aplikace. A tam si budeš moct změnit heslo. +
+ Jen admin vyzaduje zadani stareho hesla, takze to nebude tak snadne... +

+
+ + Přihlásit se pomocí magického odkazu [login_token] + + +
+
+
+
+
diff --git a/src/emails/templates/mjml/welcome.mjml b/src/emails/templates/mjml/welcome.mjml new file mode 100644 index 0000000..ae413dd --- /dev/null +++ b/src/emails/templates/mjml/welcome.mjml @@ -0,0 +1,46 @@ + + + + + + + + Vítejte v aplikaci Polétání.cz! + + + Ahoj [Jméno], +
+ +

+ Vítejte v aplikaci Polétání.cz – místě, kde můžete sdílet své letecké dobrodružství a fotografie s ostatními nadšenci. +

+ +

+ Co můžete očekávat: +

+ +
    +
  • Jednoduché nahrávání a sdílení fotografií z vašich letů.
  • +
  • Možnost připojení k letištním komunitám a sdílení tipů a triků.
  • +
  • Upozornění na nové funkce a akce v aplikaci.
  • +
+ +

+ Začněte nyní a sdílejte své vzdušné zážitky s celým světem! +

+ +

+ S pozdravem, +
+ Tým Polétání.cz +

+
+ + Přihlásit se do Polétání.cz + + +
+
+
+
+
diff --git a/src/emails/welcome.py b/src/emails/welcome.py new file mode 100644 index 0000000..ab7412b --- /dev/null +++ b/src/emails/welcome.py @@ -0,0 +1,39 @@ +class Email: + def __init__(self, subject: str, to: str, template: str, template_variables: dict): + self.subject = subject + " | Polétání.cz" + self.to = to + self.template = template + self.template_variables = template_variables + + def get_template_content(self) -> str: + return "" + + +class ContactFormEmail(Email): + def __init__(self, template_variables: dict): + super().__init__( + subject="Zpráva z kontaktního formuláře", + to="michal@kvacek.cz", + template="contact_form.html", + template_variables=template_variables + ) + + +class WelcomeEmail(Email): + def __init__(self, to: str, template_variables: dict): + super().__init__( + subject="Vítej", + to=to, + template="welcome.html", + template_variables=template_variables + ) + + +class ResetPasswordEmail(Email): + def __init__(self, to: str, template_variables: dict): + super().__init__( + subject="Reset hesla", + to=to, + template="reset_password.html", + template_variables=template_variables + ) diff --git a/src/endpoints/registration.py b/src/endpoints/registration.py index 5dce9a4..c4b6927 100644 --- a/src/endpoints/registration.py +++ b/src/endpoints/registration.py @@ -38,4 +38,7 @@ class RegistrationEndpoint: "password_hashed": bcrypt.hash(user_data.password), "description": "" }) + + # TODO: odeslat WelcomeEmail + return model.as_dict()