Skip to content

Commit 52433ed

Browse files
authored
Replace Django 5.0 with 5.1 (#278)
* Replace Django 5.0 with 5.1 * Update readme * Extract make_random_password
1 parent 12063d1 commit 52433ed

File tree

6 files changed

+41
-16
lines changed

6 files changed

+41
-16
lines changed

HISTORY.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
History
44
=======
55

6+
2.5.0
7+
-----
8+
9+
* Drop Python 3.8 support
10+
* Add Python 3.13 support
11+
* Add Django 5.1 support
12+
613
2.4.1
714
-----
815

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The codebase is targeted and tested against:
9090

9191
* Django 3.2.x against Python 3.8, 3.9, 3.10
9292
* Django 4.2.x against Python 3.8, 3.9, 3.10, 3.11, 3.12
93-
* Django 5.0.x against Python 3.10, 3.11, 3.12
93+
* Django 5.1.x against Python 3.10, 3.11, 3.12
9494

9595
To run the tests against all target environments, install `tox
9696
<https://testrun.org/tox/latest/>`_ and then execute the command::

docs/custom_usage.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,18 @@ with the contents of a freshly generated UUID.
171171

172172
In the example accounts app you would create a file named `backends.py`.::
173173

174-
from organizations.backends.defaults import InvitationBackend
174+
from organizations.backends.defaults import InvitationBackend, make_random_password
175175

176176

177177
class CustomInvitations(InvitationBackend):
178178
def invite_by_email(self, email, sender=None, request=None, **kwargs):
179179
try:
180180
user = self.user_model.objects.get(email=email)
181181
except self.user_model.DoesNotExist:
182-
user = self.user_model.objects.create(email=email,
183-
password=self.user_model.objects.make_random_password())
182+
user = self.user_model.objects.create(
183+
email=email,
184+
password=make_random_password(),
185+
)
184186
user.is_active = False
185187
user.save()
186188
self.send_invitation(user, sender, **kwargs)

src/organizations/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__author__ = "Ben Lopatin"
44
__email__ = "[email protected]"
5-
__version__ = "2.4.1"
5+
__version__ = "2.5.0"

src/organizations/backends/defaults.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from django.template import loader
2020
from django.urls import path
2121
from django.urls import reverse
22+
from django.utils.crypto import get_random_string
2223
from django.utils.translation import gettext as _
2324

2425
from organizations.backends.forms import UserRegistrationForm
@@ -28,6 +29,20 @@
2829
from organizations.utils import model_field_attr
2930

3031

32+
def make_random_password(
33+
length=10,
34+
allowed_chars="abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789",
35+
):
36+
"""
37+
Generate a random password with the given length and given
38+
allowed_chars. The default value of allowed_chars does not have "I" or
39+
"O" or letters and digits that look similar -- just to avoid confusion.
40+
41+
(Pulled directly from since-deprecated manager method in Django source)
42+
"""
43+
return get_random_string(length, allowed_chars)
44+
45+
3146
class BaseBackend:
3247
"""
3348
Base backend class for registering and inviting users to an organization
@@ -215,7 +230,7 @@ def register_by_email(self, email, sender=None, request=None, **kwargs):
215230
user = self.user_model.objects.create(
216231
username=self.get_username(),
217232
email=email,
218-
password=self.user_model.objects.make_random_password(),
233+
password=make_random_password(),
219234
)
220235
user.is_active = False
221236
user.save()
@@ -248,7 +263,7 @@ def create_view(self, request):
248263
user = self.user_model.objects.create(
249264
username=self.get_username(),
250265
email=form.cleaned_data["email"],
251-
password=self.user_model.objects.make_random_password(),
266+
password=make_random_password(),
252267
)
253268
user.is_active = False
254269
user.save()
@@ -317,11 +332,11 @@ def invite_by_email(self, email, sender=None, request=None, **kwargs):
317332
user = self.user_model.objects.create(
318333
username=self.get_username(),
319334
email=email,
320-
password=self.user_model.objects.make_random_password(),
335+
password=make_random_password(),
321336
)
322337
else:
323338
user = self.user_model.objects.create(
324-
email=email, password=self.user_model.objects.make_random_password()
339+
email=email, password=make_random_password()
325340
)
326341
user.is_active = False
327342
user.save()

tox.ini

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
[tox]
22
envlist =
33
flake8,
4-
py{38,39,310}-django{32},
5-
py{38,39}-django{42},
6-
py{310,311,312}-django{42,50}
4+
py{39,310}-django{32},
5+
py{39}-django{42},
6+
py{310,311,312}-django{42}
7+
py{310,311,312,313}-django{51}
78

89
[gh-actions]
910
python =
10-
3.8: py38
1111
3.9: py39
1212
3.10: py310
1313
3.11: py311
1414
3.12: py312
15+
3.13: py313
1516

1617
[build-system]
1718
build-backend = "hatchling.build"
@@ -23,22 +24,22 @@ setenv =
2324
PYTHONPATH = {toxinidir}:{toxinidir}/organizations
2425
commands = pytest {posargs} --cov=organizations
2526
basepython =
26-
py38: python3.8
2727
py39: python3.9
2828
py310: python3.10
2929
py311: python3.11
3030
py312: python3.12
31+
py313: python3.13
3132
deps =
3233
hatch>=1.7.0
3334
django32: Django>=3.2,<4
3435
django42: Django>=4.2,<4.3
35-
django50: Django>=5.0,<5.1
36+
django51: Django>=5.1,<5.2
3637
extras = tests
3738

3839
[testenv:flake8]
3940
basepython=python3
4041
deps=
41-
flake8==3.8.3
42+
flake8==3.12.7
4243
commands=
4344
flake8 src/organizations tests
4445

0 commit comments

Comments
 (0)