diff --git a/contracts/migrations/0038_alter_contract_agreement_url_and_more.py b/contracts/migrations/0038_alter_contract_agreement_url_and_more.py new file mode 100644 index 0000000000000000000000000000000000000000..162175a2ab1d1b692fdfd7261c6933696fd04144 --- /dev/null +++ b/contracts/migrations/0038_alter_contract_agreement_url_and_more.py @@ -0,0 +1,46 @@ +# Generated by Django 4.1.4 on 2023-04-12 09:04 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("contracts", "0037_alter_contractee_address_country_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="contract", + name="agreement_url", + field=models.URLField( + blank=True, + help_text="Běžně odkaz na fórum. Využívá se např. u koaličních smluv.", + max_length=256, + null=True, + validators=[django.core.validators.URLValidator(schemes=("https",))], + verbose_name="Odkaz na schválení", + ), + ), + 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, + validators=[django.core.validators.URLValidator(schemes=("https",))], + verbose_name="Odkaz na výběrové řízení", + ), + ), + migrations.AlterField( + model_name="contractintent", + name="url", + field=models.URLField( + max_length=256, + validators=[django.core.validators.URLValidator(schemes=("https",))], + verbose_name="Odkaz", + ), + ), + ] diff --git a/contracts/migrations/0039_alter_contract_agreement_url_and_more.py b/contracts/migrations/0039_alter_contract_agreement_url_and_more.py new file mode 100644 index 0000000000000000000000000000000000000000..1a647f02cedf3b87fa6c448099a303cd794a9ccb --- /dev/null +++ b/contracts/migrations/0039_alter_contract_agreement_url_and_more.py @@ -0,0 +1,47 @@ +# Generated by Django 4.1.4 on 2023-04-12 09:06 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("contracts", "0038_alter_contract_agreement_url_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="contract", + name="agreement_url", + field=models.URLField( + blank=True, + help_text="Běžně odkaz na fórum. Využívá se např. u koaličních smluv. Musí začínat <pre>https</pre>.", + max_length=256, + null=True, + validators=[django.core.validators.URLValidator(schemes=("https",))], + verbose_name="Odkaz na schválení", + ), + ), + 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>. Musí začínat <pre>https</pre>.', + max_length=256, + null=True, + validators=[django.core.validators.URLValidator(schemes=("https",))], + verbose_name="Odkaz na výběrové řízení", + ), + ), + migrations.AlterField( + model_name="contractintent", + name="url", + field=models.URLField( + help_text="Musí začínat <pre>https</pre>.", + max_length=256, + validators=[django.core.validators.URLValidator(schemes=("https",))], + verbose_name="Odkaz", + ), + ), + ] diff --git a/contracts/migrations/0040_alter_contract_agreement_url_and_more.py b/contracts/migrations/0040_alter_contract_agreement_url_and_more.py new file mode 100644 index 0000000000000000000000000000000000000000..d87675b04865066dacee7a29263683011de72e15 --- /dev/null +++ b/contracts/migrations/0040_alter_contract_agreement_url_and_more.py @@ -0,0 +1,47 @@ +# Generated by Django 4.1.4 on 2023-04-12 09:07 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("contracts", "0039_alter_contract_agreement_url_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="contract", + name="agreement_url", + field=models.URLField( + blank=True, + help_text="Běžně odkaz na fórum. Využívá se např. u koaličních smluv. Musí začínat <code>https</code>.", + max_length=256, + null=True, + validators=[django.core.validators.URLValidator(schemes=("https",))], + verbose_name="Odkaz na schválení", + ), + ), + 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>. Musí začínat <code>https</code>.', + max_length=256, + null=True, + validators=[django.core.validators.URLValidator(schemes=("https",))], + verbose_name="Odkaz na výběrové řízení", + ), + ), + migrations.AlterField( + model_name="contractintent", + name="url", + field=models.URLField( + help_text="Musí začínat <code>https</code>.", + max_length=256, + validators=[django.core.validators.URLValidator(schemes=("https",))], + verbose_name="Odkaz", + ), + ), + ] diff --git a/contracts/models.py b/contracts/models.py index f34cbe5396be95e05df7d4cb927e8a49a60006ec..b68ea27ee06a9e888dfd5a98bd7659427114230b 100644 --- a/contracts/models.py +++ b/contracts/models.py @@ -5,6 +5,7 @@ import typing from django.conf import settings from django.core.exceptions import ValidationError +from django.core.validators import URLValidator from django.db import models from django.db.models.signals import post_save from django.dispatch import receiver @@ -569,9 +570,11 @@ class Contract(NameStrMixin, models.Model): max_length=256, blank=True, null=True, + validators=(URLValidator(schemes=("https",)),), verbose_name="Odkaz na výběrové řízení", help_text=mark_safe( - 'Běžně odkaz na <a href="https://forum.pirati.cz/viewforum.php?f=572">fórum</a>.' + 'Běžně odkaz na <a href="https://forum.pirati.cz/viewforum.php?f=572">fórum</a>. ' + "Musí začínat <code>https</code>." ), ) @@ -579,8 +582,12 @@ class Contract(NameStrMixin, models.Model): max_length=256, blank=True, null=True, + validators=(URLValidator(schemes=("https",)),), verbose_name="Odkaz na schválení", - help_text="Běžně odkaz na fórum. Využívá se např. u koaličních smluv.", + help_text=mark_safe( + "Běžně odkaz na fórum. Využívá se např. u koaličních smluv. " + "Musí začínat <code>https</code>." + ), ) # WARNING: Dependent on the type! issues = models.ManyToManyField( @@ -992,6 +999,8 @@ class ContractIntent(NameStrMixin, models.Model): url = models.URLField( max_length=256, verbose_name="Odkaz", + validators=(URLValidator(schemes=("https",)),), + help_text=mark_safe("Musí začínat <code>https</code>."), ) contract = models.ForeignKey(