Skip to content

Commit 9a9ed78

Browse files
committed
[deps] Added support for Django >=5.1,<5.3 and Python >=3.12, 3.14 #432
- Dropped support for Python < 3.9 - Dropped support for Django < 4.2 Closes #432
1 parent 8b27115 commit 9a9ed78

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,29 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
python-version:
27-
- "3.8"
2827
- "3.9"
2928
- "3.10"
29+
- "3.11"
30+
- "3.12"
31+
- "3.13"
3032
django-version:
31-
- django~=3.2.0
32-
- django~=4.1.0
3333
- django~=4.2.0
34+
- django~=5.0.0
35+
- django~=5.1.0
36+
- django~=5.2rc0
37+
exclude:
38+
# Django 5.0+ requires Python >=3.10
39+
- python-version: "3.9"
40+
django-version: django~=5.0.0
41+
- python-version: "3.9"
42+
django-version: django~=5.1.0
43+
- python-version: "3.9"
44+
django-version: django~=5.2rc0
45+
# Python 3.13 supported only in Django >=5.1.3
46+
- python-version: "3.13"
47+
django-version: django~=4.2.0
48+
- python-version: "3.13"
49+
django-version: django~=5.0.0
3450

3551
steps:
3652
- uses: actions/checkout@v4
@@ -54,6 +70,7 @@ jobs:
5470
pip install -U -r requirements-test.txt
5571
sudo npm install -g prettier
5672
pip install -e .[rest]
73+
pip install -IU "openwisp-utils[qa,selenium] @ https://github.com/openwisp/openwisp-utils/tarball/issues/439-deps"
5774
pip install -U ${{ matrix.django-version }}
5875
5976
- name: QA checks

openwisp_users/base/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,11 @@ class Meta:
257257
abstract = True
258258

259259
def clean(self):
260-
if self.user.is_owner(self.organization_id) and not self.is_admin:
260+
if (
261+
not self._state.adding
262+
and self.user.is_owner(self.organization_id)
263+
and not self.is_admin
264+
):
261265
raise ValidationError(
262266
_(
263267
f'{self.user.username} is the owner of the organization: '

tests/testapp/tests/test_selenium.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_book_add_form_organization_field(self):
6464
visible=Organization.objects.values_list('name', flat=True),
6565
hidden=[],
6666
)
67-
self.open(reverse('admin:logout'))
67+
self.logout()
6868

6969
with self.subTest('Test organization user: 1 org'):
7070
self._test_multitenant_autocomplete_org_field(
@@ -81,7 +81,7 @@ def test_book_add_form_organization_field(self):
8181
)
8282
self.assertEqual(len(org_select.all_selected_options), 1)
8383
self.assertEqual(org_select.first_selected_option.text, org1.name)
84-
self.open(reverse('admin:logout'))
84+
self.logout()
8585

8686
with self.subTest('Test organization user: 2 orgs'):
8787
self._create_org_user(user=administrator, organization=org2, is_admin=True)
@@ -99,7 +99,7 @@ def test_book_add_form_organization_field(self):
9999
self.web_driver.find_element(By.CSS_SELECTOR, '#id_organization')
100100
)
101101
self.assertEqual(len(org_select.all_selected_options), 0)
102-
self.open(reverse('admin:logout'))
102+
self.logout()
103103

104104
def test_shelf_add_form_organization_field(self):
105105
path = reverse('admin:testapp_shelf_add')
@@ -122,7 +122,7 @@ def test_shelf_add_form_organization_field(self):
122122
+ ['Shared systemwide (no organization)'],
123123
hidden=[],
124124
)
125-
self.open(reverse('admin:logout'))
125+
self.logout()
126126

127127
with self.subTest('Test organization user'):
128128
self._test_multitenant_autocomplete_org_field(
@@ -142,4 +142,4 @@ def test_shelf_add_form_organization_field(self):
142142
)
143143
self.assertEqual(len(org_select.all_selected_options), 1)
144144
self.assertEqual(org_select.first_selected_option.text, org1.name)
145-
self.open(reverse('admin:logout'))
145+
self.logout()

0 commit comments

Comments
 (0)