From 7eb3146899ad26164dc48febf0fedbd0b091d2e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexa=20Valentov=C3=A1?= <git@imaniti.org>
Date: Tue, 10 Dec 2024 12:40:28 +0100
Subject: [PATCH] add email settings

---
 README.md                                     |   6 +-
 .../migrations/0138_maincareerpage_content.py |  19 ++
 main/models.py                                |  24 ++-
 main/templates/main/main_career_page.html     | 201 ++++++++++++++++++
 majak/settings/base.py                        |   9 +-
 .../includes/atoms/buttons/round_button.html  |   5 +
 .../molecules/boxes/main/career_box.html      |  14 +-
 .../organisms/header/main/career_header.html  |   7 +
 8 files changed, 272 insertions(+), 13 deletions(-)
 create mode 100644 main/migrations/0138_maincareerpage_content.py
 create mode 100644 main/templates/main/main_career_page.html
 create mode 100644 shared/templates/styleguide2/includes/organisms/header/main/career_header.html

diff --git a/README.md b/README.md
index 50f9cdaa..ba48d873 100644
--- a/README.md
+++ b/README.md
@@ -148,6 +148,10 @@ V produkci musí být navíc nastaveno:
 | `DJANGO_ALLOWED_HOSTS` | | allowed hosts (více hodnot odděleno čárkami) |
 | `CELERY_BROKER_URL` | | URL pro Celery Broker |
 | `CELERY_RESULT_BACKEND` | | URL pro Celery Result Backend |
+| `EMAIL_HOST` | SMTP pro odesílání přihlášek do kariér |
+| `EMAIL_HOST_USER` | --||-- Username |
+| `EMAIL_HOST_PASSWORD` | --||-- Heslo |
+| `EMAIL_PORT` | --||-- Port |
 
 Různé:
 
@@ -177,8 +181,6 @@ Přes CRON je třeba na pozadí spouštět Django `manage.py` commandy:
 * `update_callendars` - stáhne a aktualizuje kalendáře (několikrát denně)
 * `update_main_timeline_articles` - aktualizuje články na `pirati.cz` z `https://piratipracuji.cz/api/`
 * `update_redmine_issues` - aktualizuje programované body MS a KS stránek napojených na Redmine (několikrát denně)
-* `update_tweets` - aktualizuje tweety podle nastavení na Homepage pirati.cz - vyžaduje mít v .env TWITTER_BEARER_TOKEN, parametr --days určuje stáří tweetů (default 1)
-* `update_instagram` - aktualizuje Instagramové posty na Homepage pirati.cz.
 
 ### Fulltextové vyhledávání v češtině
 
diff --git a/main/migrations/0138_maincareerpage_content.py b/main/migrations/0138_maincareerpage_content.py
new file mode 100644
index 00000000..283c67b8
--- /dev/null
+++ b/main/migrations/0138_maincareerpage_content.py
@@ -0,0 +1,19 @@
+# Generated by Django 5.0.7 on 2024-12-10 07:37
+
+import wagtail.fields
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('main', '0137_maincareerspage_perex_col_1_and_more'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='maincareerpage',
+            name='content',
+            field=wagtail.fields.RichTextField(blank=True, verbose_name='Text nabĂ­dky'),
+        ),
+    ]
diff --git a/main/models.py b/main/models.py
index a93c8640..4920c4a7 100644
--- a/main/models.py
+++ b/main/models.py
@@ -11,6 +11,7 @@ from wagtailmetadata.models import MetadataPageMixin
 from datetime import date
 
 from shared import blocks as shared_blocks
+from shared.const import RICH_TEXT_DEFAULT_FEATURES
 from shared.models import (  # MenuMixin,
     ArticleMixin,
     ExtendedMetadataHomePageMixin,
@@ -92,6 +93,11 @@ class MainHomePage(MainHomePageMixin):
     class Meta:
         verbose_name = "HomePage pirati.cz"
 
+
+    @property
+    def careers_page(self):
+        return self._first_subpage_of_type(MainCareersPage)
+
     @property
     def article_page_model(self):
         return MainArticlePage
@@ -488,14 +494,28 @@ class MainCareerPage(
         default=date.today
     )
 
+    content = RichTextField(
+        "Text nabĂ­dky",
+        blank=True,
+        features=RICH_TEXT_DEFAULT_FEATURES
+    )
+
     content_panels = Page.content_panels + [
+        MultiFieldPanel(
+            [
+                FieldPanel("submission_end_date"),
+                FieldPanel("created_date"),
+            ],
+            "Datumy"
+        ),
+
         FieldPanel("category"),
         FieldPanel("location"),
         FieldPanel("time_cost"),
         FieldPanel("employment_relationship"),
         FieldPanel("pay_rate"),
-        FieldPanel("submission_end_date"),
-        FieldPanel("created_date"),
+
+        FieldPanel("content"),
     ]
 
     parent_page_types = ["main.MainCareersPage"]
diff --git a/main/templates/main/main_career_page.html b/main/templates/main/main_career_page.html
new file mode 100644
index 00000000..98503165
--- /dev/null
+++ b/main/templates/main/main_career_page.html
@@ -0,0 +1,201 @@
+{% extends "styleguide2/base.html" %}
+{% load wagtailcore_tags %}
+
+{% block content %}
+  {% block navbar %}
+    {% include 'styleguide2/includes/organisms/layout/navbar.html' with selected_item=page.get_menu_title %}
+  {% endblock %}
+
+  {% block header %}
+    {% include 'styleguide2/includes/organisms/header/main/career_header.html' with title=page.title %}
+  {% endblock %}
+
+  <main role="main">
+        <section class="container--wide mb-4 xl:mb-20">
+            <div class="text-lg mb-6">
+                <strong>Přihlášky do</strong>: {{ page.submission_end_date }}<br>
+                <strong>Zveřejněno</strong>: {{ page.created_date }}<br>
+            </div>
+
+            <div class="mb-6">
+                {{ page.content|richtext }}
+            </div>
+
+            <div data-micromodal-trigger="modal-1" class="lg:mb-3 mb-12">
+                {% include "styleguide2/includes/atoms/buttons/round_button.html" with text="Přihlásit se" show_arrow_on_hover=True %}
+            </div>
+        </section>
+    </main>
+
+    <div class="modal micromodal-slide" id="modal-1" aria-hidden="true">
+        <div class="modal__overlay" tabindex="-1">
+            <form
+                class="modal__container"
+                role="dialog"
+                aria-modal="true"
+                aria-labelledby="modal-1-title"
+                method="POST"
+                action=""
+            >
+                <header class="modal__header">
+                    <h2 class="modal__title" id="modal-1-title">
+                        Přihlásit se
+                    </h2>
+                    <button class="modal__close" aria-label="Close modal" data-micromodal-close></button>
+                </header>
+                <main class="modal__content mb-6" id="modal-1-content">
+                    <div class="form_control">
+                        <section
+                            class="
+                                flex gap-4 flex-nowrap flex-col w-full
+                                
+                                lg:flex-row lg:gap-2
+                            "
+                        >
+                            <div class="lg:w-auto w-full">
+                                <input
+                                    type="text"
+                                    name="name"
+                                    maxlength="256"
+                                    placeholder="Jméno"
+                                    id="id_name"
+                                    class="lg:w-auto w-full"
+                                    required
+                                >
+                            </div>
+                            <div class="lg:w-auto w-full">
+                                <input
+                                    type="text"
+                                    name="surname"
+                                    maxlength="256"
+                                    placeholder="Příjmení"
+                                    id="id_surname"
+                                    class="lg:w-auto w-full"
+                                    required
+                                >
+                            </div>
+                        </section>
+                        <section>
+                            <div class="w-full">
+                                <input
+                                    class="w-full"
+                                    type="email"
+                                    name="email"
+                                    maxlength="256"
+                                    id="id_email"
+                                    placeholder="E-mail"
+                                    required
+                                >
+                            </div>
+                        </section>
+                        <section>
+                            <div class="w-full">
+                                <input
+                                    class="w-full"
+                                    type="tel"
+                                    name="phone"
+                                    maxlength="19"
+                                    id="id_phone"
+                                    placeholder="Telefon"
+                                    required
+                                >
+                            </div>
+                        </section>
+                        <section>
+                            <div class="w-full">
+                                <textarea
+                                    class="w-full"
+                                    name="custom_text"
+                                    maxlength="65535"
+                                    id="id_custom_text"
+                                    placeholder="VlastnĂ­ text (nepovinnĂ˝)"
+                                ></textarea>
+                            </div>
+                        </section>
+                        <section class="flex flex-col gap-3 lg:items-center lg:flex-row">
+                            <label
+                                class="w-36"
+                                for="cv"
+                                id="cv_label"
+                            >CV: </label>
+    
+                            <input
+                                type="file"
+                                id="cv"
+                                name="cv"
+                                aria-labelledby="cv_label"
+                                class="max-w-64 mr-auto overflow-hidden break-words"
+                                required
+                            >
+    
+                            <small class="text-grey-300">(Povinné)</small>
+                        </section>
+                        <section class="flex flex-col gap-3 lg:items-center lg:flex-row">
+                            <label
+                                class="w-36"
+                                id="cover_letter_label"
+                                for="cover_letter"
+                            >Mot. dopis: </label>
+    
+                            <input
+                                type="file"
+                                id="cover_letter"
+                                name="cover_letter"
+                                aria-labelledby="cover_letter_label"
+                                class="max-w-64 mr-auto overflow-hidden break-words"
+                                required
+                            >
+    
+                            <small class="text-grey-300">(PovinnĂ˝)</small>
+                        </section>
+                        <section class="flex flex-col gap-3 lg:items-center lg:flex-row">
+                            <label
+                                class="w-36"
+                                id="other_files_label"
+                                for="other_files"
+                            >OstatnĂ­ soubory: </label>
+    
+                            <input
+                                type="file"
+                                id="other_files"
+                                name="other_files"
+                                aria-labelledby="other_files_label"
+                                class="max-w-64 mr-auto overflow-hidden break-words"
+                                multiple
+                            >
+                        </section>
+    
+                        <section class="flex flex-row gap-3 items-start leading-none">
+                            <input
+                                type="checkbox"
+                                id="personal_data_agreement"
+                                name="personal_data_agreement"
+                                aria-labelledby="personal_data_agreement_label"
+                                required
+                            >
+    
+                            <label
+                                for="personal_data_agreement"
+                            >Souhlasím se zpracováním osobním údajů (povinné)</label>
+                        </section>
+                    </div>
+                </main>
+                <footer
+                    class="
+                        modal__footer flex gap-2 justify-end flex-col items-end
+                        
+                        lg:items-start lg:gap-4 lg:flex-row
+                    "
+                >
+                    <div data-micromodal-close>
+                        {% include "styleguide2/includes/atoms/buttons/round_button_form.html" with type="button" text="Zrušit" show_arrow_on_hover=True %}
+                    </div>
+                    <div>
+                        {% include "styleguide2/includes/atoms/buttons/round_button_form.html" with type="submit" fill="#fff" classes="bg-pirati-yellow text-black" text="Odeslat přihlášku" %}
+                    </div>
+                </footer>
+            </form>
+        </div>
+    </div>
+
+{% endblock %}
diff --git a/majak/settings/base.py b/majak/settings/base.py
index 0c69ff0c..939d0729 100644
--- a/majak/settings/base.py
+++ b/majak/settings/base.py
@@ -168,9 +168,12 @@ DATA_UPLOAD_MAX_NUMBER_FIELDS = None
 
 # EMAIL
 # ------------------------------------------------------------------------------
-EMAIL_BACKEND = env(
-    "DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.dummy.EmailBackend"
-)
+EMAIL_HOST = env.str("EMAIL_HOST", "")
+EMAIL_HOST_USER = env.str("EMAIL_HOST_USER", "")
+EMAIL_HOST_PASSWORD = env.str("EMAIL_HOST_PASSWORD", "")
+EMAIL_PORT = env.str("EMAIL_PORT", "")
+EMAIL_SUBJECT_PREFIX = env.str("EMAIL_SUBJECT_PREFIX", "[Piráti] ")
+
 
 # LOGGING
 # ------------------------------------------------------------------------------
diff --git a/shared/templates/styleguide2/includes/atoms/buttons/round_button.html b/shared/templates/styleguide2/includes/atoms/buttons/round_button.html
index 747c421c..8a1a39bf 100644
--- a/shared/templates/styleguide2/includes/atoms/buttons/round_button.html
+++ b/shared/templates/styleguide2/includes/atoms/buttons/round_button.html
@@ -1,5 +1,10 @@
 <{% block element_opener %}a{% endblock %}
   {% block href %}href="{% if url %}{{ url }}{% else %}#{% endif %}"{% endblock %}
+
+  {% if type %}
+    type="{{ type }}"
+  {% endif %}
+
   class="
     flex items-center group rounded-full font-condensed uppercase font-semibold tracking-normal
     hover:no-underline max-w-max
diff --git a/shared/templates/styleguide2/includes/molecules/boxes/main/career_box.html b/shared/templates/styleguide2/includes/molecules/boxes/main/career_box.html
index 36e3c138..6107ce37 100644
--- a/shared/templates/styleguide2/includes/molecules/boxes/main/career_box.html
+++ b/shared/templates/styleguide2/includes/molecules/boxes/main/career_box.html
@@ -2,23 +2,25 @@
     class="p-6 bg-black text-white flex flex-col gap-2"
 >
     <div class="flex justify-between">
-        <div class="text-xl font-bold">{{ career_offer.name }}</div>
-        <div class="text-xl font-bold">{{ career_offer.location }}</div>
+        <div class="text-xl font-bold">{{ career.title }}</div>
+        <div class="text-xl font-bold">{{ career.location }}</div>
     </div>
 
     <div class="text-xl p-4">
-        {{ career_offer.description|safe }}
+        <strong>Časová náročnost</strong>: {{ career.time_cost }}<br>
+        <strong>Poměr</strong>: {{ career.employment_relationship }}<br>
+        <strong>Plat</strong>: {{ career.pay_rate }}<br>
     </div>
 
     <div class="flex justify-between items-end">
         <div>
             <em>
-                Prihlášky do: {{ career_offer.applications_until }}<br>
-                Zveřejněno: {{ career_offer.created_on }}
+                Prihlášky do: {{ career.submission_end_date }}<br>
+                Zveřejněno: {{ career.created_date }}
             </em>
         </div>
         <div>
-            {% include "patterns/atoms/buttons/round_button.html" with fill="#fff" classes="bg-pirati-yellow text-black" button_text="VĂ­ce" url=career_offer.url %}
+            {% include "styleguide2/includes/atoms/buttons/round_button.html" with fill="#fff" classes="bg-pirati-yellow text-black" text="VĂ­ce" url=career.url show_arrow_on_hover=True %}
         </div>
     </div>
 </div>
\ No newline at end of file
diff --git a/shared/templates/styleguide2/includes/organisms/header/main/career_header.html b/shared/templates/styleguide2/includes/organisms/header/main/career_header.html
new file mode 100644
index 00000000..23898c67
--- /dev/null
+++ b/shared/templates/styleguide2/includes/organisms/header/main/career_header.html
@@ -0,0 +1,7 @@
+{% extends 'styleguide2/includes/organisms/header/simple_header.html' %}
+
+{% block before_heading %}
+  {% include 'styleguide2/includes/atoms/header/navigation.html' with classes='mb-6' first_text="PracovnĂ­ nabĂ­dky" first_link=page.root_page.careers_page.url second_text=page.created_date %}
+{% endblock %}
+
+{% block heading_classes %}head-8xl{% endblock %}
\ No newline at end of file
-- 
GitLab