django-bulk-hooks 0.1.89__py3-none-any.whl → 0.1.90__py3-none-any.whl
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/conditions.py +7 -2
- django_bulk_hooks/engine.py +15 -3
- {django_bulk_hooks-0.1.89.dist-info → django_bulk_hooks-0.1.90.dist-info}/METADATA +1 -1
- {django_bulk_hooks-0.1.89.dist-info → django_bulk_hooks-0.1.90.dist-info}/RECORD +6 -6
- {django_bulk_hooks-0.1.89.dist-info → django_bulk_hooks-0.1.90.dist-info}/LICENSE +0 -0
- {django_bulk_hooks-0.1.89.dist-info → django_bulk_hooks-0.1.90.dist-info}/WHEEL +0 -0
django_bulk_hooks/conditions.py
CHANGED
|
@@ -209,8 +209,13 @@ class IsEqual(HookCondition):
|
|
|
209
209
|
self.value = value
|
|
210
210
|
|
|
211
211
|
def check(self, instance, original_instance=None):
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
# Handle the case where the field might not exist yet
|
|
213
|
+
try:
|
|
214
|
+
current_value = getattr(instance, self.field, None)
|
|
215
|
+
return current_value == self.value
|
|
216
|
+
except Exception:
|
|
217
|
+
# If there's any error accessing the field, treat it as None
|
|
218
|
+
return self.value is None
|
|
214
219
|
|
|
215
220
|
def get_required_fields(self):
|
|
216
221
|
return {self.field.split('.')[0]}
|
django_bulk_hooks/engine.py
CHANGED
|
@@ -57,14 +57,26 @@ def run(model_cls, event, new_instances, original_instances=None, ctx=None):
|
|
|
57
57
|
to_process_new = []
|
|
58
58
|
to_process_old = []
|
|
59
59
|
|
|
60
|
+
logger.debug(f"Checking condition {condition.__class__.__name__} for {len(new_instances)} instances")
|
|
60
61
|
for new, original in zip(new_instances, original_instances, strict=True):
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
logger.debug(f"Checking instance {new.__class__.__name__}(pk={new.pk})")
|
|
63
|
+
try:
|
|
64
|
+
matches = condition.check(new, original)
|
|
65
|
+
logger.debug(f"Condition check result: {matches}")
|
|
66
|
+
if matches:
|
|
67
|
+
to_process_new.append(new)
|
|
68
|
+
to_process_old.append(original)
|
|
69
|
+
except Exception as e:
|
|
70
|
+
logger.error(f"Error checking condition: {e}")
|
|
71
|
+
raise
|
|
64
72
|
|
|
65
73
|
# Only call if we have matching instances
|
|
66
74
|
if to_process_new:
|
|
75
|
+
logger.debug(f"Running hook for {len(to_process_new)} matching instances")
|
|
67
76
|
func(new_records=to_process_new, old_records=to_process_old if any(to_process_old) else None)
|
|
77
|
+
else:
|
|
78
|
+
logger.debug("No instances matched condition")
|
|
68
79
|
else:
|
|
69
80
|
# No condition, process all instances
|
|
81
|
+
logger.debug("No condition, processing all instances")
|
|
70
82
|
func(new_records=new_instances, old_records=original_instances if any(original_instances) else None)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
django_bulk_hooks/__init__.py,sha256=2PcJ6xz7t7Du0nmLO_5732G6u_oZTygogG0fKESRHHk,1082
|
|
2
|
-
django_bulk_hooks/conditions.py,sha256=
|
|
2
|
+
django_bulk_hooks/conditions.py,sha256=w3uxXlsJcxSsoH7_7dfmYkO6oIr8OqgoaUGp6oDIGZo,13573
|
|
3
3
|
django_bulk_hooks/constants.py,sha256=3x1H1fSUUNo0DZONN7GUVDuySZctTR-jtByBHmAIX5w,303
|
|
4
4
|
django_bulk_hooks/context.py,sha256=HVDT73uSzvgrOR6mdXTvsBm3hLOgBU8ant_mB7VlFuM,380
|
|
5
5
|
django_bulk_hooks/decorators.py,sha256=zstmb27dKcOHu3Atg7cauewCTzPvUmq03mzVKJRi56o,7230
|
|
6
|
-
django_bulk_hooks/engine.py,sha256=
|
|
6
|
+
django_bulk_hooks/engine.py,sha256=1hqjmLRmxwI-OSC6GJizD_CFGPw7pndAa0GMIV7P-XQ,3544
|
|
7
7
|
django_bulk_hooks/enums.py,sha256=Zo8_tJzuzZ2IKfVc7gZ-0tWPT8q1QhqZbAyoh9ZVJbs,381
|
|
8
8
|
django_bulk_hooks/handler.py,sha256=Qpg_zT6SsQiTlhduvzXxPdG6uynjyR2fBjj-R6HZiXI,4861
|
|
9
9
|
django_bulk_hooks/manager.py,sha256=DcVosEA4RS79KSYgw3Z14_a9Sd8CfxNNc5F3eSb8xc0,11459
|
|
10
10
|
django_bulk_hooks/models.py,sha256=9KvWkmrR0wbTHN6r7-FrSSO9ViS83NvG7iXLBw_iDZs,4793
|
|
11
11
|
django_bulk_hooks/queryset.py,sha256=7lLqhZ-XOYsZ1I3Loxi4Nhz79M8HlTYE413AW8nyeDI,1330
|
|
12
12
|
django_bulk_hooks/registry.py,sha256=Vh78exKYcdZhM27120kQm-iXGOjd_kf9ZUYBZ8eQ2V0,683
|
|
13
|
-
django_bulk_hooks-0.1.
|
|
14
|
-
django_bulk_hooks-0.1.
|
|
15
|
-
django_bulk_hooks-0.1.
|
|
16
|
-
django_bulk_hooks-0.1.
|
|
13
|
+
django_bulk_hooks-0.1.90.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
|
|
14
|
+
django_bulk_hooks-0.1.90.dist-info/METADATA,sha256=v4CFYd--pCowFVN0XxbJJ2P3xOQA-n82pDPjgqNGHY4,9051
|
|
15
|
+
django_bulk_hooks-0.1.90.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
16
|
+
django_bulk_hooks-0.1.90.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|