# -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import DataMigration from django.db import models import boards class Migration(DataMigration): def forwards(self, orm): changed_count = 0 for thread in orm['boards.Thread'].objects.all(): if thread.replies.count() >= boards.settings.MAX_POSTS_PER_THREAD: thread.bumpable = False print('Disabled bump on thread {}'.format(thread.id)) changed_count += 1 else: thread.bumpable = True thread.save(update_fields=['bumpable']) print('Changed {} threads.'.format(changed_count)) def backwards(self, orm): "Write your backwards methods here." models = { 'boards.ban': { 'Meta': {'object_name': 'Ban'}, 'can_read': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}), 'reason': ('django.db.models.fields.CharField', [], {'default': "'Auto'", 'max_length': '200'}) }, 'boards.post': { 'Meta': {'object_name': 'Post', 'ordering': "('id',)"}, '_text_rendered': ('django.db.models.fields.TextField', [], {}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'images': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'ip+'", 'null': 'True', 'to': "orm['boards.PostImage']", 'db_index': 'True', 'blank': 'True'}), 'last_edit_time': ('django.db.models.fields.DateTimeField', [], {}), 'poster_ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}), 'poster_user_agent': ('django.db.models.fields.TextField', [], {}), 'pub_time': ('django.db.models.fields.DateTimeField', [], {}), 'referenced_posts': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'rfp+'", 'null': 'True', 'to': "orm['boards.Post']", 'db_index': 'True', 'blank': 'True'}), 'refmap': ('django.db.models.fields.TextField', [], {'blank': 'True', 'null': 'True'}), 'text': ('markupfield.fields.MarkupField', [], {'rendered_field': 'True'}), 'text_markup_type': ('django.db.models.fields.CharField', [], {'default': "'bbcode'", 'max_length': '30'}), 'thread_new': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['boards.Thread']", 'null': 'True'}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '200'}) }, 'boards.postimage': { 'Meta': {'object_name': 'PostImage', 'ordering': "('id',)"}, 'hash': ('django.db.models.fields.CharField', [], {'max_length': '36'}), 'height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'image': ('boards.thumbs.ImageWithThumbsField', [], {'blank': 'True', 'max_length': '100'}), 'pre_height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'pre_width': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'width': ('django.db.models.fields.IntegerField', [], {'default': '0'}) }, 'boards.tag': { 'Meta': {'object_name': 'Tag', 'ordering': "('name',)"}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '100'}), 'threads': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'null': 'True', 'to': "orm['boards.Thread']", 'related_name': "'tag+'", 'blank': 'True'}) }, 'boards.thread': { 'Meta': {'object_name': 'Thread'}, 'archived': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'bump_time': ('django.db.models.fields.DateTimeField', [], {}), 'bumpable': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'last_edit_time': ('django.db.models.fields.DateTimeField', [], {}), 'replies': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'null': 'True', 'to': "orm['boards.Post']", 'related_name': "'tre+'", 'blank': 'True'}), 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['boards.Tag']"}) } } complete_apps = ['boards'] symmetrical = True