add migrations for state change
This commit is contained in:
parent
626c9f23fe
commit
fe9795d147
3 changed files with 59 additions and 20 deletions
39
core/tickets/migrations/0003_alter_issuethread_state.py
Normal file
39
core/tickets/migrations/0003_alter_issuethread_state.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Generated by Django 4.2.7 on 2023-12-28 20:15
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('tickets', '0002_alter_issuethread_options_and_more'),
|
||||
]
|
||||
|
||||
def convert_state(apps, schema_editor):
|
||||
IssueThread = apps.get_model('tickets', 'IssueThread')
|
||||
for issue in IssueThread.objects.all():
|
||||
if issue.state == 'new':
|
||||
issue.state = 'pending_new'
|
||||
issue.save()
|
||||
StateChange = apps.get_model('tickets', 'StateChange')
|
||||
for change in StateChange.objects.all():
|
||||
if change.state == 'new':
|
||||
change.state = 'pending_new'
|
||||
change.save()
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='issuethread',
|
||||
name='state',
|
||||
field=models.CharField(
|
||||
choices=[('pending_new', 'New'), ('pending_open', 'Open'), ('pending_shipping', 'Needs to be shipped'),
|
||||
('pending_physical_confirmation', 'Needs to be confirmed physically'),
|
||||
('pending_return', 'Needs to be returned'), ('waiting_details', 'Waiting for details'),
|
||||
('waiting_pre_shipping', 'Waiting for Address/Shipping Info'),
|
||||
('closed_returned', 'Closed: Returned'), ('closed_shipped', 'Closed: Shipped'),
|
||||
('closed_not_found', 'Closed: Not found'),
|
||||
('closed_not_our_problem', 'Closed: Not our problem'),
|
||||
('closed_duplicate', 'Closed: Duplicate'), ('closed_timeout', 'Closed: Timeout'),
|
||||
('closed_spam', 'Closed: Spam')], default='pending_new', max_length=32, verbose_name='state'),
|
||||
),
|
||||
migrations.RunPython(convert_state),
|
||||
]
|
|
@ -39,7 +39,7 @@ class IssueApiTest(TestCase):
|
|||
)
|
||||
state = StateChange.objects.create(
|
||||
issue_thread=issue,
|
||||
state="new",
|
||||
state="pending_new",
|
||||
timestamp=now + timedelta(seconds=1),
|
||||
)
|
||||
mail2 = Email.objects.create(
|
||||
|
@ -62,7 +62,7 @@ class IssueApiTest(TestCase):
|
|||
self.assertEqual(len(response.json()), 1)
|
||||
self.assertEqual(response.json()[0]['id'], issue.id)
|
||||
self.assertEqual(response.json()[0]['name'], "test issue")
|
||||
self.assertEqual(response.json()[0]['state'], "new")
|
||||
self.assertEqual(response.json()[0]['state'], "pending_new")
|
||||
self.assertEqual(response.json()[0]['assigned_to'], None)
|
||||
self.assertEqual(response.json()[0]['last_activity'], issue.last_activity.strftime('%Y-%m-%dT%H:%M:%S.%fZ'))
|
||||
self.assertEqual(len(response.json()[0]['timeline']), 4)
|
||||
|
@ -80,7 +80,7 @@ class IssueApiTest(TestCase):
|
|||
self.assertEqual(response.json()[0]['timeline'][0]['body'], 'test')
|
||||
self.assertEqual(response.json()[0]['timeline'][0]['timestamp'],
|
||||
mail1.timestamp.strftime('%Y-%m-%dT%H:%M:%S.%fZ'))
|
||||
self.assertEqual(response.json()[0]['timeline'][1]['state'], 'new')
|
||||
self.assertEqual(response.json()[0]['timeline'][1]['state'], 'pending_new')
|
||||
self.assertEqual(response.json()[0]['timeline'][1]['timestamp'],
|
||||
state.timestamp.strftime('%Y-%m-%dT%H:%M:%S.%fZ'))
|
||||
self.assertEqual(response.json()[0]['timeline'][2]['sender'], 'test')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue