From 5e657010290550d88457c873cb96403715b0a3e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Valenta?= <git@imaniti.org>
Date: Tue, 11 Apr 2023 00:32:30 +0200
Subject: [PATCH] add help information

---
 ..._alter_contract_valid_end_date_and_more.py | 23 ++++++++++
 .../0036_alter_contract_tender_url.py         | 18 ++++++++
 contracts/models.py                           | 13 +++++-
 static_src/admin/contract_form.js             | 43 -------------------
 4 files changed, 53 insertions(+), 44 deletions(-)
 create mode 100644 contracts/migrations/0035_alter_contract_valid_end_date_and_more.py
 create mode 100644 contracts/migrations/0036_alter_contract_tender_url.py

diff --git a/contracts/migrations/0035_alter_contract_valid_end_date_and_more.py b/contracts/migrations/0035_alter_contract_valid_end_date_and_more.py
new file mode 100644
index 0000000..4fb5f37
--- /dev/null
+++ b/contracts/migrations/0035_alter_contract_valid_end_date_and_more.py
@@ -0,0 +1,23 @@
+# Generated by Django 4.1.4 on 2023-04-10 22:30
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('contracts', '0034_alter_contract_agreement_url_and_more'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='contract',
+            name='valid_end_date',
+            field=models.DateField(blank=True, help_text='<strong>Pokud není konec účinnosti zadán, smlouva je evidována jako na dobu neurčitou.</strong>', null=True, verbose_name='Konec účinnosti'),
+        ),
+        migrations.AlterField(
+            model_name='contract',
+            name='valid_start_date',
+            field=models.DateField(blank=True, help_text='<strong>Pokud není začátek účinnosti zadán, vypočítá se automaticky podle posledního data podpisu.</strong>', null=True, verbose_name='Začátek účinnosti'),
+        ),
+    ]
diff --git a/contracts/migrations/0036_alter_contract_tender_url.py b/contracts/migrations/0036_alter_contract_tender_url.py
new file mode 100644
index 0000000..7faca40
--- /dev/null
+++ b/contracts/migrations/0036_alter_contract_tender_url.py
@@ -0,0 +1,18 @@
+# Generated by Django 4.1.4 on 2023-04-10 22:31
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('contracts', '0035_alter_contract_valid_end_date_and_more'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='contract',
+            name='tender_url',
+            field=models.URLField(blank=True, help_text='Běžně odkaz na <a href="https://forum.pirati.cz/viewforum.php?f=572">fórum</a>.', max_length=256, null=True, verbose_name='Odkaz na výběrové řízení'),
+        ),
+    ]
diff --git a/contracts/models.py b/contracts/models.py
index e1129e8..98c1c0d 100644
--- a/contracts/models.py
+++ b/contracts/models.py
@@ -9,6 +9,7 @@ from django.db import models
 from django.db.models.signals import post_save
 from django.dispatch import receiver
 from django.urls import reverse
+from django.utils.safestring import mark_safe
 from markdownx.models import MarkdownxField
 
 from shared.models import NameStrMixin
@@ -477,11 +478,19 @@ class Contract(NameStrMixin, models.Model):
         blank=True,
         null=True,
         verbose_name="Začátek účinnosti",
+        help_text=mark_safe(
+            "<strong>Pokud není začátek účinnosti zadán, vypočítá se automaticky "
+            "podle posledního data podpisu.</strong>"
+        )
     )
     valid_end_date = models.DateField(
         blank=True,
         null=True,
         verbose_name="Konec účinnosti",
+        help_text=mark_safe(
+            "<strong>Pokud není konec účinnosti zadán, smlouva je evidována jako "
+            "na dobu neurčitou.</strong>"
+        )
     )
 
     class LegalStates(models.TextChoices):
@@ -531,7 +540,9 @@ class Contract(NameStrMixin, models.Model):
         blank=True,
         null=True,
         verbose_name="Odkaz na výběrové řízení",
-        help_text="Běžně odkaz na fórum."
+        help_text=mark_safe(
+            "Běžně odkaz na <a href=\"https://forum.pirati.cz/viewforum.php?f=572\">fórum</a>."
+        )
     )
 
     agreement_url = models.URLField(
diff --git a/static_src/admin/contract_form.js b/static_src/admin/contract_form.js
index f1ea5a4..dde148d 100644
--- a/static_src/admin/contract_form.js
+++ b/static_src/admin/contract_form.js
@@ -1,13 +1,7 @@
 import $ from "jquery";
 
-import alertify from "alertifyjs";
-import "alertifyjs/build/css/alertify.min.css";
-
 $(window).ready(
     () => {
-        let startDateWarningDismissed = false;
-        let endDateWarningDismissed = false;
-
         $(".field-publishing_rejection_comment").
         css(
             "display",
@@ -61,42 +55,5 @@ $(window).ready(
                 if (!otherIsSelected) $(".field-cost_unit_other").val("");
             }
         );
-
-        $(
-            "#contract_form .submit-row input[name=\"_save\"],"
-            + "#contract_form .submit-row input[name=\"_addanother\"],"
-            + "#contract_form .submit-row input[name=\"_continue\"]"
-        ).on(
-            "click",
-            event => {
-                if (!startDateWarningDismissed && $("#id_valid_start_date").val() === "") {
-                    event.preventDefault();
-
-                    alertify.alert(
-                        "Začátek platnosti není zadán",
-                        `Začátek platnosti nebyl uveden. Pokud ho necháš tak, jak je,
-bude automaticky vyplněn podle posledního data
-podpisu smluvních stran. Pokud podpisy neexistují,
-pole zůstane prázdné.`,
-                        () => {
-                            startDateWarningDismissed = true;
-                        }
-                    );
-                }
-
-                if (!endDateWarningDismissed && $("#id_valid_end_date").val() === "") {
-                    event.preventDefault();
-
-                    alertify.alert(
-                        "Konec platnosti není zadán",
-                        `Konec platnosti nebyl uveden. Pokud ho necháš tak, jak je,
-smlouva bude evidována jako na dobu neurčitou.`,
-                        () => {
-                            endDateWarningDismissed = true;
-                        }
-                    );
-                }
-            }
-        )
     }
 );
-- 
GitLab