refactor(core): Switch to inherit from Centurion model for model TicketBase

ref: #870 #863
This commit is contained in:
2025-07-15 02:11:59 +09:30
parent 1efa932fb9
commit b4f61223d6
2 changed files with 58 additions and 10 deletions

View File

@ -0,0 +1,46 @@
# Generated by Django 5.1.10 on 2025-07-14 16:20
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("core", "0035_alter_ticketcommentbase_id_and_more"),
]
operations = [
migrations.AlterField(
model_name="ticketbase",
name="external_ref",
field=models.IntegerField(
blank=True,
help_text="External System reference",
null=True,
verbose_name="Reference Number",
),
),
migrations.AlterField(
model_name="ticketbase",
name="external_system",
field=models.IntegerField(
blank=True,
choices=[
(1, "Github"),
(2, "Gitlab"),
(9999, "Custom #1 (Imported)"),
(9998, "Custom #2 (Imported)"),
(9997, "Custom #3 (Imported)"),
(9996, "Custom #4 (Imported)"),
(9995, "Custom #5 (Imported)"),
(9994, "Custom #6 (Imported)"),
(9993, "Custom #7 (Imported)"),
(9992, "Custom #8 (Imported)"),
(9991, "Custom #9 (Imported)"),
],
help_text="External system this item derives",
null=True,
verbose_name="External System",
),
),
]

View File

@ -47,6 +47,8 @@ class TicketBase(
model_notes = None
model_tag = 'ticket'
save_model_history: bool = False
class Ticket_ExternalSystem(models.IntegerChoices): # <null|github|gitlab>
@ -150,7 +152,6 @@ class TicketBase(
external_system = models.IntegerField(
blank = True,
choices = Ticket_ExternalSystem,
default = None,
help_text = 'External system this item derives',
null = True,
verbose_name = 'External System',
@ -158,7 +159,6 @@ class TicketBase(
external_ref = models.IntegerField(
blank = True,
default = None,
help_text = 'External System reference',
null = True,
verbose_name = 'Reference Number',
@ -903,12 +903,14 @@ class TicketBase(
]
changed_fields: list = []
fields = [ value.name for value in self._meta.fields ]
for field, value in self._before.items():
if (
self._before[field] != self._after[field]
and field not in excluded_fields
and field in self.fields
and field in fields
):
changed_fields = changed_fields + [ field ]
@ -1102,13 +1104,13 @@ class TicketBase(
comment_user = None
comment = TicketCommentAction.objects.create(
organization = self.organization,
ticket = self,
comment_type = TicketCommentAction._meta.sub_model_type,
body = comment_text,
# user = user
)
# comment = TicketCommentAction.objects.create(
# organization = self.organization,
# ticket = self,
# comment_type = TicketCommentAction._meta.sub_model_type,
# body = comment_text,
# # user = user
# )
# comment.save()
a = 'b'