Show More
@@ -0,0 +1,32 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | from __future__ import unicode_literals | |||
|
3 | ||||
|
4 | from django.db import migrations, models | |||
|
5 | ||||
|
6 | ||||
|
7 | class Migration(migrations.Migration): | |||
|
8 | ||||
|
9 | def bumpable_and_opening_to_status(apps, schema_editor): | |||
|
10 | Thread = apps.get_model('boards', 'Thread') | |||
|
11 | for thread in Thread.objects.all(): | |||
|
12 | if thread.archived: | |||
|
13 | thread.status = 'archived' | |||
|
14 | elif not thread.bumpable: | |||
|
15 | thread.status = 'bumplimit' | |||
|
16 | else: | |||
|
17 | thread.status = 'active' | |||
|
18 | thread.save(update_fields=['status']) | |||
|
19 | ||||
|
20 | ||||
|
21 | dependencies = [ | |||
|
22 | ('boards', '0035_auto_20151021_1346'), | |||
|
23 | ] | |||
|
24 | ||||
|
25 | operations = [ | |||
|
26 | migrations.AddField( | |||
|
27 | model_name='thread', | |||
|
28 | name='status', | |||
|
29 | field=models.CharField(default='active', max_length=50), | |||
|
30 | ), | |||
|
31 | migrations.RunPython(bumpable_and_opening_to_status), | |||
|
32 | ] |
@@ -0,0 +1,22 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | from __future__ import unicode_literals | |||
|
3 | ||||
|
4 | from django.db import migrations, models | |||
|
5 | ||||
|
6 | ||||
|
7 | class Migration(migrations.Migration): | |||
|
8 | ||||
|
9 | dependencies = [ | |||
|
10 | ('boards', '0036_thread_status'), | |||
|
11 | ] | |||
|
12 | ||||
|
13 | operations = [ | |||
|
14 | migrations.RemoveField( | |||
|
15 | model_name='thread', | |||
|
16 | name='archived', | |||
|
17 | ), | |||
|
18 | migrations.RemoveField( | |||
|
19 | model_name='thread', | |||
|
20 | name='bumpable', | |||
|
21 | ), | |||
|
22 | ] |
General Comments 0
You need to be logged in to leave comments.
Login now