dbca-utils 2.0.1__tar.gz → 2.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,19 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbca-utils
3
- Version: 2.0.1
4
- Summary: Utilities for Django/Python apps
5
- Home-page: https://github.com/dbca-wa/dbca-utils
6
- Author: Department of Biodiversity, Conservation and Attractions
7
- Author-email: asi@dbca.wa.gov.au
8
- Maintainer: Department of Biodiversity, Conservation and Attractions
9
- Maintainer-email: asi@dbca.wa.gov.au
10
- License: Apache License, Version 2.0
11
- Keywords: django,middleware,utility
12
- Platform: UNKNOWN
3
+ Version: 2.0.3
4
+ Summary: Utilities for DBCA Django apps
5
+ License: Apache-2.0
6
+ Author: Rocky Chen
7
+ Author-email: rocky.chen@dbca.wa.gov.au
8
+ Requires-Python: >=3.9,<4.0
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Environment :: Web Environment
13
11
  Classifier: Framework :: Django
14
12
  Classifier: Framework :: Django :: 3.2
15
13
  Classifier: Framework :: Django :: 4.0
16
14
  Classifier: Framework :: Django :: 4.2
17
15
  Classifier: Framework :: Django :: 5.0
18
- Classifier: Environment :: Web Environment
19
16
  Classifier: Intended Audience :: Developers
20
- Classifier: Development Status :: 5 - Production/Stable
21
17
  Classifier: License :: OSI Approved :: Apache Software License
22
18
  Classifier: Programming Language :: Python
23
19
  Classifier: Programming Language :: Python :: 3
@@ -25,21 +21,49 @@ Classifier: Programming Language :: Python :: 3.9
25
21
  Classifier: Programming Language :: Python :: 3.10
26
22
  Classifier: Programming Language :: Python :: 3.11
27
23
  Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
28
25
  Classifier: Topic :: Software Development :: Libraries
29
26
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Requires-Dist: django (>=3.2,<5.1)
30
28
  Description-Content-Type: text/markdown
31
- License-File: LICENSE
32
29
 
33
30
  # Overview
34
31
 
35
32
  DBCA Django utility classes and functions.
36
33
 
37
- # SSO Login Middleware
34
+ ## Development
35
+
36
+ This project for development is using
37
+ [Poetry](https://python-poetry.org/docs/) to install and manage a virtual Python
38
+ environment. With Poetry installed, change into the project directory and run:
39
+
40
+ poetry install
41
+
42
+ Activate the virtualenv like so:
43
+
44
+ poetry shell
45
+
46
+ Run unit tests using `pytest` (or `tox`, to test against multiple Python versions):
47
+
48
+ pytest -v
49
+ tox -v
50
+
51
+ ## Releases
52
+
53
+ Tagged releases are built and pushed to PyPI automatically using a GitHub
54
+ workflow in the project. Update the project version in `pyproject.toml` and
55
+ tag the required commit with the same value to trigger a release.
56
+
57
+ ## Installation
58
+
59
+ 1. Install via pip/Poetry/etc.: `pip install dbca-utils`
60
+
61
+ ## SSO Login Middleware
38
62
 
39
63
  This will automatically login and create users using headers from an upstream proxy (REMOTE_USER and some others).
40
64
  The logout view will redirect to a separate logout page which clears the SSO session.
41
65
 
42
- ## Usage
66
+ ### Usage
43
67
 
44
68
  Add `dbca_utils.middleware.SSOLoginMiddleware` to `settings.MIDDLEWARE` (after both of
45
69
  `django.contrib.sessions.middleware.SessionMiddleware` and
@@ -51,7 +75,7 @@ on every request, and `request.user.is_authenticated` won't work properly/will b
51
75
 
52
76
  Example:
53
77
 
54
- ```
78
+ ```python
55
79
  MIDDLEWARE = [
56
80
  ...,
57
81
  'django.contrib.sessions.middleware.SessionMiddleware',
@@ -61,13 +85,12 @@ MIDDLEWARE = [
61
85
  ]
62
86
  ```
63
87
 
64
- # Audit model mixin
65
-
66
- ``AuditMixin`` is an extension of ``Django.db.model.Model`` that adds a number of additional fields:
88
+ ## Audit model mixin
67
89
 
68
- * creator - FK to ``AUTH_USER_MODEL``, used to record the object creator
69
- * modifier - FK to ``AUTH_USER_MODEL``, used to record who the object was last modified by
70
- * created - a timestamp that is set on initial object save
71
- * modified - an auto-updating timestamp (on each object save)
90
+ `AuditMixin` is an extension of `Django.db.model.Model` that adds a number of additional fields:
72
91
 
92
+ - creator - FK to `AUTH_USER_MODEL`, used to record the object creator
93
+ - modifier - FK to `AUTH_USER_MODEL`, used to record who the object was last modified by
94
+ - created - a timestamp that is set on initial object save
95
+ - modified - an auto-updating timestamp (on each object save)
73
96
 
@@ -0,0 +1,66 @@
1
+ # Overview
2
+
3
+ DBCA Django utility classes and functions.
4
+
5
+ ## Development
6
+
7
+ This project for development is using
8
+ [Poetry](https://python-poetry.org/docs/) to install and manage a virtual Python
9
+ environment. With Poetry installed, change into the project directory and run:
10
+
11
+ poetry install
12
+
13
+ Activate the virtualenv like so:
14
+
15
+ poetry shell
16
+
17
+ Run unit tests using `pytest` (or `tox`, to test against multiple Python versions):
18
+
19
+ pytest -v
20
+ tox -v
21
+
22
+ ## Releases
23
+
24
+ Tagged releases are built and pushed to PyPI automatically using a GitHub
25
+ workflow in the project. Update the project version in `pyproject.toml` and
26
+ tag the required commit with the same value to trigger a release.
27
+
28
+ ## Installation
29
+
30
+ 1. Install via pip/Poetry/etc.: `pip install dbca-utils`
31
+
32
+ ## SSO Login Middleware
33
+
34
+ This will automatically login and create users using headers from an upstream proxy (REMOTE_USER and some others).
35
+ The logout view will redirect to a separate logout page which clears the SSO session.
36
+
37
+ ### Usage
38
+
39
+ Add `dbca_utils.middleware.SSOLoginMiddleware` to `settings.MIDDLEWARE` (after both of
40
+ `django.contrib.sessions.middleware.SessionMiddleware` and
41
+ `django.contrib.auth.middleware.AuthenticationMiddleware`.
42
+ Ensure that `AUTHENTICATION_BACKENDS` contains `django.contrib.auth.backends.ModelBackend`,
43
+ as this middleware depends on it for retrieving the logged in user for a session.
44
+ Note that the middleware will still work without it, but will reauthenticate the session
45
+ on every request, and `request.user.is_authenticated` won't work properly/will be false.
46
+
47
+ Example:
48
+
49
+ ```python
50
+ MIDDLEWARE = [
51
+ ...,
52
+ 'django.contrib.sessions.middleware.SessionMiddleware',
53
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
54
+ 'dbca_utils.middleware.SSOLoginMiddleware'
55
+ ...,
56
+ ]
57
+ ```
58
+
59
+ ## Audit model mixin
60
+
61
+ `AuditMixin` is an extension of `Django.db.model.Model` that adds a number of additional fields:
62
+
63
+ - creator - FK to `AUTH_USER_MODEL`, used to record the object creator
64
+ - modifier - FK to `AUTH_USER_MODEL`, used to record who the object was last modified by
65
+ - created - a timestamp that is set on initial object save
66
+ - modified - an auto-updating timestamp (on each object save)
@@ -0,0 +1,56 @@
1
+ [tool.poetry]
2
+ name = "dbca-utils"
3
+ version = "2.0.3"
4
+ description = "Utilities for DBCA Django apps"
5
+ authors = [
6
+ "Rocky Chen <rocky.chen@dbca.wa.gov.au>",
7
+ "Ashley Felton <ashley.felton@dbca.wa.gov.au>",
8
+ ]
9
+ license = "Apache-2.0"
10
+ readme = "README.md"
11
+ classifiers = [
12
+ "Framework :: Django",
13
+ "Framework :: Django :: 3.2",
14
+ "Framework :: Django :: 4.0",
15
+ "Framework :: Django :: 4.2",
16
+ "Framework :: Django :: 5.0",
17
+ "Environment :: Web Environment",
18
+ "Intended Audience :: Developers",
19
+ "Development Status :: 5 - Production/Stable",
20
+ "License :: OSI Approved :: Apache Software License",
21
+ "Programming Language :: Python",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.9",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Topic :: Software Development :: Libraries",
28
+ "Topic :: Software Development :: Libraries :: Python Modules",
29
+ ]
30
+
31
+
32
+ [tool.poetry.group.dev.dependencies]
33
+ pytest-django = "^4.9.0"
34
+ pytest-sugar = "^1.0.0"
35
+ tox = "^4.23.2"
36
+
37
+ [project.urls]
38
+ homepage = "https://github.com/dbca-wa/dbca-utils"
39
+ source = "https://github.com/dbca-wa/dbca-utils.git"
40
+ changelog = "https://github.com/dbca-wa/dbca-utils/blob/master/CHANGELOG.md"
41
+
42
+ [tool.poetry.dependencies]
43
+ python = "^3.9"
44
+ django = ">=3.2,<5.1"
45
+
46
+ [build-system]
47
+ requires = ["poetry-core"]
48
+ build-backend = "poetry.core.masonry.api"
49
+
50
+ [tool.pytest.ini_options]
51
+ # https://pytest-django.readthedocs.io/en/latest/configuring_django.html#pyproject-toml-settings
52
+ DJANGO_SETTINGS_MODULE = "tests.settings"
53
+ # https://pytest-django.readthedocs.io/en/latest/managing_python_path.html#using-pytest-s-pythonpath-option
54
+ pythonpath = ". src"
55
+ # https://pytest-django.readthedocs.io/en/latest/faq.html#my-tests-are-not-being-found-why
56
+ python_files = "tests.py test_*.py"
@@ -3,6 +3,7 @@ from django.conf import settings
3
3
  from django.contrib.auth import login, logout, get_user_model
4
4
  from django.utils.deprecation import MiddlewareMixin
5
5
  from django.utils.functional import SimpleLazyObject
6
+ from django.utils import timezone
6
7
  from django.contrib.auth.middleware import AuthenticationMiddleware, get_user
7
8
 
8
9
  from dbca_utils.utils import env
@@ -161,7 +162,7 @@ class SSOLoginMiddleware(MiddlewareMixin):
161
162
  ):
162
163
  user = User.objects.filter(username__iexact=attributemap["username"])[0]
163
164
  else:
164
- user = User()
165
+ user = User(last_login=timezone.localtime())
165
166
 
166
167
  # Set the user's details from the supplied information.
167
168
  user.__dict__.update(attributemap)
@@ -1,2 +0,0 @@
1
- include README.md
2
- include LICENSE
dbca-utils-2.0.1/PKG-INFO DELETED
@@ -1,73 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: dbca-utils
3
- Version: 2.0.1
4
- Summary: Utilities for Django/Python apps
5
- Home-page: https://github.com/dbca-wa/dbca-utils
6
- Author: Department of Biodiversity, Conservation and Attractions
7
- Author-email: asi@dbca.wa.gov.au
8
- Maintainer: Department of Biodiversity, Conservation and Attractions
9
- Maintainer-email: asi@dbca.wa.gov.au
10
- License: Apache License, Version 2.0
11
- Keywords: django,middleware,utility
12
- Platform: UNKNOWN
13
- Classifier: Framework :: Django
14
- Classifier: Framework :: Django :: 3.2
15
- Classifier: Framework :: Django :: 4.0
16
- Classifier: Framework :: Django :: 4.2
17
- Classifier: Framework :: Django :: 5.0
18
- Classifier: Environment :: Web Environment
19
- Classifier: Intended Audience :: Developers
20
- Classifier: Development Status :: 5 - Production/Stable
21
- Classifier: License :: OSI Approved :: Apache Software License
22
- Classifier: Programming Language :: Python
23
- Classifier: Programming Language :: Python :: 3
24
- Classifier: Programming Language :: Python :: 3.9
25
- Classifier: Programming Language :: Python :: 3.10
26
- Classifier: Programming Language :: Python :: 3.11
27
- Classifier: Programming Language :: Python :: 3.12
28
- Classifier: Topic :: Software Development :: Libraries
29
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
30
- Description-Content-Type: text/markdown
31
- License-File: LICENSE
32
-
33
- # Overview
34
-
35
- DBCA Django utility classes and functions.
36
-
37
- # SSO Login Middleware
38
-
39
- This will automatically login and create users using headers from an upstream proxy (REMOTE_USER and some others).
40
- The logout view will redirect to a separate logout page which clears the SSO session.
41
-
42
- ## Usage
43
-
44
- Add `dbca_utils.middleware.SSOLoginMiddleware` to `settings.MIDDLEWARE` (after both of
45
- `django.contrib.sessions.middleware.SessionMiddleware` and
46
- `django.contrib.auth.middleware.AuthenticationMiddleware`.
47
- Ensure that `AUTHENTICATION_BACKENDS` contains `django.contrib.auth.backends.ModelBackend`,
48
- as this middleware depends on it for retrieving the logged in user for a session.
49
- Note that the middleware will still work without it, but will reauthenticate the session
50
- on every request, and `request.user.is_authenticated` won't work properly/will be false.
51
-
52
- Example:
53
-
54
- ```
55
- MIDDLEWARE = [
56
- ...,
57
- 'django.contrib.sessions.middleware.SessionMiddleware',
58
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
59
- 'dbca_utils.middleware.SSOLoginMiddleware'
60
- ...,
61
- ]
62
- ```
63
-
64
- # Audit model mixin
65
-
66
- ``AuditMixin`` is an extension of ``Django.db.model.Model`` that adds a number of additional fields:
67
-
68
- * creator - FK to ``AUTH_USER_MODEL``, used to record the object creator
69
- * modifier - FK to ``AUTH_USER_MODEL``, used to record who the object was last modified by
70
- * created - a timestamp that is set on initial object save
71
- * modified - an auto-updating timestamp (on each object save)
72
-
73
-
@@ -1,39 +0,0 @@
1
- # Overview
2
-
3
- DBCA Django utility classes and functions.
4
-
5
- # SSO Login Middleware
6
-
7
- This will automatically login and create users using headers from an upstream proxy (REMOTE_USER and some others).
8
- The logout view will redirect to a separate logout page which clears the SSO session.
9
-
10
- ## Usage
11
-
12
- Add `dbca_utils.middleware.SSOLoginMiddleware` to `settings.MIDDLEWARE` (after both of
13
- `django.contrib.sessions.middleware.SessionMiddleware` and
14
- `django.contrib.auth.middleware.AuthenticationMiddleware`.
15
- Ensure that `AUTHENTICATION_BACKENDS` contains `django.contrib.auth.backends.ModelBackend`,
16
- as this middleware depends on it for retrieving the logged in user for a session.
17
- Note that the middleware will still work without it, but will reauthenticate the session
18
- on every request, and `request.user.is_authenticated` won't work properly/will be false.
19
-
20
- Example:
21
-
22
- ```
23
- MIDDLEWARE = [
24
- ...,
25
- 'django.contrib.sessions.middleware.SessionMiddleware',
26
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
27
- 'dbca_utils.middleware.SSOLoginMiddleware'
28
- ...,
29
- ]
30
- ```
31
-
32
- # Audit model mixin
33
-
34
- ``AuditMixin`` is an extension of ``Django.db.model.Model`` that adds a number of additional fields:
35
-
36
- * creator - FK to ``AUTH_USER_MODEL``, used to record the object creator
37
- * modifier - FK to ``AUTH_USER_MODEL``, used to record who the object was last modified by
38
- * created - a timestamp that is set on initial object save
39
- * modified - an auto-updating timestamp (on each object save)
@@ -1,15 +0,0 @@
1
- LICENSE
2
- MANIFEST.in
3
- README.md
4
- setup.cfg
5
- setup.py
6
- dbca_utils/__init__.py
7
- dbca_utils/middleware.py
8
- dbca_utils/models.py
9
- dbca_utils/utils.py
10
- dbca_utils.egg-info/PKG-INFO
11
- dbca_utils.egg-info/SOURCES.txt
12
- dbca_utils.egg-info/dependency_links.txt
13
- dbca_utils.egg-info/not-zip-safe
14
- dbca_utils.egg-info/requires.txt
15
- dbca_utils.egg-info/top_level.txt
@@ -1 +0,0 @@
1
- Django>=3.2
@@ -1 +0,0 @@
1
- dbca_utils
@@ -1,10 +0,0 @@
1
- [metadata]
2
- license-file = LICENSE
3
-
4
- [flake8]
5
- ignore = E302,E501,W503
6
-
7
- [egg_info]
8
- tag_build =
9
- tag_date = 0
10
-
dbca-utils-2.0.1/setup.py DELETED
@@ -1,47 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- from setuptools import setup
4
- from pathlib import Path
5
-
6
- # Read the contents of the README file:
7
- this_directory = Path(__file__).parent
8
- long_description = (this_directory / "README.md").read_text()
9
-
10
- setup(
11
- name='dbca-utils',
12
- version='2.0.1',
13
- packages=['dbca_utils'],
14
- description='Utilities for Django/Python apps',
15
- long_description=long_description,
16
- long_description_content_type='text/markdown',
17
- url='https://github.com/dbca-wa/dbca-utils',
18
- author='Department of Biodiversity, Conservation and Attractions',
19
- author_email='asi@dbca.wa.gov.au',
20
- maintainer='Department of Biodiversity, Conservation and Attractions',
21
- maintainer_email='asi@dbca.wa.gov.au',
22
- license='Apache License, Version 2.0',
23
- zip_safe=False,
24
- keywords=['django', 'middleware', 'utility'],
25
- install_requires=[
26
- 'Django>=3.2',
27
- ],
28
- classifiers=[
29
- 'Framework :: Django',
30
- 'Framework :: Django :: 3.2',
31
- 'Framework :: Django :: 4.0',
32
- 'Framework :: Django :: 4.2',
33
- 'Framework :: Django :: 5.0',
34
- 'Environment :: Web Environment',
35
- 'Intended Audience :: Developers',
36
- 'Development Status :: 5 - Production/Stable',
37
- 'License :: OSI Approved :: Apache Software License',
38
- 'Programming Language :: Python',
39
- 'Programming Language :: Python :: 3',
40
- 'Programming Language :: Python :: 3.9',
41
- 'Programming Language :: Python :: 3.10',
42
- 'Programming Language :: Python :: 3.11',
43
- 'Programming Language :: Python :: 3.12',
44
- 'Topic :: Software Development :: Libraries',
45
- 'Topic :: Software Development :: Libraries :: Python Modules',
46
- ],
47
- )
File without changes