#37122: JSONField has_changed doesn't reflect disabled correctly
-------------------------------+--------------------------------------
     Reporter:  alex           |                    Owner:  (none)
         Type:  Uncategorized  |                   Status:  new
    Component:  Uncategorized  |                  Version:  6.0
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  1              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  1              |                    UI/UX:  0
-------------------------------+--------------------------------------
Description changed by alex:

Old description:

> Problem:
>
> A disabled JSONField still reports changes via has_changed.
>
> Why?
>
> ``` python
> def has_changed(self, initial, data):
>     # here we miss the check for disabled
>     if super().has_changed(initial, data):
>         return True
>     ...
>
> ```
> As we see, has_changed from the base is called and if successful, True is
> returned. But we have no additional check for disabled.
>
> Fix:
>
> ``` python
> def has_changed(self, initial, data):
>     if self.disabled:
>         return False
>     if super().has_changed(initial, data):
>         return True
>     ...
>
> ```
>
> This corrupts the changed fields in the history of admin.

New description:

 Problem:

 A disabled JSONField still reports changes via has_changed.

 Why?


 {{{

 def has_changed(self, initial, data):
     # here we miss the check for disabled
     if super().has_changed(initial, data):
         return True
     ...

 }}}

 As we see, has_changed from the base is called and if successful, True is
 returned. But we have no additional check for disabled.

 Fix:


 {{{

 def has_changed(self, initial, data):
     if self.disabled:
         return False
     if super().has_changed(initial, data):
         return True
     ...
 }}}


 This corrupts the changed fields in the history of admin.

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/37122#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019e6d937fb3-ba59235b-67f8-4f86-8d48-3729b0d0c072-000000%40eu-central-1.amazonses.com.

Reply via email to