File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
codeforlife/models/signals Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ def check_previous_values(
20
20
):
21
21
# pylint: disable=line-too-long
22
22
"""Check if the previous values are as expected. If the previous value's key
23
- is not on the model, this check returns false .
23
+ is not on the model, this check returns False .
24
24
25
25
Args:
26
26
instance: The current instance.
@@ -42,6 +42,31 @@ def check_previous_values(
42
42
return True
43
43
44
44
45
+ def previous_values_are_unequal (instance : _ .AnyModel , fields : t .Set [str ]):
46
+ # pylint: disable=line-too-long
47
+ """Check if all the previous values are not equal to the current values. If
48
+ the previous value's key is not on the model, this check returns False.
49
+
50
+ Args:
51
+ instance: The current instance.
52
+ fields: The fields that should not be equal.
53
+
54
+ Returns:
55
+ If all the previous values are not equal to the current values.
56
+ """
57
+ # pylint: enable=line-too-long
58
+
59
+ for field in fields :
60
+ previous_value_key = PREVIOUS_VALUE_KEY .format (field = field )
61
+
62
+ if not hasattr (instance , previous_value_key ) or (
63
+ getattr (instance , field ) == getattr (instance , previous_value_key )
64
+ ):
65
+ return False
66
+
67
+ return True
68
+
69
+
45
70
def get_previous_value (
46
71
instance : _ .AnyModel , field : str , cls : t .Type [FieldValue ]
47
72
):
You can’t perform that action at this time.
0 commit comments