django-bulk-hooks 0.1.87__tar.gz → 0.1.88__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.
Potentially problematic release.
This version of django-bulk-hooks might be problematic. Click here for more details.
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/PKG-INFO +1 -1
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/django_bulk_hooks/conditions.py +21 -3
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/pyproject.toml +1 -1
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/LICENSE +0 -0
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/README.md +0 -0
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/django_bulk_hooks/__init__.py +0 -0
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/django_bulk_hooks/constants.py +0 -0
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/django_bulk_hooks/context.py +0 -0
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/django_bulk_hooks/decorators.py +0 -0
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/django_bulk_hooks/engine.py +0 -0
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/django_bulk_hooks/enums.py +0 -0
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/django_bulk_hooks/handler.py +0 -0
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/django_bulk_hooks/manager.py +0 -0
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/django_bulk_hooks/models.py +0 -0
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/django_bulk_hooks/queryset.py +0 -0
- {django_bulk_hooks-0.1.87 → django_bulk_hooks-0.1.88}/django_bulk_hooks/registry.py +0 -0
|
@@ -245,15 +245,33 @@ class WasEqual(HookCondition):
|
|
|
245
245
|
|
|
246
246
|
|
|
247
247
|
class HasChanged(HookCondition):
|
|
248
|
-
def __init__(self, field):
|
|
248
|
+
def __init__(self, field, has_changed=True):
|
|
249
|
+
"""
|
|
250
|
+
Check if a field's value has changed or remained the same.
|
|
251
|
+
|
|
252
|
+
Args:
|
|
253
|
+
field: The field name to check
|
|
254
|
+
has_changed: If True (default), condition passes when field has changed.
|
|
255
|
+
If False, condition passes when field has remained the same.
|
|
256
|
+
This is useful for:
|
|
257
|
+
- Detecting stable/unchanged fields
|
|
258
|
+
- Validating field immutability
|
|
259
|
+
- Ensuring critical fields remain constant
|
|
260
|
+
- State machine validations
|
|
261
|
+
"""
|
|
249
262
|
self.field = field
|
|
263
|
+
self.has_changed = has_changed
|
|
250
264
|
|
|
251
265
|
def check(self, instance, original_instance=None):
|
|
252
266
|
if original_instance is None:
|
|
253
|
-
|
|
267
|
+
# For new instances:
|
|
268
|
+
# - If we're checking for changes (has_changed=True), return False since there's no change yet
|
|
269
|
+
# - If we're checking for stability (has_changed=False), return True since it's technically unchanged
|
|
270
|
+
return not self.has_changed
|
|
271
|
+
|
|
254
272
|
current_value = resolve_dotted_attr(instance, self.field)
|
|
255
273
|
original_value = resolve_dotted_attr(original_instance, self.field)
|
|
256
|
-
return current_value != original_value
|
|
274
|
+
return (current_value != original_value) == self.has_changed
|
|
257
275
|
|
|
258
276
|
def get_required_fields(self):
|
|
259
277
|
return {self.field.split('.')[0]}
|
|
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
|