From 9fa33214a60ed2a1a24a54a17720e21184e1f2f3 Mon Sep 17 00:00:00 2001 From: Paul Schreiber Date: Wed, 4 Sep 2024 11:52:47 -0400 Subject: [PATCH] fix: replace CheckConstraint.check with CheckConstraint.condition and add FORMS_URLFIELD_ASSUME_HTTPS (#1445) * fix: change check to condition fixes RemovedInDjango60Warning: CheckConstraint.check is deprecated in favor of `.condition`. * fix: add FORMS_URLFIELD_ASSUME_HTTPS setting fixes RemovedInDjango60Warning: The default scheme will be changed from 'http' to 'https' in Django 6.0. Pass the forms.URLField.assume_scheme argument to silence this warning, or set the FORMS_URLFIELD_ASSUME_HTTPS transitional setting to True to opt into using 'https' as the new default scheme. * style: fix whitespace --- ...e_project_management_site_unique_active_slug_and_more.py | 2 +- .../0003_alter_depthdependentsoildata_options_and_more.py | 2 +- ...005_projectdepthinterval_projectsoilsettings_and_more.py | 6 +++--- terraso_backend/apps/soil_id/models/depth_interval.py | 2 +- terraso_backend/config/settings.py | 3 +++ 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/terraso_backend/apps/project_management/migrations/0003_remove_site_project_management_site_unique_active_slug_and_more.py b/terraso_backend/apps/project_management/migrations/0003_remove_site_project_management_site_unique_active_slug_and_more.py index 562750ba5..eeedabc22 100644 --- a/terraso_backend/apps/project_management/migrations/0003_remove_site_project_management_site_unique_active_slug_and_more.py +++ b/terraso_backend/apps/project_management/migrations/0003_remove_site_project_management_site_unique_active_slug_and_more.py @@ -49,7 +49,7 @@ class Migration(migrations.Migration): migrations.AddConstraint( model_name="site", constraint=models.CheckConstraint( - check=models.Q( + condition=models.Q( models.Q(("project__isnull", False), ("owner__isnull", False), _connector="OR"), models.Q(("project__isnull", True), ("owner__isnull", True), _connector="OR"), ), diff --git a/terraso_backend/apps/soil_id/migrations/0003_alter_depthdependentsoildata_options_and_more.py b/terraso_backend/apps/soil_id/migrations/0003_alter_depthdependentsoildata_options_and_more.py index 26da98af1..f6d1cd923 100644 --- a/terraso_backend/apps/soil_id/migrations/0003_alter_depthdependentsoildata_options_and_more.py +++ b/terraso_backend/apps/soil_id/migrations/0003_alter_depthdependentsoildata_options_and_more.py @@ -499,7 +499,7 @@ class Migration(migrations.Migration): migrations.AddConstraint( model_name="depthdependentsoildata", constraint=models.CheckConstraint( - check=models.Q(("depth_start__lt", models.F("depth_end"))), + condition=models.Q(("depth_start__lt", models.F("depth_end"))), name="depth_interval_coherence", ), ), diff --git a/terraso_backend/apps/soil_id/migrations/0005_projectdepthinterval_projectsoilsettings_and_more.py b/terraso_backend/apps/soil_id/migrations/0005_projectdepthinterval_projectsoilsettings_and_more.py index 54fb39744..88ad8eba9 100644 --- a/terraso_backend/apps/soil_id/migrations/0005_projectdepthinterval_projectsoilsettings_and_more.py +++ b/terraso_backend/apps/soil_id/migrations/0005_projectdepthinterval_projectsoilsettings_and_more.py @@ -205,7 +205,7 @@ class Migration(migrations.Migration): migrations.AddConstraint( model_name="depthdependentsoildata", constraint=models.CheckConstraint( - check=models.Q(("depth_interval_start__lt", models.F("depth_interval_end"))), + condition=models.Q(("depth_interval_start__lt", models.F("depth_interval_end"))), name="soil_id_depthdependentsoildata_depth_interval_coherence", ), ), @@ -247,7 +247,7 @@ class Migration(migrations.Migration): migrations.AddConstraint( model_name="soildatadepthinterval", constraint=models.CheckConstraint( - check=models.Q(("depth_interval_start__lt", models.F("depth_interval_end"))), + condition=models.Q(("depth_interval_start__lt", models.F("depth_interval_end"))), name="soil_id_soildatadepthinterval_depth_interval_coherence", ), ), @@ -262,7 +262,7 @@ class Migration(migrations.Migration): migrations.AddConstraint( model_name="projectdepthinterval", constraint=models.CheckConstraint( - check=models.Q(("depth_interval_start__lt", models.F("depth_interval_end"))), + condition=models.Q(("depth_interval_start__lt", models.F("depth_interval_end"))), name="soil_id_projectdepthinterval_depth_interval_coherence", ), ), diff --git a/terraso_backend/apps/soil_id/models/depth_interval.py b/terraso_backend/apps/soil_id/models/depth_interval.py index 4da89d75a..5950dd349 100644 --- a/terraso_backend/apps/soil_id/models/depth_interval.py +++ b/terraso_backend/apps/soil_id/models/depth_interval.py @@ -38,7 +38,7 @@ def constraints(related_field: str): name="%(app_label)s_%(class)s_unique_depth_interval", ), models.CheckConstraint( - check=models.Q(depth_interval_start__lt=models.F("depth_interval_end")), + condition=models.Q(depth_interval_start__lt=models.F("depth_interval_end")), name="%(app_label)s_%(class)s_depth_interval_coherence", ), ] diff --git a/terraso_backend/config/settings.py b/terraso_backend/config/settings.py index d42aa0d4e..774e10cdf 100644 --- a/terraso_backend/config/settings.py +++ b/terraso_backend/config/settings.py @@ -445,3 +445,6 @@ class JWTProvider(TypedDict): f"https://api.hsforms.com/submissions/v3/integration/submit/" f"{HUBSPOT_PORTAL_ID}/{HUBSPOT_ACCOUNT_DELETION_FORM_ID}" ) + +# Neeed for Django 5.x to silence warning. Remove when Django 6.0 is released. +FORMS_URLFIELD_ASSUME_HTTPS = True