feat(core): When changing ticket description create an action comment with the details

ref: #502
This commit is contained in:
2025-01-28 05:47:07 +09:30
parent 624f892a73
commit d7a8840444

View File

@ -1,3 +1,5 @@
import difflib
from django.contrib.auth.models import User
from django.db import models
from django.db.models import Q, signals, Sum
@ -953,6 +955,24 @@ class Ticket(
comment_field_value = f"changed Real Finish Date from _{before[field]}_ to **{to_value}**"
if field == 'description':
comment_field_value = ''.join(
str(x) for x in list(
difflib.unified_diff(
str(before[field] + '\n').splitlines(keepends=True),
str(after[field] + '\n').splitlines(keepends=True),
fromfile = 'before',
tofile = 'after',
n = 10000,
lineterm = '\n'
)
)
) + ''
comment_field_value = '<details><summary>Changed the Description</summary>\n\n``` diff \n\n' + comment_field_value + '\n\n```\n\n</details>'
if comment_field_value:
if request: