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_pgjson.fields import JsonField
|
||||
|
||||
from taiga.mdrender.service import get_diff_of_htmls
|
||||
|
||||
from .choices import HistoryType
|
||||
from .choices import HISTORY_TYPE_CHOICES
|
||||
|
||||
|
@ -82,7 +84,20 @@ class HistoryEntry(models.Model):
|
|||
for key in self.diff:
|
||||
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]]
|
||||
elif key == "watchers":
|
||||
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 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 .models import HistoryType
|
||||
|
@ -161,14 +160,6 @@ def make_diff(oldobj:FrozenObj, newobj:FrozenObj) -> FrozenDiff:
|
|||
if key not in first:
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ class WatchedResourceMixin(object):
|
|||
cases on actions methods that not uses standard
|
||||
`post_save` hook of drf resources.
|
||||
"""
|
||||
|
||||
if history is None:
|
||||
history = self.get_last_history()
|
||||
|
||||
|
|
Loading…
Reference in New Issue