django-bulk-hooks 0.1.61__py3-none-any.whl → 0.1.63__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.

@@ -31,7 +31,7 @@ class HookCondition:
31
31
  return NotCondition(self)
32
32
 
33
33
 
34
- class WhenFieldValueIsNot(HookCondition):
34
+ class IsNotEqual(HookCondition):
35
35
  def __init__(self, field, value, only_on_change=False):
36
36
  self.field = field
37
37
  self.value = value
@@ -54,7 +54,7 @@ class WhenFieldValueIsNot(HookCondition):
54
54
  return current != self.value
55
55
 
56
56
 
57
- class WhenFieldValueIs(HookCondition):
57
+ class IsEqual(HookCondition):
58
58
  def __init__(self, field, value, only_on_change=False):
59
59
  self.field = field
60
60
  self.value = value
@@ -77,7 +77,7 @@ class WhenFieldValueIs(HookCondition):
77
77
  return current == self.value
78
78
 
79
79
 
80
- class WhenFieldHasChanged(HookCondition):
80
+ class HasChanged(HookCondition):
81
81
  def __init__(self, field, has_changed=True):
82
82
  self.field = field
83
83
  self.has_changed = has_changed
@@ -90,7 +90,7 @@ class WhenFieldHasChanged(HookCondition):
90
90
  return (current != previous) == self.has_changed
91
91
 
92
92
 
93
- class WhenFieldValueWas(HookCondition):
93
+ class WasEqual(HookCondition):
94
94
  def __init__(self, field, value, only_on_change=False):
95
95
  """
96
96
  Check if a field's original value was `value`.
@@ -111,7 +111,7 @@ class WhenFieldValueWas(HookCondition):
111
111
  return previous == self.value
112
112
 
113
113
 
114
- class WhenFieldValueChangesTo(HookCondition):
114
+ class ChangesTo(HookCondition):
115
115
  def __init__(self, field, value):
116
116
  """
117
117
  Check if a field's value has changed to `value`.
@@ -128,6 +128,46 @@ class WhenFieldValueChangesTo(HookCondition):
128
128
  return previous != self.value and current == self.value
129
129
 
130
130
 
131
+ class IsGreaterThan(HookCondition):
132
+ def __init__(self, field, value):
133
+ self.field = field
134
+ self.value = value
135
+
136
+ def check(self, instance, original_instance=None):
137
+ current = resolve_dotted_attr(instance, self.field)
138
+ return current is not None and current > self.value
139
+
140
+
141
+ class IsGreaterThanOrEqual(HookCondition):
142
+ def __init__(self, field, value):
143
+ self.field = field
144
+ self.value = value
145
+
146
+ def check(self, instance, original_instance=None):
147
+ current = resolve_dotted_attr(instance, self.field)
148
+ return current is not None and current >= self.value
149
+
150
+
151
+ class IsLessThan(HookCondition):
152
+ def __init__(self, field, value):
153
+ self.field = field
154
+ self.value = value
155
+
156
+ def check(self, instance, original_instance=None):
157
+ current = resolve_dotted_attr(instance, self.field)
158
+ return current is not None and current < self.value
159
+
160
+
161
+ class IsLessThanOrEqual(HookCondition):
162
+ def __init__(self, field, value):
163
+ self.field = field
164
+ self.value = value
165
+
166
+ def check(self, instance, original_instance=None):
167
+ current = resolve_dotted_attr(instance, self.field)
168
+ return current is not None and current <= self.value
169
+
170
+
131
171
  class AndCondition(HookCondition):
132
172
  def __init__(self, cond1, cond2):
133
173
  self.cond1 = cond1
@@ -22,7 +22,7 @@ class BulkLifecycleManager(models.Manager):
22
22
  return LifecycleQuerySet(self.model, using=self._db)
23
23
 
24
24
  @transaction.atomic
25
- def bulk_update(self, objs, fields, batch_size=None, bypass_hooks=False):
25
+ def bulk_update(self, objs, fields, bypass_hooks=False, **kwargs):
26
26
  if not objs:
27
27
  return []
28
28
 
@@ -53,9 +53,7 @@ class BulkLifecycleManager(models.Manager):
53
53
  for i in range(0, len(objs), self.CHUNK_SIZE):
54
54
  chunk = objs[i : i + self.CHUNK_SIZE]
55
55
  # Call the base implementation to avoid re-triggering this method
56
- super(models.Manager, self).bulk_update(
57
- chunk, fields, batch_size=batch_size
58
- )
56
+ super(models.Manager, self).bulk_update(chunk, fields, **kwargs)
59
57
 
60
58
  if not bypass_hooks:
61
59
  engine.run(model_cls, AFTER_UPDATE, objs, originals, ctx=ctx)
@@ -106,9 +104,7 @@ class BulkLifecycleManager(models.Manager):
106
104
  return modified_fields
107
105
 
108
106
  @transaction.atomic
109
- def bulk_create(
110
- self, objs, batch_size=None, ignore_conflicts=False, bypass_hooks=False
111
- ):
107
+ def bulk_create(self, objs, bypass_hooks=False, **kwargs):
112
108
  model_cls = self.model
113
109
 
114
110
  if any(not isinstance(obj, model_cls) for obj in objs):
@@ -125,9 +121,7 @@ class BulkLifecycleManager(models.Manager):
125
121
  for i in range(0, len(objs), self.CHUNK_SIZE):
126
122
  chunk = objs[i : i + self.CHUNK_SIZE]
127
123
  result.extend(
128
- super(models.Manager, self).bulk_create(
129
- chunk, batch_size=batch_size, ignore_conflicts=ignore_conflicts
130
- )
124
+ super(models.Manager, self).bulk_create(chunk, **kwargs)
131
125
  )
132
126
 
133
127
  if not bypass_hooks:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: django-bulk-hooks
3
- Version: 0.1.61
3
+ Version: 0.1.63
4
4
  Summary: Lifecycle-style hooks for Django bulk operations like bulk_create and bulk_update.
5
5
  License: MIT
6
6
  Keywords: django,bulk,hooks
@@ -1,17 +1,17 @@
1
1
  django_bulk_hooks/__init__.py,sha256=6VFU52Kz5Yjhjr_RhID41nMaXUMZ4na_MVDXEhIMXc4,98
2
- django_bulk_hooks/conditions.py,sha256=UQP5Y7yyJXqDdUcUukRPxCbvrsV6HqNmIxERFZqBh58,5317
2
+ django_bulk_hooks/conditions.py,sha256=S8o8JLAeYoF5hNUaxmC2QwMtmak0C73aI-j4GtgmbAw,6541
3
3
  django_bulk_hooks/constants.py,sha256=Jks1BIADYbap2fpq3Ry0e7w-CiXBCsR9b5h1yan1qoc,192
4
4
  django_bulk_hooks/context.py,sha256=hElvgYZoH1nEM2dR7JIi7pbRt67za90ZVy0OzyFWMNg,367
5
5
  django_bulk_hooks/decorators.py,sha256=YiczUdfUBI6bk0-7ShfpuvU_n8YCDB6QD4i57NnmvNE,4886
6
6
  django_bulk_hooks/engine.py,sha256=l7BzU3lfYhZHZazks8FgHhZB4iLVKuzmcnVcyEQkGpQ,1978
7
7
  django_bulk_hooks/enums.py,sha256=Zo8_tJzuzZ2IKfVc7gZ-0tWPT8q1QhqZbAyoh9ZVJbs,381
8
8
  django_bulk_hooks/handler.py,sha256=qUulFSPhi__gWHISC4GogeVQ9aDo45bz0Dj421Y6skE,4968
9
- django_bulk_hooks/manager.py,sha256=ajsb0-HaIcb48WCHsD-Cz78umjNWQdbZarMIvBiyA_I,6691
9
+ django_bulk_hooks/manager.py,sha256=ZnVYQsb7xG0CCM-UY98jynkt6u2uWOR9sUBK05ksQUk,6504
10
10
  django_bulk_hooks/models.py,sha256=_cqIVHKhXb1EOnXxhsuJUlLnPjTRM_sCP5OKbq4q-I8,542
11
11
  django_bulk_hooks/priority.py,sha256=HG_2D35nga68lBCZmSXTcplXrjFoRgZFRDOy4ROKonY,376
12
12
  django_bulk_hooks/queryset.py,sha256=YG9wlvOdujapmxzNhOXTO74Uph0sozUsfc8e5n9KniU,1409
13
13
  django_bulk_hooks/registry.py,sha256=yeTi0IhodL61J86ohb5OyITufE28T3ecMbt6RWvkzTs,585
14
- django_bulk_hooks-0.1.61.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
15
- django_bulk_hooks-0.1.61.dist-info/METADATA,sha256=HLbhpnq0Z5CuOyHm0t7YF_s83UCUMEYd_cbKCpw0la8,3113
16
- django_bulk_hooks-0.1.61.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
- django_bulk_hooks-0.1.61.dist-info/RECORD,,
14
+ django_bulk_hooks-0.1.63.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
15
+ django_bulk_hooks-0.1.63.dist-info/METADATA,sha256=__bG-0CXog67Y94oXy-UcQX-anAJV10UQ3nDf-3lfpM,3113
16
+ django_bulk_hooks-0.1.63.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
17
+ django_bulk_hooks-0.1.63.dist-info/RECORD,,