From a689e77bef699526bfcf22eb13732b6297726d4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Farka?= <stepanfarka11@gmail.com>
Date: Wed, 25 May 2022 08:49:29 +0200
Subject: [PATCH] [ADD] custom urls to donate homepage header

---
 ...22_donatehomepage_custom_url_1_and_more.py | 41 +++++++++++++++++++
 donate/models.py                              | 17 ++++++++
 donate/templates/donate/base.html             |  8 ++++
 3 files changed, 66 insertions(+)
 create mode 100644 donate/migrations/0022_donatehomepage_custom_url_1_and_more.py

diff --git a/donate/migrations/0022_donatehomepage_custom_url_1_and_more.py b/donate/migrations/0022_donatehomepage_custom_url_1_and_more.py
new file mode 100644
index 00000000..96ad1c59
--- /dev/null
+++ b/donate/migrations/0022_donatehomepage_custom_url_1_and_more.py
@@ -0,0 +1,41 @@
+# Generated by Django 4.0.4 on 2022-05-25 06:46
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("donate", "0021_donatehomepage_support_image"),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name="donatehomepage",
+            name="custom_url_1",
+            field=models.URLField(
+                blank=True, null=True, verbose_name="Vlastní odkaz 1"
+            ),
+        ),
+        migrations.AddField(
+            model_name="donatehomepage",
+            name="custom_url_1_text",
+            field=models.CharField(
+                blank=True, max_length=128, verbose_name="Text vlastního odkazu 1"
+            ),
+        ),
+        migrations.AddField(
+            model_name="donatehomepage",
+            name="custom_url_2",
+            field=models.URLField(
+                blank=True, null=True, verbose_name="Vlastní odkaz 2"
+            ),
+        ),
+        migrations.AddField(
+            model_name="donatehomepage",
+            name="custom_url_2_text",
+            field=models.CharField(
+                blank=True, max_length=128, verbose_name="Text vlastního odkazu 2"
+            ),
+        ),
+    ]
diff --git a/donate/models.py b/donate/models.py
index 20c82315..431a3bba 100644
--- a/donate/models.py
+++ b/donate/models.py
@@ -129,6 +129,14 @@ class DonateHomePage(
     region_title = models.CharField("podpoř kraj nadpis", max_length=250, blank=True)
     region_body = models.TextField("podpoř kraj popis", blank=True)
     # settings
+    custom_url_1 = models.URLField("Vlastní odkaz 1", blank=True, null=True)
+    custom_url_1_text = models.CharField(
+        "Text vlastního odkazu 1", max_length=128, blank=True
+    )
+    custom_url_2 = models.URLField("Vlastní odkaz 2", blank=True, null=True)
+    custom_url_2_text = models.CharField(
+        "Text vlastního odkazu 2", max_length=128, blank=True
+    )
     facebook = models.URLField("Facebook URL", blank=True, null=True)
     instagram = models.URLField("Instagram URL", blank=True, null=True)
     twitter = models.URLField("Twitter URL", blank=True, null=True)
@@ -170,6 +178,15 @@ class DonateHomePage(
     promote_panels = make_promote_panels(admin_help.build(admin_help.IMPORTANT_TITLE))
 
     settings_panels = [
+        MultiFieldPanel(
+            [
+                FieldPanel("custom_url_1"),
+                FieldPanel("custom_url_1_text"),
+                FieldPanel("custom_url_2"),
+                FieldPanel("custom_url_2_text"),
+            ],
+            "vlastní odkazy",
+        ),
         MultiFieldPanel(
             [
                 FieldPanel("facebook"),
diff --git a/donate/templates/donate/base.html b/donate/templates/donate/base.html
index bb2a2117..00345f73 100644
--- a/donate/templates/donate/base.html
+++ b/donate/templates/donate/base.html
@@ -58,6 +58,14 @@
   {% block header %}
   <div class="pre-navbar d-none d-lg-flex" style="background:black;">
     <div class="container d-flex justify-content-end">
+        {% if page.root_page.custom_url_1 and page.root_page.custom_url_1_text %}
+            <a href="{{ page.root_page.custom_url_1 }}" class="header_link header_link--desktop mr-4 py-2" target="_blank"
+               rel="noreferrer"><i class="icon-external-link mr-2" title="Ikona odkazu"></i>{{ page.root_page.custom_url_1_text }}</a>
+        {% endif %}
+        {% if page.root_page.custom_url_2 and page.root_page.custom_url_2_text %}
+            <a href="{{ page.root_page.custom_url_2 }}" class="header_link header_link--desktop mr-4 py-2" target="_blank"
+               rel="noreferrer"><i class="icon-external-link mr-2" title="Ikona odkazu"></i>{{ page.root_page.custom_url_2_text }}</a>
+        {% endif %}
       <a href="https://www.pirati.cz/" class="header_link header_link--desktop mr-4 py-2" target="_blank" rel="noreferrer"><i class="icon-external-link mr-2" title="Ikona odkazu"></i>www.pirati.cz</a>
     </div>
   </div>
-- 
GitLab