diff --git a/temba/mailroom/events.py b/temba/mailroom/events.py index 024b0473b88..27d307aa6cf 100644 --- a/temba/mailroom/events.py +++ b/temba/mailroom/events.py @@ -219,7 +219,6 @@ def from_ticket_event(cls, org: Org, user: User, obj: TicketEvent) -> dict: "closed_on": ticket.closed_on.isoformat() if ticket.closed_on else None, "topic": _topic(ticket.topic) if ticket.topic else None, "status": ticket.status, - "body": None, }, "created_on": get_event_time(obj).isoformat(), "created_by": _user(obj.created_by) if obj.created_by else None, diff --git a/temba/mailroom/tests.py b/temba/mailroom/tests.py index 8521c9d5ae5..a0e0be3f377 100644 --- a/temba/mailroom/tests.py +++ b/temba/mailroom/tests.py @@ -529,7 +529,6 @@ def test_from_ticket_event(self): "closed_on": None, "status": "O", "topic": {"uuid": str(self.org.default_ticket_topic.uuid), "name": "General"}, - "body": None, }, "created_on": matchers.ISODate(), "created_by": { @@ -559,7 +558,6 @@ def test_from_ticket_event(self): "closed_on": None, "status": "O", "topic": {"uuid": str(self.org.default_ticket_topic.uuid), "name": "General"}, - "body": None, }, "created_on": matchers.ISODate(), "created_by": None, diff --git a/temba/tickets/migrations/0062_move_body_to_open_note.py b/temba/tickets/migrations/0062_move_body_to_open_note.py index 823004e46bf..9d0ae5695a6 100644 --- a/temba/tickets/migrations/0062_move_body_to_open_note.py +++ b/temba/tickets/migrations/0062_move_body_to_open_note.py @@ -3,7 +3,7 @@ from django.db import migrations -def move_body_to_open_note(apps, schema_editor): +def move_body_to_open_note(apps, schema_editor): # pragma: no cover Ticket = apps.get_model("tickets", "Ticket") num_updated = 0 diff --git a/temba/tickets/migrations/0063_remove_ticket_body.py b/temba/tickets/migrations/0063_remove_ticket_body.py new file mode 100644 index 00000000000..e6618d81de2 --- /dev/null +++ b/temba/tickets/migrations/0063_remove_ticket_body.py @@ -0,0 +1,17 @@ +# Generated by Django 5.0.8 on 2024-08-08 19:21 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("tickets", "0062_move_body_to_open_note"), + ] + + operations = [ + migrations.RemoveField( + model_name="ticket", + name="body", + ), + ] diff --git a/temba/tickets/models.py b/temba/tickets/models.py index 50f242a5876..919bd3381e3 100644 --- a/temba/tickets/models.py +++ b/temba/tickets/models.py @@ -107,9 +107,6 @@ class Ticket(models.Model): # when this ticket last had activity which includes messages being sent and received, and is used for ordering last_activity_on = models.DateTimeField(default=timezone.now) - # deprecated - body = models.TextField(null=True) - def assign(self, user: User, *, assignee: User): self.bulk_assign(self.org, user, [self], assignee=assignee) diff --git a/temba/tickets/tests.py b/temba/tickets/tests.py index 278ffe30c8a..b023cb82c6b 100644 --- a/temba/tickets/tests.py +++ b/temba/tickets/tests.py @@ -10,7 +10,7 @@ from temba.contacts.models import Contact, ContactField, ContactURN from temba.orgs.models import Export -from temba.tests import CRUDLTestMixin, MigrationTest, TembaTest, matchers, mock_mailroom +from temba.tests import CRUDLTestMixin, TembaTest, matchers, mock_mailroom from temba.utils.dates import datetime_to_timestamp from temba.utils.uuid import uuid4 @@ -38,7 +38,6 @@ def test_model(self, mr_mocks): org=self.org, contact=contact, topic=self.org.default_ticket_topic, - body="Where are my cookies?", status="O", ) @@ -489,7 +488,6 @@ def assert_tickets(resp, tickets: list): "uuid": str(contact2.tickets.filter(status="O").first().uuid), "assignee": None, "topic": {"uuid": matchers.UUID4String(), "name": "General"}, - "body": None, "last_activity_on": matchers.ISODate(), "closed_on": None, }, @@ -510,7 +508,6 @@ def assert_tickets(resp, tickets: list): "uuid": str(joes_open_tickets[0].uuid), "assignee": None, "topic": {"uuid": matchers.UUID4String(), "name": "General"}, - "body": None, "last_activity_on": matchers.ISODate(), "closed_on": None, }, @@ -536,7 +533,6 @@ def assert_tickets(resp, tickets: list): "email": "admin@nyaruka.com", }, "topic": {"uuid": matchers.UUID4String(), "name": "General"}, - "body": None, "last_activity_on": matchers.ISODate(), "closed_on": None, }, @@ -588,7 +584,6 @@ def assert_tickets(resp, tickets: list): "uuid": str(c3_t2.uuid), "assignee": None, "topic": {"uuid": matchers.UUID4String(), "name": "General"}, - "body": None, "last_activity_on": matchers.ISODate(), "closed_on": matchers.ISODate(), }, @@ -1396,28 +1391,3 @@ def _record_last_close(self, org, d: date, seconds: int, undo: bool = False): TicketDailyTiming.objects.create( count_type=TicketDailyTiming.TYPE_LAST_CLOSE, scope=f"o:{org.id}", day=d, count=count, seconds=seconds ) - - -class MoveBodyToOpenNoteTest(MigrationTest): - app = "tickets" - migrate_from = "0061_alter_ticket_body_alter_ticketevent_note" - migrate_to = "0062_move_body_to_open_note" - - def setUpBeforeMigration(self, apps): - contact = self.create_contact("Bob", urns=["twitter:bobby"]) - - self.ticket1 = self.create_ticket(contact) - self.ticket2 = self.create_ticket(contact) - self.ticket2.body = "I was a body" - self.ticket2.save(update_fields=("body",)) - - def test_migration(self): - self.ticket1.refresh_from_db() - self.ticket2.refresh_from_db() - - # body unchanged - self.assertIsNone(self.ticket1.body) - self.assertEqual("I was a body", self.ticket2.body) - - self.assertEqual(None, self.ticket1.events.get(event_type="O").note) - self.assertEqual("I was a body", self.ticket2.events.get(event_type="O").note) diff --git a/temba/tickets/views.py b/temba/tickets/views.py index 5deade0f4a4..3186e79936d 100644 --- a/temba/tickets/views.py +++ b/temba/tickets/views.py @@ -422,7 +422,6 @@ def as_json(t): "uuid": str(t.uuid), "assignee": user_as_json(t.assignee) if t.assignee else None, "topic": topic_as_json(t.topic) if t.topic else None, - "body": t.body, "last_activity_on": t.last_activity_on, "closed_on": t.closed_on, },