django-bulk-hooks 0.1.95__tar.gz → 0.1.96__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.95 → django_bulk_hooks-0.1.96}/PKG-INFO +1 -1
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/django_bulk_hooks/conditions.py +23 -3
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/pyproject.toml +1 -1
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/LICENSE +0 -0
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/README.md +0 -0
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/django_bulk_hooks/__init__.py +0 -0
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/django_bulk_hooks/constants.py +0 -0
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/django_bulk_hooks/context.py +0 -0
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/django_bulk_hooks/decorators.py +0 -0
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/django_bulk_hooks/engine.py +0 -0
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/django_bulk_hooks/enums.py +0 -0
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/django_bulk_hooks/handler.py +0 -0
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/django_bulk_hooks/manager.py +0 -0
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/django_bulk_hooks/models.py +0 -0
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/django_bulk_hooks/queryset.py +0 -0
- {django_bulk_hooks-0.1.95 → django_bulk_hooks-0.1.96}/django_bulk_hooks/registry.py +0 -0
|
@@ -195,13 +195,33 @@ class WasEqual(HookCondition):
|
|
|
195
195
|
|
|
196
196
|
|
|
197
197
|
class HasChanged(HookCondition):
|
|
198
|
-
def __init__(self, field_name):
|
|
198
|
+
def __init__(self, field_name, has_changed=True):
|
|
199
|
+
"""
|
|
200
|
+
Check if a field's value has changed or remained the same.
|
|
201
|
+
|
|
202
|
+
Args:
|
|
203
|
+
field_name: The field name to check
|
|
204
|
+
has_changed: If True (default), condition passes when field has changed.
|
|
205
|
+
If False, condition passes when field has remained the same.
|
|
206
|
+
This is useful for:
|
|
207
|
+
- Detecting stable/unchanged fields
|
|
208
|
+
- Validating field immutability
|
|
209
|
+
- Ensuring critical fields remain constant
|
|
210
|
+
- State machine validations
|
|
211
|
+
"""
|
|
199
212
|
self.field_name = field_name
|
|
213
|
+
self.has_changed = has_changed
|
|
200
214
|
|
|
201
215
|
def check(self, instance, original_instance=None):
|
|
202
216
|
if original_instance is None:
|
|
203
|
-
|
|
204
|
-
|
|
217
|
+
# For new instances:
|
|
218
|
+
# - If we're checking for changes (has_changed=True), return True since it's a new record
|
|
219
|
+
# - If we're checking for stability (has_changed=False), return False since it's technically changed from nothing
|
|
220
|
+
return self.has_changed
|
|
221
|
+
|
|
222
|
+
current_value = getattr(instance, self.field_name, None)
|
|
223
|
+
original_value = getattr(original_instance, self.field_name, None)
|
|
224
|
+
return (current_value != original_value) == self.has_changed
|
|
205
225
|
|
|
206
226
|
def get_required_fields(self):
|
|
207
227
|
return {self.field_name}
|
|
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
|