diff --git a/boards/migrations/0036_thread_status.py b/boards/migrations/0036_thread_status.py new file mode 100644 --- /dev/null +++ b/boards/migrations/0036_thread_status.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + def bumpable_and_opening_to_status(apps, schema_editor): + Thread = apps.get_model('boards', 'Thread') + for thread in Thread.objects.all(): + if thread.archived: + thread.status = 'archived' + elif not thread.bumpable: + thread.status = 'bumplimit' + else: + thread.status = 'active' + thread.save(update_fields=['status']) + + + dependencies = [ + ('boards', '0035_auto_20151021_1346'), + ] + + operations = [ + migrations.AddField( + model_name='thread', + name='status', + field=models.CharField(default='active', max_length=50), + ), + migrations.RunPython(bumpable_and_opening_to_status), + ] diff --git a/boards/migrations/0037_auto_20151122_2155.py b/boards/migrations/0037_auto_20151122_2155.py new file mode 100644 --- /dev/null +++ b/boards/migrations/0037_auto_20151122_2155.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('boards', '0036_thread_status'), + ] + + operations = [ + migrations.RemoveField( + model_name='thread', + name='archived', + ), + migrations.RemoveField( + model_name='thread', + name='bumpable', + ), + ]