django-icv-core 0.1.0__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.
Files changed (69) hide show
  1. django_icv_core-0.1.0/LICENSE +21 -0
  2. django_icv_core-0.1.0/PKG-INFO +98 -0
  3. django_icv_core-0.1.0/README.md +63 -0
  4. django_icv_core-0.1.0/pyproject.toml +78 -0
  5. django_icv_core-0.1.0/setup.cfg +4 -0
  6. django_icv_core-0.1.0/src/django_icv_core.egg-info/PKG-INFO +98 -0
  7. django_icv_core-0.1.0/src/django_icv_core.egg-info/SOURCES.txt +67 -0
  8. django_icv_core-0.1.0/src/django_icv_core.egg-info/dependency_links.txt +1 -0
  9. django_icv_core-0.1.0/src/django_icv_core.egg-info/requires.txt +10 -0
  10. django_icv_core-0.1.0/src/django_icv_core.egg-info/top_level.txt +1 -0
  11. django_icv_core-0.1.0/src/icv_core/__init__.py +10 -0
  12. django_icv_core-0.1.0/src/icv_core/admin.py +41 -0
  13. django_icv_core-0.1.0/src/icv_core/apps.py +20 -0
  14. django_icv_core-0.1.0/src/icv_core/audit/__init__.py +12 -0
  15. django_icv_core-0.1.0/src/icv_core/audit/api/__init__.py +0 -0
  16. django_icv_core-0.1.0/src/icv_core/audit/api/serializers.py +69 -0
  17. django_icv_core-0.1.0/src/icv_core/audit/api/urls.py +12 -0
  18. django_icv_core-0.1.0/src/icv_core/audit/api/views.py +67 -0
  19. django_icv_core-0.1.0/src/icv_core/audit/decorators.py +81 -0
  20. django_icv_core-0.1.0/src/icv_core/audit/handlers.py +53 -0
  21. django_icv_core-0.1.0/src/icv_core/audit/middleware.py +65 -0
  22. django_icv_core-0.1.0/src/icv_core/audit/mixins.py +124 -0
  23. django_icv_core-0.1.0/src/icv_core/audit/models.py +271 -0
  24. django_icv_core-0.1.0/src/icv_core/audit/services.py +234 -0
  25. django_icv_core-0.1.0/src/icv_core/audit/signals.py +12 -0
  26. django_icv_core-0.1.0/src/icv_core/audit/tasks.py +81 -0
  27. django_icv_core-0.1.0/src/icv_core/checks.py +91 -0
  28. django_icv_core-0.1.0/src/icv_core/conf.py +86 -0
  29. django_icv_core-0.1.0/src/icv_core/exceptions.py +7 -0
  30. django_icv_core-0.1.0/src/icv_core/handlers.py +16 -0
  31. django_icv_core-0.1.0/src/icv_core/management/__init__.py +0 -0
  32. django_icv_core-0.1.0/src/icv_core/management/commands/__init__.py +0 -0
  33. django_icv_core-0.1.0/src/icv_core/management/commands/icv_core_audit_archive.py +53 -0
  34. django_icv_core-0.1.0/src/icv_core/management/commands/icv_core_audit_stats.py +50 -0
  35. django_icv_core-0.1.0/src/icv_core/management/commands/icv_core_check.py +41 -0
  36. django_icv_core-0.1.0/src/icv_core/managers/__init__.py +9 -0
  37. django_icv_core-0.1.0/src/icv_core/managers/scoped.py +46 -0
  38. django_icv_core-0.1.0/src/icv_core/managers/soft_delete.py +43 -0
  39. django_icv_core-0.1.0/src/icv_core/middleware.py +46 -0
  40. django_icv_core-0.1.0/src/icv_core/migrations/0001_initial.py +346 -0
  41. django_icv_core-0.1.0/src/icv_core/migrations/__init__.py +0 -0
  42. django_icv_core-0.1.0/src/icv_core/models/__init__.py +25 -0
  43. django_icv_core-0.1.0/src/icv_core/models/base.py +51 -0
  44. django_icv_core-0.1.0/src/icv_core/models/compliance.py +42 -0
  45. django_icv_core-0.1.0/src/icv_core/models/soft_delete.py +80 -0
  46. django_icv_core-0.1.0/src/icv_core/py.typed +0 -0
  47. django_icv_core-0.1.0/src/icv_core/services/__init__.py +15 -0
  48. django_icv_core-0.1.0/src/icv_core/signals.py +9 -0
  49. django_icv_core-0.1.0/src/icv_core/templatetags/__init__.py +0 -0
  50. django_icv_core-0.1.0/src/icv_core/templatetags/icv_core.py +83 -0
  51. django_icv_core-0.1.0/src/icv_core/tenancy/__init__.py +40 -0
  52. django_icv_core-0.1.0/src/icv_core/tenancy/context.py +105 -0
  53. django_icv_core-0.1.0/src/icv_core/tenancy/managers.py +91 -0
  54. django_icv_core-0.1.0/src/icv_core/tenancy/mixins.py +105 -0
  55. django_icv_core-0.1.0/src/icv_core/testing/__init__.py +10 -0
  56. django_icv_core-0.1.0/src/icv_core/testing/factories.py +45 -0
  57. django_icv_core-0.1.0/src/icv_core/testing/fixtures.py +25 -0
  58. django_icv_core-0.1.0/src/icv_core/testing/helpers.py +26 -0
  59. django_icv_core-0.1.0/tests/test_audit_api.py +940 -0
  60. django_icv_core-0.1.0/tests/test_audit_features.py +873 -0
  61. django_icv_core-0.1.0/tests/test_audit_services.py +407 -0
  62. django_icv_core-0.1.0/tests/test_commands_and_checks.py +813 -0
  63. django_icv_core-0.1.0/tests/test_conf.py +53 -0
  64. django_icv_core-0.1.0/tests/test_managers.py +59 -0
  65. django_icv_core-0.1.0/tests/test_middleware.py +57 -0
  66. django_icv_core-0.1.0/tests/test_models.py +223 -0
  67. django_icv_core-0.1.0/tests/test_signals.py +21 -0
  68. django_icv_core-0.1.0/tests/test_templatetags.py +84 -0
  69. django_icv_core-0.1.0/tests/test_tenancy.py +293 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nigel Copley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,98 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-icv-core
3
+ Version: 0.1.0
4
+ Summary: Foundation layer for ICV-Django: abstract base models, managers, middleware, utilities, and audit logging.
5
+ Author: Nigel Copley
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/nigelcopley/icv-django
8
+ Project-URL: Documentation, https://github.com/nigelcopley/icv-django/tree/main/packages/icv-core
9
+ Project-URL: Changelog, https://github.com/nigelcopley/icv-django/tree/main/packages/icv-core/CHANGELOG.md
10
+ Project-URL: Issue Tracker, https://github.com/nigelcopley/icv-django/issues
11
+ Project-URL: Source Code, https://github.com/nigelcopley/icv-django/tree/main/packages/icv-core
12
+ Keywords: django,reusable,base-models,uuid,soft-delete,audit,timestamps
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Framework :: Django
15
+ Classifier: Framework :: Django :: 4.2
16
+ Classifier: Framework :: Django :: 5.0
17
+ Classifier: Framework :: Django :: 5.1
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Requires-Python: >=3.11
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: Django>=4.2
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8.0; extra == "dev"
28
+ Requires-Dist: pytest-django>=4.8; extra == "dev"
29
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
30
+ Requires-Dist: factory-boy>=3.3; extra == "dev"
31
+ Requires-Dist: ruff>=0.5.0; extra == "dev"
32
+ Requires-Dist: mypy>=1.10; extra == "dev"
33
+ Requires-Dist: django-stubs>=5.0; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ # django-icv-core
37
+
38
+ [![CI](https://github.com/nigelcopley/icv-django/actions/workflows/ci.yml/badge.svg)](https://github.com/nigelcopley/icv-django/actions/workflows/ci.yml)
39
+ [![PyPI version](https://img.shields.io/pypi/v/django-icv-core.svg)](https://pypi.org/project/django-icv-core/)
40
+ [![Python versions](https://img.shields.io/pypi/pyversions/django-icv-core.svg)](https://pypi.org/project/django-icv-core/)
41
+ [![Django versions](https://img.shields.io/pypi/djversions/django-icv-core.svg)](https://pypi.org/project/django-icv-core/)
42
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
43
+
44
+ Foundation layer for ICV-Django packages. Provides abstract base models,
45
+ custom managers, middleware, utilities, template tags, and an optional audit
46
+ subsystem.
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ pip install django-icv-core
52
+ ```
53
+
54
+ ```python
55
+ INSTALLED_APPS = [
56
+ # ...
57
+ "icv_core",
58
+ ]
59
+ ```
60
+
61
+ ## Documentation
62
+
63
+ See [APP-001: Core](../../docs/specs/APP-001-core.md) for the full specification.
64
+
65
+ ## Quick Start
66
+
67
+ ```python
68
+ from icv_core.models import BaseModel, SoftDeleteModel
69
+
70
+ class Article(BaseModel):
71
+ title = models.CharField(max_length=255)
72
+
73
+ class Product(SoftDeleteModel):
74
+ name = models.CharField(max_length=255)
75
+
76
+ # Soft delete
77
+ product.soft_delete() # sets is_active=False, deleted_at=now
78
+ product.restore() # sets is_active=True, deleted_at=None
79
+
80
+ # Filtered queries
81
+ Product.objects.all() # active only
82
+ Product.objects.deleted() # soft-deleted only
83
+ Product.all_objects.all() # everything
84
+ ```
85
+
86
+ ## Settings
87
+
88
+ All settings use the `ICV_CORE_` prefix. Every setting has a sensible default.
89
+
90
+ | Setting | Default | Description |
91
+ |---------|---------|-------------|
92
+ | `ICV_CORE_UUID_VERSION` | `4` | UUID version for primary keys |
93
+ | `ICV_CORE_ALLOW_HARD_DELETE` | `False` | Allow `.delete()` on SoftDeleteModel |
94
+ | `ICV_CORE_TRACK_CREATED_BY` | `False` | Enable created_by/updated_by tracking |
95
+ | `ICV_CORE_AUDIT_ENABLED` | `False` | Enable the audit subsystem |
96
+ | `ICV_CORE_AUDIT_RETENTION_DAYS` | `365` | Days before audit entries are eligible for archival |
97
+
98
+ See [APP-001](../../docs/specs/APP-001-core.md) Section 2 for the full settings reference.
@@ -0,0 +1,63 @@
1
+ # django-icv-core
2
+
3
+ [![CI](https://github.com/nigelcopley/icv-django/actions/workflows/ci.yml/badge.svg)](https://github.com/nigelcopley/icv-django/actions/workflows/ci.yml)
4
+ [![PyPI version](https://img.shields.io/pypi/v/django-icv-core.svg)](https://pypi.org/project/django-icv-core/)
5
+ [![Python versions](https://img.shields.io/pypi/pyversions/django-icv-core.svg)](https://pypi.org/project/django-icv-core/)
6
+ [![Django versions](https://img.shields.io/pypi/djversions/django-icv-core.svg)](https://pypi.org/project/django-icv-core/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ Foundation layer for ICV-Django packages. Provides abstract base models,
10
+ custom managers, middleware, utilities, template tags, and an optional audit
11
+ subsystem.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install django-icv-core
17
+ ```
18
+
19
+ ```python
20
+ INSTALLED_APPS = [
21
+ # ...
22
+ "icv_core",
23
+ ]
24
+ ```
25
+
26
+ ## Documentation
27
+
28
+ See [APP-001: Core](../../docs/specs/APP-001-core.md) for the full specification.
29
+
30
+ ## Quick Start
31
+
32
+ ```python
33
+ from icv_core.models import BaseModel, SoftDeleteModel
34
+
35
+ class Article(BaseModel):
36
+ title = models.CharField(max_length=255)
37
+
38
+ class Product(SoftDeleteModel):
39
+ name = models.CharField(max_length=255)
40
+
41
+ # Soft delete
42
+ product.soft_delete() # sets is_active=False, deleted_at=now
43
+ product.restore() # sets is_active=True, deleted_at=None
44
+
45
+ # Filtered queries
46
+ Product.objects.all() # active only
47
+ Product.objects.deleted() # soft-deleted only
48
+ Product.all_objects.all() # everything
49
+ ```
50
+
51
+ ## Settings
52
+
53
+ All settings use the `ICV_CORE_` prefix. Every setting has a sensible default.
54
+
55
+ | Setting | Default | Description |
56
+ |---------|---------|-------------|
57
+ | `ICV_CORE_UUID_VERSION` | `4` | UUID version for primary keys |
58
+ | `ICV_CORE_ALLOW_HARD_DELETE` | `False` | Allow `.delete()` on SoftDeleteModel |
59
+ | `ICV_CORE_TRACK_CREATED_BY` | `False` | Enable created_by/updated_by tracking |
60
+ | `ICV_CORE_AUDIT_ENABLED` | `False` | Enable the audit subsystem |
61
+ | `ICV_CORE_AUDIT_RETENTION_DAYS` | `365` | Days before audit entries are eligible for archival |
62
+
63
+ See [APP-001](../../docs/specs/APP-001-core.md) Section 2 for the full settings reference.
@@ -0,0 +1,78 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "django-icv-core"
7
+ version = "0.1.0"
8
+ description = "Foundation layer for ICV-Django: abstract base models, managers, middleware, utilities, and audit logging."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.11"
12
+ authors = [
13
+ {name = "Nigel Copley"},
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Framework :: Django",
18
+ "Framework :: Django :: 4.2",
19
+ "Framework :: Django :: 5.0",
20
+ "Framework :: Django :: 5.1",
21
+ "Intended Audience :: Developers",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ ]
26
+ keywords = [
27
+ "django",
28
+ "reusable",
29
+ "base-models",
30
+ "uuid",
31
+ "soft-delete",
32
+ "audit",
33
+ "timestamps",
34
+ ]
35
+ dependencies = [
36
+ "Django>=4.2",
37
+ ]
38
+
39
+ [project.urls]
40
+ Homepage = "https://github.com/nigelcopley/icv-django"
41
+ Documentation = "https://github.com/nigelcopley/icv-django/tree/main/packages/icv-core"
42
+ Changelog = "https://github.com/nigelcopley/icv-django/tree/main/packages/icv-core/CHANGELOG.md"
43
+ "Issue Tracker" = "https://github.com/nigelcopley/icv-django/issues"
44
+ "Source Code" = "https://github.com/nigelcopley/icv-django/tree/main/packages/icv-core"
45
+
46
+ [project.optional-dependencies]
47
+ dev = [
48
+ "pytest>=8.0",
49
+ "pytest-django>=4.8",
50
+ "pytest-cov>=5.0",
51
+ "factory-boy>=3.3",
52
+ "ruff>=0.5.0",
53
+ "mypy>=1.10",
54
+ "django-stubs>=5.0",
55
+ ]
56
+
57
+ [tool.setuptools.packages.find]
58
+ where = ["src"]
59
+
60
+ # pytest config is centralised in the root pyproject.toml.
61
+ # Run tests from the project root: pytest packages/icv-core/tests/
62
+
63
+ # ruff config is centralised in the root pyproject.toml.
64
+
65
+ [tool.mypy]
66
+ python_version = "3.11"
67
+ plugins = ["mypy_django_plugin.main"]
68
+ strict = false
69
+
70
+ [tool.django-stubs]
71
+ django_settings_module = "tests.settings"
72
+
73
+ [tool.coverage.run]
74
+ source = ["src"]
75
+ omit = ["*/migrations/*", "*/testing/*"]
76
+
77
+ [tool.coverage.report]
78
+ fail_under = 90
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,98 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-icv-core
3
+ Version: 0.1.0
4
+ Summary: Foundation layer for ICV-Django: abstract base models, managers, middleware, utilities, and audit logging.
5
+ Author: Nigel Copley
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/nigelcopley/icv-django
8
+ Project-URL: Documentation, https://github.com/nigelcopley/icv-django/tree/main/packages/icv-core
9
+ Project-URL: Changelog, https://github.com/nigelcopley/icv-django/tree/main/packages/icv-core/CHANGELOG.md
10
+ Project-URL: Issue Tracker, https://github.com/nigelcopley/icv-django/issues
11
+ Project-URL: Source Code, https://github.com/nigelcopley/icv-django/tree/main/packages/icv-core
12
+ Keywords: django,reusable,base-models,uuid,soft-delete,audit,timestamps
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Framework :: Django
15
+ Classifier: Framework :: Django :: 4.2
16
+ Classifier: Framework :: Django :: 5.0
17
+ Classifier: Framework :: Django :: 5.1
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Requires-Python: >=3.11
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: Django>=4.2
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8.0; extra == "dev"
28
+ Requires-Dist: pytest-django>=4.8; extra == "dev"
29
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
30
+ Requires-Dist: factory-boy>=3.3; extra == "dev"
31
+ Requires-Dist: ruff>=0.5.0; extra == "dev"
32
+ Requires-Dist: mypy>=1.10; extra == "dev"
33
+ Requires-Dist: django-stubs>=5.0; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ # django-icv-core
37
+
38
+ [![CI](https://github.com/nigelcopley/icv-django/actions/workflows/ci.yml/badge.svg)](https://github.com/nigelcopley/icv-django/actions/workflows/ci.yml)
39
+ [![PyPI version](https://img.shields.io/pypi/v/django-icv-core.svg)](https://pypi.org/project/django-icv-core/)
40
+ [![Python versions](https://img.shields.io/pypi/pyversions/django-icv-core.svg)](https://pypi.org/project/django-icv-core/)
41
+ [![Django versions](https://img.shields.io/pypi/djversions/django-icv-core.svg)](https://pypi.org/project/django-icv-core/)
42
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
43
+
44
+ Foundation layer for ICV-Django packages. Provides abstract base models,
45
+ custom managers, middleware, utilities, template tags, and an optional audit
46
+ subsystem.
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ pip install django-icv-core
52
+ ```
53
+
54
+ ```python
55
+ INSTALLED_APPS = [
56
+ # ...
57
+ "icv_core",
58
+ ]
59
+ ```
60
+
61
+ ## Documentation
62
+
63
+ See [APP-001: Core](../../docs/specs/APP-001-core.md) for the full specification.
64
+
65
+ ## Quick Start
66
+
67
+ ```python
68
+ from icv_core.models import BaseModel, SoftDeleteModel
69
+
70
+ class Article(BaseModel):
71
+ title = models.CharField(max_length=255)
72
+
73
+ class Product(SoftDeleteModel):
74
+ name = models.CharField(max_length=255)
75
+
76
+ # Soft delete
77
+ product.soft_delete() # sets is_active=False, deleted_at=now
78
+ product.restore() # sets is_active=True, deleted_at=None
79
+
80
+ # Filtered queries
81
+ Product.objects.all() # active only
82
+ Product.objects.deleted() # soft-deleted only
83
+ Product.all_objects.all() # everything
84
+ ```
85
+
86
+ ## Settings
87
+
88
+ All settings use the `ICV_CORE_` prefix. Every setting has a sensible default.
89
+
90
+ | Setting | Default | Description |
91
+ |---------|---------|-------------|
92
+ | `ICV_CORE_UUID_VERSION` | `4` | UUID version for primary keys |
93
+ | `ICV_CORE_ALLOW_HARD_DELETE` | `False` | Allow `.delete()` on SoftDeleteModel |
94
+ | `ICV_CORE_TRACK_CREATED_BY` | `False` | Enable created_by/updated_by tracking |
95
+ | `ICV_CORE_AUDIT_ENABLED` | `False` | Enable the audit subsystem |
96
+ | `ICV_CORE_AUDIT_RETENTION_DAYS` | `365` | Days before audit entries are eligible for archival |
97
+
98
+ See [APP-001](../../docs/specs/APP-001-core.md) Section 2 for the full settings reference.
@@ -0,0 +1,67 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/django_icv_core.egg-info/PKG-INFO
5
+ src/django_icv_core.egg-info/SOURCES.txt
6
+ src/django_icv_core.egg-info/dependency_links.txt
7
+ src/django_icv_core.egg-info/requires.txt
8
+ src/django_icv_core.egg-info/top_level.txt
9
+ src/icv_core/__init__.py
10
+ src/icv_core/admin.py
11
+ src/icv_core/apps.py
12
+ src/icv_core/checks.py
13
+ src/icv_core/conf.py
14
+ src/icv_core/exceptions.py
15
+ src/icv_core/handlers.py
16
+ src/icv_core/middleware.py
17
+ src/icv_core/py.typed
18
+ src/icv_core/signals.py
19
+ src/icv_core/audit/__init__.py
20
+ src/icv_core/audit/decorators.py
21
+ src/icv_core/audit/handlers.py
22
+ src/icv_core/audit/middleware.py
23
+ src/icv_core/audit/mixins.py
24
+ src/icv_core/audit/models.py
25
+ src/icv_core/audit/services.py
26
+ src/icv_core/audit/signals.py
27
+ src/icv_core/audit/tasks.py
28
+ src/icv_core/audit/api/__init__.py
29
+ src/icv_core/audit/api/serializers.py
30
+ src/icv_core/audit/api/urls.py
31
+ src/icv_core/audit/api/views.py
32
+ src/icv_core/management/__init__.py
33
+ src/icv_core/management/commands/__init__.py
34
+ src/icv_core/management/commands/icv_core_audit_archive.py
35
+ src/icv_core/management/commands/icv_core_audit_stats.py
36
+ src/icv_core/management/commands/icv_core_check.py
37
+ src/icv_core/managers/__init__.py
38
+ src/icv_core/managers/scoped.py
39
+ src/icv_core/managers/soft_delete.py
40
+ src/icv_core/migrations/0001_initial.py
41
+ src/icv_core/migrations/__init__.py
42
+ src/icv_core/models/__init__.py
43
+ src/icv_core/models/base.py
44
+ src/icv_core/models/compliance.py
45
+ src/icv_core/models/soft_delete.py
46
+ src/icv_core/services/__init__.py
47
+ src/icv_core/templatetags/__init__.py
48
+ src/icv_core/templatetags/icv_core.py
49
+ src/icv_core/tenancy/__init__.py
50
+ src/icv_core/tenancy/context.py
51
+ src/icv_core/tenancy/managers.py
52
+ src/icv_core/tenancy/mixins.py
53
+ src/icv_core/testing/__init__.py
54
+ src/icv_core/testing/factories.py
55
+ src/icv_core/testing/fixtures.py
56
+ src/icv_core/testing/helpers.py
57
+ tests/test_audit_api.py
58
+ tests/test_audit_features.py
59
+ tests/test_audit_services.py
60
+ tests/test_commands_and_checks.py
61
+ tests/test_conf.py
62
+ tests/test_managers.py
63
+ tests/test_middleware.py
64
+ tests/test_models.py
65
+ tests/test_signals.py
66
+ tests/test_templatetags.py
67
+ tests/test_tenancy.py
@@ -0,0 +1,10 @@
1
+ Django>=4.2
2
+
3
+ [dev]
4
+ pytest>=8.0
5
+ pytest-django>=4.8
6
+ pytest-cov>=5.0
7
+ factory-boy>=3.3
8
+ ruff>=0.5.0
9
+ mypy>=1.10
10
+ django-stubs>=5.0
@@ -0,0 +1,10 @@
1
+ """
2
+ icv-core — Foundation layer for ICV-Django packages.
3
+
4
+ Provides abstract base models, custom managers, middleware, utilities,
5
+ template tags, and an optional audit subsystem.
6
+ """
7
+
8
+ __version__ = "0.1.0"
9
+
10
+ default_app_config = "icv_core.apps.IcvCoreConfig"
@@ -0,0 +1,41 @@
1
+ """Admin configuration for icv-core.
2
+
3
+ No concrete models in the core layer. Provides IcvSoftDeleteAdmin mixin
4
+ for consuming projects.
5
+ """
6
+
7
+ from django.contrib import admin
8
+ from django.utils.translation import gettext_lazy as _
9
+
10
+
11
+ class IcvSoftDeleteAdmin(admin.ModelAdmin):
12
+ """
13
+ Admin mixin for SoftDeleteModel subclasses.
14
+
15
+ Includes soft-deleted records in the admin queryset and provides
16
+ restore/soft-delete bulk actions.
17
+
18
+ Usage::
19
+
20
+ @admin.register(MyModel)
21
+ class MyModelAdmin(IcvSoftDeleteAdmin):
22
+ ...
23
+ """
24
+
25
+ list_filter = ("is_active",)
26
+
27
+ def get_queryset(self, request):
28
+ """Include soft-deleted records in the admin list."""
29
+ return self.model.all_objects.all()
30
+
31
+ actions = ["soft_delete_selected", "restore_selected"]
32
+
33
+ @admin.action(description=_("Soft-delete selected records"))
34
+ def soft_delete_selected(self, request, queryset) -> None:
35
+ for obj in queryset.filter(is_active=True):
36
+ obj.soft_delete()
37
+
38
+ @admin.action(description=_("Restore selected records"))
39
+ def restore_selected(self, request, queryset) -> None:
40
+ for obj in queryset.filter(is_active=False):
41
+ obj.restore()
@@ -0,0 +1,20 @@
1
+ from django.apps import AppConfig
2
+ from django.utils.translation import gettext_lazy as _
3
+
4
+
5
+ class IcvCoreConfig(AppConfig):
6
+ name = "icv_core"
7
+ label = "icv_core"
8
+ verbose_name = _("ICV Core")
9
+ default_auto_field = "django.db.models.BigAutoField"
10
+
11
+ def ready(self) -> None:
12
+ from icv_core.conf import ICV_CORE_AUDIT_ENABLED
13
+
14
+ from . import (
15
+ checks, # noqa: F401 — register system checks
16
+ handlers, # noqa: F401 — connect signal handlers
17
+ )
18
+
19
+ if ICV_CORE_AUDIT_ENABLED:
20
+ from icv_core.audit import handlers as audit_handlers # noqa: F401
@@ -0,0 +1,12 @@
1
+ """
2
+ icv_core.audit — Audit subsystem for icv-core.
3
+
4
+ Active only when ICV_CORE_AUDIT_ENABLED=True. Provides:
5
+ - AuditEntry, AdminActivityLog, SystemAlert concrete models
6
+ - AuditMixin for automatic model change tracking
7
+ - AuditRequestMiddleware for request context capture
8
+ - log_event() service function
9
+ - @audited decorator
10
+ - Celery task for archiving old entries
11
+ - DRF API viewsets (admin-only)
12
+ """
@@ -0,0 +1,69 @@
1
+ """DRF serializers for the audit subsystem."""
2
+
3
+ from rest_framework import serializers
4
+
5
+ from icv_core.audit.models import AdminActivityLog, AuditEntry, SystemAlert
6
+
7
+
8
+ class AuditEntrySerializer(serializers.ModelSerializer):
9
+ class Meta:
10
+ model = AuditEntry
11
+ fields = [
12
+ "id",
13
+ "event_type",
14
+ "action",
15
+ "user",
16
+ "ip_address",
17
+ "user_agent",
18
+ "target_content_type",
19
+ "target_object_id",
20
+ "description",
21
+ "metadata",
22
+ "created_at",
23
+ ]
24
+ read_only_fields = fields
25
+
26
+
27
+ class AdminActivityLogSerializer(serializers.ModelSerializer):
28
+ class Meta:
29
+ model = AdminActivityLog
30
+ fields = [
31
+ "id",
32
+ "admin_user",
33
+ "action_type",
34
+ "description",
35
+ "target_content_type",
36
+ "target_object_id",
37
+ "ip_address",
38
+ "user_agent",
39
+ "metadata",
40
+ "created_at",
41
+ ]
42
+ read_only_fields = fields
43
+
44
+
45
+ class SystemAlertSerializer(serializers.ModelSerializer):
46
+ class Meta:
47
+ model = SystemAlert
48
+ fields = [
49
+ "id",
50
+ "alert_type",
51
+ "severity",
52
+ "title",
53
+ "message",
54
+ "metadata",
55
+ "is_resolved",
56
+ "resolved_by",
57
+ "resolved_at",
58
+ "resolution_notes",
59
+ "created_at",
60
+ "updated_at",
61
+ ]
62
+ read_only_fields = [
63
+ "id",
64
+ "is_resolved",
65
+ "resolved_by",
66
+ "resolved_at",
67
+ "created_at",
68
+ "updated_at",
69
+ ]
@@ -0,0 +1,12 @@
1
+ """URL configuration for the icv-core audit API."""
2
+
3
+ from rest_framework.routers import DefaultRouter
4
+
5
+ from icv_core.audit.api.views import AdminActivityLogViewSet, AuditEntryViewSet, SystemAlertViewSet
6
+
7
+ router = DefaultRouter()
8
+ router.register(r"entries", AuditEntryViewSet, basename="audit-entry")
9
+ router.register(r"admin-activity", AdminActivityLogViewSet, basename="audit-admin-activity")
10
+ router.register(r"alerts", SystemAlertViewSet, basename="audit-alert")
11
+
12
+ urlpatterns = router.urls