Fix bug #868: Delete empty description_diff
parent
99756050db
commit
ac12c878ed
|
@ -21,6 +21,8 @@ from django.db.models.loading import get_model
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django_pgjson.fields import JsonField
|
from django_pgjson.fields import JsonField
|
||||||
|
|
||||||
|
from taiga.mdrender.service import get_diff_of_htmls
|
||||||
|
|
||||||
from .choices import HistoryType
|
from .choices import HistoryType
|
||||||
from .choices import HISTORY_TYPE_CHOICES
|
from .choices import HISTORY_TYPE_CHOICES
|
||||||
|
|
||||||
|
@ -82,7 +84,20 @@ class HistoryEntry(models.Model):
|
||||||
for key in self.diff:
|
for key in self.diff:
|
||||||
value = None
|
value = None
|
||||||
|
|
||||||
if key in users_keys:
|
# Note: Hack to prevent description_diff propagation
|
||||||
|
# on old HistoryEntry objects.
|
||||||
|
if key == "description_diff":
|
||||||
|
continue
|
||||||
|
elif key == "description":
|
||||||
|
description_diff = get_diff_of_htmls(
|
||||||
|
self.diff[key][0],
|
||||||
|
self.diff[key][1]
|
||||||
|
)
|
||||||
|
|
||||||
|
if description_diff:
|
||||||
|
key = "description_diff"
|
||||||
|
value = (None, description_diff)
|
||||||
|
elif key in users_keys:
|
||||||
value = [resolve_value("users", x) for x in self.diff[key]]
|
value = [resolve_value("users", x) for x in self.diff[key]]
|
||||||
elif key == "watchers":
|
elif key == "watchers":
|
||||||
value = [[resolve_value("users", x) for x in self.diff[key][0]],
|
value = [[resolve_value("users", x) for x in self.diff[key][0]],
|
||||||
|
|
|
@ -39,7 +39,6 @@ from django.db.models.loading import get_model
|
||||||
from django.db import transaction as tx
|
from django.db import transaction as tx
|
||||||
|
|
||||||
from taiga.mdrender.service import render as mdrender
|
from taiga.mdrender.service import render as mdrender
|
||||||
from taiga.mdrender.service import get_diff_of_htmls
|
|
||||||
from taiga.base.utils.db import get_typename_for_model_class
|
from taiga.base.utils.db import get_typename_for_model_class
|
||||||
|
|
||||||
from .models import HistoryType
|
from .models import HistoryType
|
||||||
|
@ -161,14 +160,6 @@ def make_diff(oldobj:FrozenObj, newobj:FrozenObj) -> FrozenDiff:
|
||||||
if key not in first:
|
if key not in first:
|
||||||
diff[key] = (not_found_value, second[key])
|
diff[key] = (not_found_value, second[key])
|
||||||
|
|
||||||
if "description" in diff:
|
|
||||||
description_diff = get_diff_of_htmls(
|
|
||||||
diff["description"][0],
|
|
||||||
diff["description"][1]
|
|
||||||
)
|
|
||||||
if description_diff:
|
|
||||||
diff["description_diff"] = (not_found_value, description_diff)
|
|
||||||
|
|
||||||
return FrozenDiff(newobj.key, diff, newobj.snapshot)
|
return FrozenDiff(newobj.key, diff, newobj.snapshot)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ class WatchedResourceMixin(object):
|
||||||
cases on actions methods that not uses standard
|
cases on actions methods that not uses standard
|
||||||
`post_save` hook of drf resources.
|
`post_save` hook of drf resources.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if history is None:
|
if history is None:
|
||||||
history = self.get_last_history()
|
history = self.get_last_history()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue