Skip to content

Django 4.2 and fix tests #369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,55 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: pinax/linting@v2
- uses: actions/checkout@v2

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install lint dependencies
run: |
python -m pip install --upgrade pip
pip install ruff

- name: Lint with ruff
run: |
ruff --format=github --target-version=py311 account tests

test:
name: Testing
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.6, 3.7, 3.8, 3.9, "3.10"]
django: [2.2.*, 3.2.*]
python:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
django:
- "3.2.*"
- "4.2.*"
exclude:
- python: "3.11"
django: "3.2.*"

steps:
- uses: pinax/testing@v2
- uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v4
with:
python: ${{ matrix.python }}
django: ${{ matrix.django }}
python-version: ${{ matrix.python }}

- name: Install Django
shell: bash
run: pip install Django==${{ matrix.django }} 'django-appconf>=1.0.4' 'pytz>=2020.4'

- name: Install test utilities
shell: bash
run: pip install pytest pytest-django

- name: Running Python Tests
shell: bash
run: pytest
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
include .coveragerc
include CHANGELOG.md
include LICENSE
include tox.ini
include README.md
include runtests.py
recursive-include account *.html
recursive-include account *.txt
recursive-include account/locale *
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ Pinax is an open-source platform built on the Django Web Framework. It is an eco

#### Supported Django and Python versions

Django / Python | 3.6 | 3.7 | 3.8 | 3.9 | 3.10
--------------- | --- | --- | --- | --- | ----
2.2 | * | * | * | * | *
3.2 | * | * | * | * | *
Django / Python | 3.8 | 3.9 | 3.10 | 3.11
--------------- | --- | --- | ---- | ----
3.2 | * | * | * |
4.2 | * | * | * | *


## Requirements

* Django 2.2 or 3.2
* Python 3.6, 3.7, 3.8, 3.9, 3.10
* Django 3.2 or 4.2
* Python 3.8, 3.9, 3.10, 3.11
* django-appconf (included in ``install_requires``)
* pytz (included in ``install_requires``)

Expand Down
4 changes: 1 addition & 3 deletions account/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import pkg_resources

__version__ = pkg_resources.get_distribution("django-user-accounts").version
__version__ = "3.2.1"
4 changes: 3 additions & 1 deletion account/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ class SignupForm(forms.Form):

def clean_username(self):
if not alnum_re.search(self.cleaned_data["username"]):
raise forms.ValidationError(_("Usernames can only contain letters, numbers and the following special characters ./+/-/_"))
raise forms.ValidationError(
_("Usernames can only contain letters, numbers and the following special characters ./+/-/_")
)
lookup_kwargs = get_user_lookup_kwargs({
"{username}__iexact": self.cleaned_data["username"]
})
Expand Down
14 changes: 12 additions & 2 deletions account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@

class Account(models.Model):

user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name="account", verbose_name=_("user"), on_delete=models.CASCADE)
user = models.OneToOneField(
settings.AUTH_USER_MODEL,
related_name="account",
verbose_name=_("user"),
on_delete=models.CASCADE,
)
timezone = TimeZoneField(_("timezone"))
language = models.CharField(
_("language"),
Expand Down Expand Up @@ -407,5 +412,10 @@ class PasswordExpiry(models.Model):
"""
Holds the password expiration period for a single user.
"""
user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name="password_expiry", verbose_name=_("user"), on_delete=models.CASCADE)
user = models.OneToOneField(
settings.AUTH_USER_MODEL,
related_name="password_expiry",
verbose_name=_("user"),
on_delete=models.CASCADE,
)
expiry = models.PositiveIntegerField(default=0)
5 changes: 0 additions & 5 deletions account/tests/urls.py

This file was deleted.

6 changes: 5 additions & 1 deletion account/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
path("confirm_email/<str:key>/", ConfirmEmailView.as_view(), name="account_confirm_email"),
path("password/", ChangePasswordView.as_view(), name="account_password"),
path("password/reset/", PasswordResetView.as_view(), name="account_password_reset"),
path("password/reset/<str:uidb36>/<str:token>/", PasswordResetTokenView.as_view(), name="account_password_reset_token"),
path(
"password/reset/<str:uidb36>/<str:token>/",
PasswordResetTokenView.as_view(),
name="account_password_reset_token",
),
path("settings/", SettingsView.as_view(), name="account_settings"),
path("delete/", DeleteView.as_view(), name="account_delete"),
]
4 changes: 2 additions & 2 deletions account/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from django.core.exceptions import SuspiciousOperation
from django.http import HttpResponseRedirect, QueryDict
from django.urls import NoReverseMatch, reverse
from django.utils import timezone
from django.utils.encoding import force_str

import pytz
from account.conf import settings

from .models import PasswordHistory
Expand Down Expand Up @@ -139,7 +139,7 @@ def check_password_expired(user):
except PasswordHistory.DoesNotExist:
return False

now = datetime.datetime.now()
now = timezone.now()
expiration = latest.timestamp + datetime.timedelta(seconds=expiry)

if expiration < now:
Expand Down
20 changes: 16 additions & 4 deletions account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ def get_context_data(self, **kwargs):
redirect_field_name = self.get_redirect_field_name()
ctx.update({
"redirect_field_name": redirect_field_name,
"redirect_field_value": self.request.POST.get(redirect_field_name, self.request.GET.get(redirect_field_name, "")),
"redirect_field_value": self.request.POST.get(
redirect_field_name,
self.request.GET.get(redirect_field_name, ""),
),
})
return ctx

Expand Down Expand Up @@ -383,7 +386,10 @@ def get_context_data(self, **kwargs):
redirect_field_name = self.get_redirect_field_name()
ctx.update({
"redirect_field_name": redirect_field_name,
"redirect_field_value": self.request.POST.get(redirect_field_name, self.request.GET.get(redirect_field_name, "")),
"redirect_field_value": self.request.POST.get(
redirect_field_name,
self.request.GET.get(redirect_field_name, ""),
),
})
return ctx

Expand Down Expand Up @@ -448,7 +454,10 @@ def get_context_data(self, **kwargs):
redirect_field_name = self.get_redirect_field_name()
ctx.update({
"redirect_field_name": redirect_field_name,
"redirect_field_value": self.request.POST.get(redirect_field_name, self.request.GET.get(redirect_field_name, "")),
"redirect_field_value": self.request.POST.get(
redirect_field_name,
self.request.GET.get(redirect_field_name, ""),
),
})
return ctx

Expand Down Expand Up @@ -790,7 +799,10 @@ def get_context_data(self, **kwargs):
redirect_field_name = self.get_redirect_field_name()
ctx.update({
"redirect_field_name": redirect_field_name,
"redirect_field_value": self.request.POST.get(redirect_field_name, self.request.GET.get(redirect_field_name, "")),
"redirect_field_value": self.request.POST.get(
redirect_field_name,
self.request.GET.get(redirect_field_name, ""),
),
})
return ctx

Expand Down
4 changes: 2 additions & 2 deletions makemigrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"django.contrib.contenttypes",
"django.contrib.sites",
"account",
"account.tests"
"tests"
],
MIDDLEWARE_CLASSES=[],
DATABASES={
Expand All @@ -21,7 +21,7 @@
}
},
SITE_ID=1,
ROOT_URLCONF="account.tests.urls",
ROOT_URLCONF="tests.urls",
SECRET_KEY="notasecret",
)

Expand Down
10 changes: 10 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
64 changes: 58 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
[build-system]
requires = ["setuptools>=61.2"]
build-backend = "setuptools.build_meta"

[project]
name = "django-user-accounts"
authors = [{name = "Pinax Team", email = "team@pinaxproject.com"}]
description = "a Django user account app"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.2",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"Django>=3.2",
"django-appconf>=1.0.4",
"pytz>=2020.4",
]
dynamic = ["version"]

[project.readme]
file = "README.md"
content-type = "text/markdown"

[project.urls]
Homepage = "http://github.com/pinax/django-user-accounts"

[tool.isort]
profile = "hug"
src_paths = ["account"]
Expand All @@ -8,9 +46,23 @@ sections = "FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER"
skip_glob = "account/migrations/*,docs"
include_trailing_comma = "True"

[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
testpaths = ["tests"]
DJANGO_SETTINGS_MODULE = "tests.settings"

[tool.ruff]
line-length = 120

[tool.ruff.per-file-ignores]
"account/migrations/**.py" = ["E501"]

[tool.setuptools]
packages = ["account"]
include-package-data = true
zip-safe = false

[tool.setuptools.dynamic]
version = {attr = "account.__version__"}

[tool.setuptools.package-data]
account = ["locale/*/LC_MESSAGES/*"]
4 changes: 2 additions & 2 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def runtests(*test_args):
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "account.tests.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")
django.setup()

parent = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -15,7 +15,7 @@ def runtests(*test_args):
from django.test.runner import DiscoverRunner
runner_class = DiscoverRunner
if not test_args:
test_args = ["account.tests"]
test_args = ["tests"]

failures = runner_class(verbosity=1, interactive=True, failfast=False).run_tests(test_args)
sys.exit(failures)
Expand Down
47 changes: 0 additions & 47 deletions setup.cfg

This file was deleted.

File renamed without changes.
Loading