diff --git a/Pipfile b/Pipfile index a6ca945a..1a30f2e3 100644 --- a/Pipfile +++ b/Pipfile @@ -19,7 +19,7 @@ requests-mock = "*" watchdog = {extras = ["watchmedo"], version = "*"} [packages] -djangorestframework = "~=3.9" +djangorestframework = "~=3.14.0" django-environ = "~=0.4" django-model-utils = "~=4.0" sentry-sdk = "~=1.17.0" @@ -30,9 +30,8 @@ requests = "~=2.31" unidecode = "~=1.2" django-log-formatter-ecs = "==0.0.5" gunicorn = "*" -django = "==3.2.23" +django = "~=4.2.8" elastic-apm = "==6.7.2" -django-jsonfield = "==1.4" msal = "~=1.22.0" psycopg2-binary = "~=2.9.3" setuptools = "~=65.5.1" diff --git a/Pipfile.lock b/Pipfile.lock index caa52f8e..22628b5f 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "676dd01f9d7f01b4e1a1a2735334f2e65705880df342f68b33bc2d1a4ccaaaf2" + "sha256": "f385428bcfb1f71e1f4cfed303bd22384979b5f4eeb4bc0015a2be7566efd65c" }, "pipfile-spec": 6, "requires": { @@ -34,9 +34,6 @@ "version": "==3.7.2" }, "backports.zoneinfo": { - "extras": [ - "tzdata" - ], "hashes": [ "sha256:17746bd546106fa389c51dbea67c8b7c8f0d14b5526a579ca6ccf5ed72c526cf", "sha256:1b13e654a55cd45672cb54ed12148cd33628f672548f373963b0bff67b217328", @@ -315,12 +312,12 @@ }, "django": { "hashes": [ - "sha256:82968f3640e29ef4a773af2c28448f5f7a08d001c6ac05b32d02aeee6509508b", - "sha256:d48608d5f62f2c1e260986835db089fa3b79d6f58510881d316b8d88345ae6e1" + "sha256:12498cc3cb8bc8038539fef9e90e95f507502436c1f0c3a673411324fa675d14", + "sha256:2cc2fc7d1708ada170ddd6c99f35cc25db664f165d3794bc7723f46b2f8c8984" ], "index": "pypi", - "markers": "python_version >= '3.6'", - "version": "==3.2.23" + "markers": "python_version >= '3.8'", + "version": "==4.2.9" }, "django-environ": { "hashes": [ @@ -348,14 +345,6 @@ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'", "version": "==3.0.7" }, - "django-jsonfield": { - "hashes": [ - "sha256:7bdd0ea75ad842b9e33decdf343398c91fbb7bd664fde0648ef83e78b0453b6e", - "sha256:9b3dac9f7352a6d37e9cfe0126c5b58ac7abf1cb20c0da294a00269a725223f1" - ], - "index": "pypi", - "version": "==1.4.0" - }, "django-log-formatter-ecs": { "hashes": [ "sha256:1e8731dd25a11ac64e789f19931e12fe7ef8ad1a172b7bceb2ea5cab185a583e", @@ -710,11 +699,11 @@ }, "urllib3": { "hashes": [ - "sha256:55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3", - "sha256:df7aa8afb0148fa78488e7899b2c59b5f4ffcfa82e6c54ccb9dd37c1d7b52d54" + "sha256:051d961ad0c62a94e50ecf1af379c3aba230c66c710493493560c0c223c49f20", + "sha256:ce3711610ddce217e6d113a2732fafad960a03fd0318c91faa79481e35c11224" ], "markers": "python_version >= '3.8'", - "version": "==2.1.0" + "version": "==2.2.0" }, "vine": { "hashes": [ @@ -847,6 +836,28 @@ ], "version": "==0.2.0" }, + "backports.zoneinfo": { + "hashes": [ + "sha256:17746bd546106fa389c51dbea67c8b7c8f0d14b5526a579ca6ccf5ed72c526cf", + "sha256:1b13e654a55cd45672cb54ed12148cd33628f672548f373963b0bff67b217328", + "sha256:1c5742112073a563c81f786e77514969acb58649bcdf6cdf0b4ed31a348d4546", + "sha256:4a0f800587060bf8880f954dbef70de6c11bbe59c673c3d818921f042f9954a6", + "sha256:5c144945a7752ca544b4b78c8c41544cdfaf9786f25fe5ffb10e838e19a27570", + "sha256:7b0a64cda4145548fed9efc10322770f929b944ce5cee6c0dfe0c87bf4c0c8c9", + "sha256:8439c030a11780786a2002261569bdf362264f605dfa4d65090b64b05c9f79a7", + "sha256:8961c0f32cd0336fb8e8ead11a1f8cd99ec07145ec2931122faaac1c8f7fd987", + "sha256:89a48c0d158a3cc3f654da4c2de1ceba85263fafb861b98b59040a5086259722", + "sha256:a76b38c52400b762e48131494ba26be363491ac4f9a04c1b7e92483d169f6582", + "sha256:da6013fd84a690242c310d77ddb8441a559e9cb3d3d59ebac9aca1a57b2e18bc", + "sha256:e55b384612d93be96506932a786bbcde5a2db7a9e6a4bb4bffe8b733f5b9036b", + "sha256:e81b76cace8eda1fca50e345242ba977f9be6ae3945af8d46326d776b4cf78d1", + "sha256:e8236383a20872c0cdf5a62b554b27538db7fa1bbec52429d8d106effbaeca08", + "sha256:f04e857b59d9d1ccc39ce2da1021d196e47234873820cbeaad210724b1ee28ac", + "sha256:fadbfe37f74051d024037f223b8e001611eac868b5c5b06144ef4d8b799862f2" + ], + "markers": "python_version < '3.9'", + "version": "==0.2.1" + }, "bandit": { "hashes": [ "sha256:2ff3fe35fe3212c0be5fc9c4899bd0108e2b5239c5ff62fb174639e4660fe958", @@ -998,9 +1009,6 @@ "version": "==8.1.7" }, "coverage": { - "extras": [ - "toml" - ], "hashes": [ "sha256:004d1880bed2d97151facef49f08e255a20ceb6f9432df75f4eef018fdd5a78c", "sha256:01d84219b5cdbfc8122223b39a954820929497a1cb1422824bb86b07b74594b6", @@ -1069,12 +1077,12 @@ }, "django": { "hashes": [ - "sha256:82968f3640e29ef4a773af2c28448f5f7a08d001c6ac05b32d02aeee6509508b", - "sha256:d48608d5f62f2c1e260986835db089fa3b79d6f58510881d316b8d88345ae6e1" + "sha256:12498cc3cb8bc8038539fef9e90e95f507502436c1f0c3a673411324fa675d14", + "sha256:2cc2fc7d1708ada170ddd6c99f35cc25db664f165d3794bc7723f46b2f8c8984" ], "index": "pypi", - "markers": "python_version >= '3.6'", - "version": "==3.2.23" + "markers": "python_version >= '3.8'", + "version": "==4.2.9" }, "django-extensions": { "hashes": [ @@ -1425,13 +1433,6 @@ "markers": "python_version >= '3.8'", "version": "==4.8.0" }, - "pytz": { - "hashes": [ - "sha256:31d4583c4ed539cd037956140d695e42c033a19e984bfce9964a3f7d59bc2b40", - "sha256:f90ef520d95e7c46951105338d918664ebfd6f1d995bd7d153127ce90efafa6a" - ], - "version": "==2023.4" - }, "pyyaml": { "hashes": [ "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5", @@ -1610,11 +1611,11 @@ }, "urllib3": { "hashes": [ - "sha256:55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3", - "sha256:df7aa8afb0148fa78488e7899b2c59b5f4ffcfa82e6c54ccb9dd37c1d7b52d54" + "sha256:051d961ad0c62a94e50ecf1af379c3aba230c66c710493493560c0c223c49f20", + "sha256:ce3711610ddce217e6d113a2732fafad960a03fd0318c91faa79481e35c11224" ], "markers": "python_version >= '3.8'", - "version": "==2.1.0" + "version": "==2.2.0" }, "watchdog": { "extras": [ diff --git a/conf/settings.py b/conf/settings.py index 9234ede2..6cd7dfa2 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -24,7 +24,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = env.bool("DEBUG", default=False) -ALLOWED_HOSTS = "*" +ALLOWED_HOSTS = ["*"] # Application definition diff --git a/mail/migrations/0001_initial.py b/mail/migrations/0001_initial.py index fb65e36f..33787e6c 100644 --- a/mail/migrations/0001_initial.py +++ b/mail/migrations/0001_initial.py @@ -4,7 +4,6 @@ import django.db.models.deletion import django.utils.timezone -import jsonfield.fields from django.db import migrations, models @@ -85,20 +84,20 @@ class Migration(migrations.Migration): name="UsageUpdate", fields=[ ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ("licence_ids", jsonfield.fields.JSONField(default=dict)), + ("licence_ids", models.JSONField(default=dict)), ("spire_run_number", models.IntegerField()), ("hmrc_run_number", models.IntegerField()), - ("has_lite_data", models.NullBooleanField(default=None)), - ("has_spire_data", models.NullBooleanField(default=None)), - ("lite_payload", jsonfield.fields.JSONField(default=dict)), + ("has_lite_data", models.BooleanField(null=True)), + ("has_spire_data", models.BooleanField(null=True)), + ("lite_payload", models.JSONField(default=dict)), ("lite_sent_at", models.DateTimeField(blank=True, null=True)), - ("lite_accepted_licences", jsonfield.fields.JSONField(default=dict)), - ("lite_rejected_licences", jsonfield.fields.JSONField(default=dict)), - ("spire_accepted_licences", jsonfield.fields.JSONField(default=dict)), - ("spire_rejected_licences", jsonfield.fields.JSONField(default=dict)), - ("lite_licences", jsonfield.fields.JSONField(default=dict)), - ("spire_licences", jsonfield.fields.JSONField(default=dict)), - ("lite_response", jsonfield.fields.JSONField(default=dict)), + ("lite_accepted_licences", models.JSONField(default=dict)), + ("lite_rejected_licences", models.JSONField(default=dict)), + ("spire_accepted_licences", models.JSONField(default=dict)), + ("spire_rejected_licences", models.JSONField(default=dict)), + ("lite_licences", models.JSONField(default=dict)), + ("spire_licences", models.JSONField(default=dict)), + ("lite_response", models.JSONField(default=dict)), ("mail", models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to="mail.Mail")), ], options={ @@ -134,7 +133,7 @@ class Migration(migrations.Migration): choices=[("insert", "Insert"), ("cancel", "Cancel"), ("update", "Update")], max_length=6 ), ), - ("data", jsonfield.fields.JSONField(default=dict)), + ("data", models.JSONField(default=dict)), ("received_at", models.DateTimeField(default=django.utils.timezone.now)), ("is_processed", models.BooleanField(default=False)), ("old_lite_id", models.UUIDField(null=True)), diff --git a/mail/migrations/0022_alter_licencedata_licence_payloads.py b/mail/migrations/0022_alter_licencedata_licence_payloads.py new file mode 100644 index 00000000..7ce206bd --- /dev/null +++ b/mail/migrations/0022_alter_licencedata_licence_payloads.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.9 on 2024-01-04 14:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("mail", "0021_licencepayload_skip_process"), + ] + + operations = [ + migrations.AlterField( + model_name="licencedata", + name="licence_payloads", + field=models.ManyToManyField( + help_text="LicencePayload records linked to this LicenceData instance", + related_name="+", + to="mail.licencepayload", + ), + ), + ] diff --git a/mail/models.py b/mail/models.py index e0f6280f..3c0f081c 100644 --- a/mail/models.py +++ b/mail/models.py @@ -125,8 +125,8 @@ class UsageData(models.Model): mail = models.ForeignKey(Mail, on_delete=models.DO_NOTHING, null=False) spire_run_number = models.IntegerField() hmrc_run_number = models.IntegerField() - has_lite_data = models.NullBooleanField(default=None) - has_spire_data = models.NullBooleanField(default=None) + has_lite_data = models.BooleanField(null=True) + has_spire_data = models.BooleanField(null=True) lite_payload = models.JSONField(default=dict) lite_sent_at = models.DateTimeField(blank=True, null=True) # When update was sent to LITE API lite_accepted_licences = models.JSONField(default=list)