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),
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue