djhtmx 1.0.0__tar.gz → 1.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 (39) hide show
  1. {djhtmx-1.0.0 → djhtmx-1.1.0}/CHANGELOG.md +16 -6
  2. {djhtmx-1.0.0 → djhtmx-1.1.0}/PKG-INFO +1 -1
  3. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/__init__.py +1 -1
  4. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/command_queue.py +4 -1
  5. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/utils.py +8 -5
  6. {djhtmx-1.0.0 → djhtmx-1.1.0}/.gitignore +0 -0
  7. {djhtmx-1.0.0 → djhtmx-1.1.0}/LICENSE +0 -0
  8. {djhtmx-1.0.0 → djhtmx-1.1.0}/MANIFEST.in +0 -0
  9. {djhtmx-1.0.0 → djhtmx-1.1.0}/README.md +0 -0
  10. {djhtmx-1.0.0 → djhtmx-1.1.0}/pyproject.toml +0 -0
  11. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/apps.py +0 -0
  12. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/commands.py +0 -0
  13. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/component.py +0 -0
  14. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/consumer.py +0 -0
  15. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/context.py +0 -0
  16. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/exceptions.py +0 -0
  17. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/global_events.py +0 -0
  18. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/introspection.py +0 -0
  19. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/json.py +0 -0
  20. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/management/commands/htmx.py +0 -0
  21. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/middleware.py +0 -0
  22. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/query.py +0 -0
  23. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/repo.py +0 -0
  24. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/settings.py +0 -0
  25. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/static/htmx/2.0.4/ext/ws.js +0 -0
  26. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/static/htmx/2.0.4/htmx.amd.js +0 -0
  27. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/static/htmx/2.0.4/htmx.cjs.js +0 -0
  28. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/static/htmx/2.0.4/htmx.esm.d.ts +0 -0
  29. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/static/htmx/2.0.4/htmx.esm.js +0 -0
  30. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/static/htmx/2.0.4/htmx.js +0 -0
  31. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/static/htmx/2.0.4/htmx.min.js +0 -0
  32. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/static/htmx/django.js +0 -0
  33. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/templates/htmx/headers.html +0 -0
  34. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/templates/htmx/lazy.html +0 -0
  35. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/templatetags/__init__.py +0 -0
  36. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/templatetags/htmx.py +0 -0
  37. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/testing.py +0 -0
  38. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/tracing.py +0 -0
  39. {djhtmx-1.0.0 → djhtmx-1.1.0}/src/djhtmx/urls.py +0 -0
@@ -7,16 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.1.0] - 2025-08-15
11
+
12
+ ### Changed
13
+ - **BREAKING**: Refactored `get_model_subscriptions` to use explicit action parameters instead of auto-subscribing to all actions by default
14
+ - Changed default behavior from implicit subscription to all actions to explicit opt-in only
15
+ - Updated command queue to subscribe to both instance and model-level signals for better coverage
16
+
10
17
  ### Added
11
18
  - **Custom Context Support for Render Command**: The `Render` command now accepts an optional `context` parameter of type `dict[str, Any]`. When provided, this context will override the component's default context during template rendering, while preserving essential HTMX variables (`htmx_repo`, `hx_oob`, `this`). This enables more flexible template rendering scenarios where you need to pass custom data that differs from the component's state.
19
+ - Added type annotation `Action = Literal["created", "updated", "deleted"]` for better type safety
20
+ - Support for `None` in actions parameter to include bare prefix subscriptions
12
21
 
13
- ### Changed
14
- - The `Render` dataclass now includes a `context: dict[str, Any] | None = None` field
22
+ ### Technical Details
23
+ - The `Render` dataclass now includes a `context: dict[str, Any] | None = None` field
15
24
  - The `Repository.render_html` method signature now includes an optional `context` parameter
16
25
  - Template rendering logic now supports context override while maintaining backwards compatibility
17
-
18
- ### Technical Details
19
- - All changes are fully backwards compatible - existing code continues to work without modification
26
+ - All custom context changes are fully backwards compatible - existing code continues to work without modification
20
27
  - When `context=None` (default), behavior is identical to previous versions
21
28
  - When `context` is provided, it takes precedence over component context but essential HTMX context variables are preserved
22
- - Comprehensive test coverage added for the new functionality
29
+ - Comprehensive test coverage added for all new functionality
30
+
31
+ ### Migration Guide
32
+ - If you were relying on `get_model_subscriptions()` to automatically subscribe to all actions, you now need to explicitly pass the actions you want: `get_model_subscriptions(instance, actions=["created", "updated", "deleted"])`
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: djhtmx
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: Interactive UI Components for Django using HTMX
5
5
  Project-URL: Homepage, https://github.com/edelvalle/djhtmx
6
6
  Project-URL: Documentation, https://github.com/edelvalle/djhtmx#readme
@@ -1,4 +1,4 @@
1
1
  from .middleware import middleware
2
2
 
3
- __version__ = "1.0.0"
3
+ __version__ = "1.1.0"
4
4
  __all__ = ("middleware",)
@@ -48,7 +48,10 @@ class CommandQueue:
48
48
  else:
49
49
  action = "updated"
50
50
 
51
- signals = get_model_subscriptions(instance, actions=(action,))
51
+ signals = get_model_subscriptions(
52
+ instance, actions=(action, None)
53
+ ) | get_model_subscriptions(type(instance), actions=(action, None))
54
+
52
55
  for field in get_related_fields(sender):
53
56
  fk_id = getattr(instance, field.name)
54
57
  signal = f"{field.related_model_name}.{fk_id}.{field.relation_name}"
@@ -63,9 +63,12 @@ def get_instance_subscriptions(
63
63
  return {f"{prefix}.{action}" for action in actions}
64
64
 
65
65
 
66
+ Action = t.Literal["created", "updated", "deleted"]
67
+
68
+
66
69
  def get_model_subscriptions(
67
70
  obj: type[models.Model] | models.Model,
68
- actions: t.Sequence[str] = ("created", "updated", "deleted"),
71
+ actions: t.Sequence[Action | None] = (),
69
72
  ) -> set[str]:
70
73
  """Get the subscriptions to actions of the model.
71
74
 
@@ -77,6 +80,7 @@ def get_model_subscriptions(
77
80
  possible relation (e.g 'users.deleted').
78
81
 
79
82
  """
83
+ actions = actions or (None,)
80
84
  if isinstance(obj, models.Model):
81
85
  cls = type(obj)
82
86
  instance = obj
@@ -85,10 +89,9 @@ def get_model_subscriptions(
85
89
  instance = None
86
90
  app = cls._meta.app_label
87
91
  name = cls._meta.model_name
88
- result = {(model_prefix := f"{app}.{name}")}
89
- if instance:
90
- result.add(prefix := f"{model_prefix}.{instance.pk}")
91
- result.update(f"{prefix}.{action}" for action in actions)
92
+ model_prefix = f"{app}.{name}"
93
+ prefix = f"{model_prefix}.{instance.pk}" if instance else model_prefix
94
+ result = {(f"{prefix}.{action}" if action else prefix) for action in actions}
92
95
  return result
93
96
 
94
97
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes