Skip to content

Commit f6a4843

Browse files
authored
Upgrade to Django 5.0.x #50 (#58)
Signed-off-by: tdruez <tdruez@nexb.com>
1 parent badc0d6 commit f6a4843

51 files changed

Lines changed: 194 additions & 250 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
uses: actions/checkout@v4
3434

3535
- name: Set up Python
36-
uses: actions/setup-python@v4
36+
uses: actions/setup-python@v5
3737
with:
3838
python-version: "3.12"
3939

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Release notes
33

44
### Version 5.1.0-dev
55

6-
- Upgrade Python version to 3.12
6+
- Upgrade Python version to 3.12 and Django to 5.0.x
77
https://github.com/nexB/dejacode/issues/50
88

99
- Replace Celery by RQ for async job queue and worker.

component_catalog/tests/test_admin.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def test_activity_log_activated(self):
495495
def test_component_admin_changelist_list_display_as_popup(self):
496496
self.client.login(username="test", password="secret")
497497
url = reverse("admin:component_catalog_component_changelist")
498-
expect1 = '<input type="checkbox" id="action-toggle">'
498+
expect1 = '<input type="checkbox" id="action-toggle"'
499499
expect2 = "get_hierarchy_link"
500500
expect3 = "<span>View</span>"
501501
expect4 = '<td class="action-checkbox">'
@@ -864,7 +864,6 @@ def test_component_save_as_with_inlines(self):
864864
"dje-externalreference-content_type-object_id-INITIAL_FORMS": 0,
865865
}
866866
response = self.client.post(url, data)
867-
# print response.context_data['adminform'].form.errors
868867
self.assertEqual(302, response.status_code)
869868

870869
new_component = Component.objects.get(name=new_name, dataspace=self.dataspace1)
@@ -901,8 +900,8 @@ def test_add_to_product_action_proper_component(self):
901900
self.assertEqual(self.license1.key, pc.license_expression)
902901
self.assertEqual(self.user, pc.created_by)
903902
self.assertEqual(self.user, pc.last_modified_by)
904-
self.assertEqual(26, len(str(pc.created_date)))
905-
self.assertEqual(26, len(str(pc.last_modified_date)))
903+
self.assertEqual(32, len(str(pc.created_date)))
904+
self.assertEqual(32, len(str(pc.last_modified_date)))
906905

907906
self.assertFalse(History.objects.get_for_object(pc).exists())
908907
self.assertEqual(self.user, pc.created_by)
@@ -956,8 +955,8 @@ def test_add_to_product_action_proper_package(self):
956955
self.assertEqual(self.license1.key, pp.license_expression)
957956
self.assertEqual(self.user, pp.created_by)
958957
self.assertEqual(self.user, pp.last_modified_by)
959-
self.assertEqual(26, len(str(pp.created_date)))
960-
self.assertEqual(26, len(str(pp.last_modified_date)))
958+
self.assertEqual(32, len(str(pp.created_date)))
959+
self.assertEqual(32, len(str(pp.last_modified_date)))
961960

962961
self.assertFalse(History.objects.get_for_object(pp).exists())
963962
self.assertEqual(self.user, pp.created_by)

component_catalog/tests/test_importers.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,10 @@ def test_component_import_null_boolean_field(self):
895895
self.assertContains(response, expected1, html=True, count=4)
896896

897897
expected_template = """
898-
<select name="form-0-{0}" id="id_form-0-{0}">
898+
<select name="form-0-{field_name}"
899+
aria-describedby="id_form-0-{field_name}_helptext"
900+
id="id_form-0-{field_name}"
901+
>
899902
<option value="unknown">Unknown</option>
900903
<option value="true">Yes</option>
901904
<option value="false" selected>No</option>
@@ -909,7 +912,8 @@ def test_component_import_null_boolean_field(self):
909912
"indemnification",
910913
]
911914
for field_name in fields:
912-
self.assertContains(response, expected_template.format(field_name), html=True)
915+
expected = expected_template.format(field_name=field_name)
916+
self.assertContains(response, expected, html=True)
913917

914918
# Results
915919
formset_data = {
@@ -926,10 +930,10 @@ def test_component_import_null_boolean_field(self):
926930
self.client.post(url, formset_data)
927931
component = Component.objects.latest("id")
928932
self.assertEqual(formset_data["form-0-name"], component.name)
929-
self.assertTrue(component.sublicense_allowed is False)
930-
self.assertTrue(component.express_patent_grant is False)
931-
self.assertTrue(component.covenant_not_to_assert is False)
932-
self.assertTrue(component.indemnification is False)
933+
self.assertFalse(component.sublicense_allowed)
934+
self.assertFalse(component.express_patent_grant)
935+
self.assertFalse(component.covenant_not_to_assert)
936+
self.assertFalse(component.indemnification)
933937

934938
def test_component_import_acceptable_linkages(self):
935939
formset_data = {

component_catalog/tests/test_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ def test_component_deletion(self):
601601
# Deleting c1 should delete the c1 object and the Subcomponent, but c2
602602
# is not impacted
603603
self.c1.delete()
604-
self.assertFalse(Subcomponent.objects.filter(parent=self.c1, child=self.c2))
604+
self.assertFalse(Subcomponent.objects.filter(parent__id=self.c1.id, child=self.c2))
605605
self.assertFalse(Component.objects.filter(id=self.c1.id))
606606
self.assertTrue(Component.objects.filter(id=self.c2.id))
607607

component_catalog/tests/test_views.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,8 +1509,9 @@ def test_package_list_view_add_to_component_from_package_data(self):
15091509
self.assertContains(response, 'value="1.0"')
15101510
self.assertContains(
15111511
response,
1512-
'<input type="url" name="homepage_url" maxlength="1024"'
1513-
' class="urlinput form-control" id="id_homepage_url">',
1512+
'<input type="url" name="homepage_url" maxlength="1024" '
1513+
'class="urlinput form-control" aria-describedby="id_homepage_url_helptext" '
1514+
'id="id_homepage_url">',
15141515
)
15151516

15161517
def test_package_list_view_usage_policy_availability(self):
@@ -1732,10 +1733,7 @@ def test_package_details_view_add_to_product(self):
17321733
self.assertContains(response, expected)
17331734
self.assertIsNotNone(response.context_data["form"])
17341735

1735-
expected_status_select = (
1736-
'<select name="review_status" class="select form-select" disabled'
1737-
' id="id_review_status">'
1738-
)
1736+
expected_status_select = '<select name="review_status" class="select form-select" disabled'
17391737
self.assertContains(response, expected_status_select)
17401738
self.assertContains(response, f'<option value="{purpose1.pk}">Core</option>')
17411739

component_catalog/tests/testfiles/search/component_dataset.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"nexB"
2929
],
3030
"uuid": "53fa7229-617b-4dfa-9eee-8c09e9380046",
31-
"created_date": "2014-07-01T00:00:00",
32-
"last_modified_date": "2017-05-19T16:09:49.020",
31+
"created_date": "2014-07-01T00:00:00Z",
32+
"last_modified_date": "2017-05-19T16:09:49.020Z",
3333
"reference_notes": "",
3434
"usage_policy": null,
3535
"name": "logback",
@@ -68,8 +68,8 @@
6868
"nexB"
6969
],
7070
"uuid": "03df48a9-60df-43b6-9c04-4a4c9015f309",
71-
"created_date": "2014-07-01T00:00:00",
72-
"last_modified_date": "2017-05-19T16:10:20.504",
71+
"created_date": "2014-07-01T00:00:00Z",
72+
"last_modified_date": "2017-05-19T16:10:20.504Z",
7373
"reference_notes": "",
7474
"usage_policy": null,
7575
"name": "logback",
@@ -108,8 +108,8 @@
108108
"nexB"
109109
],
110110
"uuid": "fed79fab-5d00-4994-a2d1-ad35164b736a",
111-
"created_date": "2014-07-01T00:00:00",
112-
"last_modified_date": "2014-03-04T12:07:06.500",
111+
"created_date": "2014-07-01T00:00:00Z",
112+
"last_modified_date": "2014-03-04T12:07:06.500Z",
113113
"reference_notes": "",
114114
"usage_policy": null,
115115
"name": "logback eclipse",
@@ -148,8 +148,8 @@
148148
"nexB"
149149
],
150150
"uuid": "4a037d63-f479-41f7-985e-436b8039160a",
151-
"created_date": "2014-07-01T00:00:00",
152-
"last_modified_date": "2016-11-10T03:56:18.135",
151+
"created_date": "2014-07-01T00:00:00Z",
152+
"last_modified_date": "2016-11-10T03:56:18.135Z",
153153
"reference_notes": "",
154154
"usage_policy": null,
155155
"name": "jblogbackup",
@@ -188,8 +188,8 @@
188188
"nexB"
189189
],
190190
"uuid": "663fe571-6042-48cd-95ec-6cf57316a591",
191-
"created_date": "2015-08-04T15:08:45.738",
192-
"last_modified_date": "2015-08-21T12:16:25.333",
191+
"created_date": "2015-08-04T15:08:45.738Z",
192+
"last_modified_date": "2015-08-21T12:16:25.333Z",
193193
"reference_notes": "",
194194
"usage_policy": null,
195195
"name": "logback classic",
@@ -228,8 +228,8 @@
228228
"nexB"
229229
],
230230
"uuid": "d47238fd-09aa-45e9-aafa-9d8c3fe10b93",
231-
"created_date": "2014-07-01T00:00:00",
232-
"last_modified_date": "2016-11-10T03:56:18.165",
231+
"created_date": "2014-07-01T00:00:00Z",
232+
"last_modified_date": "2016-11-10T03:56:18.165Z",
233233
"reference_notes": "",
234234
"usage_policy": null,
235235
"name": "jblogbackup",
@@ -268,8 +268,8 @@
268268
"nexB"
269269
],
270270
"uuid": "31368d10-b832-4c77-87d3-2d300989d30e",
271-
"created_date": "2014-07-01T00:00:00",
272-
"last_modified_date": "2016-11-10T04:17:12.090",
271+
"created_date": "2014-07-01T00:00:00Z",
272+
"last_modified_date": "2016-11-10T04:17:12.090Z",
273273
"reference_notes": "",
274274
"usage_policy": null,
275275
"name": "nagios-logback-appender",
@@ -308,8 +308,8 @@
308308
"nexB"
309309
],
310310
"uuid": "0a8bfdd1-7c48-4ac7-99f1-9e6c46e1bb81",
311-
"created_date": "2014-07-01T00:00:00",
312-
"last_modified_date": "2017-05-19T16:10:45.082",
311+
"created_date": "2014-07-01T00:00:00Z",
312+
"last_modified_date": "2017-05-19T16:10:45.082Z",
313313
"reference_notes": "",
314314
"usage_policy": null,
315315
"name": "logback",
@@ -348,8 +348,8 @@
348348
"nexB"
349349
],
350350
"uuid": "9b1c732d-081b-44ae-a366-ac0182281422",
351-
"created_date": "2017-06-13T10:05:03.727",
352-
"last_modified_date": "2017-06-13T10:05:03.727",
351+
"created_date": "2017-06-13T10:05:03.727Z",
352+
"last_modified_date": "2017-06-13T10:05:03.727Z",
353353
"reference_notes": "",
354354
"usage_policy": null,
355355
"name": "zzz",

dejacode/settings.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# Common Django settings for all deployments of DejaCode
1010

1111
import sys
12+
import tempfile
1213
from pathlib import Path
1314

1415
import environ
@@ -209,7 +210,13 @@ def gettext_noop(s):
209210
# CSRF_COOKIE_HTTPONLY = True
210211
# Also, security.W004 SECURE_HSTS_SECONDS and security.W008 SECURE_SSL_REDIRECT
211212
# are handled at the web server level.
212-
SILENCED_SYSTEM_CHECKS = ["security.W004", "security.W008", "security.W017", "urls.W005"]
213+
SILENCED_SYSTEM_CHECKS = [
214+
"security.W004",
215+
"security.W008",
216+
"security.W017",
217+
"urls.W005",
218+
"admin.E039",
219+
]
213220

214221
# Set the following to True to enable ClamAV scan on uploaded files
215222
# This requires the installation of ClamAV
@@ -654,6 +661,8 @@ def get_fake_redis_connection(config, use_strict_redis):
654661
if IS_TESTS:
655662
# Silent the django-axes logging during tests
656663
LOGGING["loggers"].update({"axes": {"handlers": ["null"]}})
664+
# Do not pollute the MEDIA_ROOT location while running the tests.
665+
MEDIA_ROOT = tempfile.TemporaryDirectory().name
657666
# Set a faster hashing algorithm for running the tests
658667
# https://docs.djangoproject.com/en/dev/topics/testing/overview/#password-hashing
659668
PASSWORD_HASHERS = [

dejacode_toolkit/scancodeio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
#
88

99
import json
10+
from hashlib import md5
1011
from urllib.parse import quote_plus
1112

1213
from django.apps import apps
1314
from django.conf import settings
1415
from django.core import signing
1516
from django.urls import reverse
16-
from django.utils.crypto import md5
1717

1818
import requests
1919
from license_expression import Licensing

dje/filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ class DataspaceFilter(ChoicesOnlyListFilterMixin, BaseDataspaceLookupsFilter):
467467
"""
468468

469469
title = _("dataspace")
470-
parameter_name = "dataspace__id__exact"
470+
parameter_name = "dataspace__id"
471471

472472
def lookups(self, request, model_admin):
473473
"""Set the lookup value for the current user dataspace choice to None."""

0 commit comments

Comments
 (0)