Ejemplo n.º 1
0
class Migration(migrations.Migration):
    dependencies = [
        ('misago_categories', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Post',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('poster_name', models.CharField(max_length=255)),
                ('poster_ip', models.GenericIPAddressField()),
                ('original', models.TextField()),
                ('parsed', models.TextField()),
                ('checksum', models.CharField(max_length=64, default='-')),
                ('has_attachments', models.BooleanField(default=False)),
                ('attachments_cache', JSONField(null=True, blank=True)),
                ('posted_on', models.DateTimeField()),
                ('updated_on', models.DateTimeField()),
                ('edits', models.PositiveIntegerField(default=0)),
                ('last_editor_name',
                 models.CharField(max_length=255, null=True, blank=True)),
                ('last_editor_slug',
                 models.SlugField(max_length=255, null=True, blank=True)),
                ('hidden_by',
                 models.ForeignKey(
                     related_name='+',
                     on_delete=django.db.models.deletion.SET_NULL,
                     blank=True,
                     to=settings.AUTH_USER_MODEL,
                     null=True)),
                ('hidden_by_name',
                 models.CharField(max_length=255, null=True, blank=True)),
                ('hidden_by_slug',
                 models.SlugField(max_length=255, null=True, blank=True)),
                ('hidden_on',
                 models.DateTimeField(default=django.utils.timezone.now)),
                ('has_reports', models.BooleanField(default=False)),
                ('has_open_reports', models.BooleanField(default=False)),
                ('is_unapproved',
                 models.BooleanField(default=False, db_index=True)),
                ('is_hidden', models.BooleanField(default=False)),
                ('is_protected', models.BooleanField(default=False)),
                ('category',
                 models.ForeignKey(to='misago_categories.Category')),
                ('last_editor',
                 models.ForeignKey(
                     related_name='+',
                     on_delete=django.db.models.deletion.SET_NULL,
                     blank=True,
                     to=settings.AUTH_USER_MODEL,
                     null=True)),
                ('mentions',
                 models.ManyToManyField(related_name='mention_set',
                                        to=settings.AUTH_USER_MODEL)),
                ('poster',
                 models.ForeignKey(
                     on_delete=django.db.models.deletion.SET_NULL,
                     blank=True,
                     to=settings.AUTH_USER_MODEL,
                     null=True)),
                ('is_event', models.BooleanField(default=False,
                                                 db_index=True)),
                ('event_type',
                 models.CharField(max_length=255, null=True, blank=True)),
                ('event_context', JSONField(null=True, blank=True)),
            ],
            options={},
            bases=(models.Model, ),
        ),
        CreatePartialIndex(
            field='Post.has_open_reports',
            index_name='misago_post_has_open_reports_partial',
            condition='has_open_reports = TRUE',
        ),
        CreatePartialIndex(
            field='Post.is_hidden',
            index_name='misago_post_is_hidden_partial',
            condition='is_hidden = FALSE',
        ),
        migrations.CreateModel(
            name='Thread',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('title', models.CharField(max_length=255)),
                ('slug', models.CharField(max_length=255)),
                ('replies',
                 models.PositiveIntegerField(default=0, db_index=True)),
                ('has_reported_posts', models.BooleanField(default=False)),
                ('has_open_reports', models.BooleanField(default=False)),
                ('has_unapproved_posts', models.BooleanField(default=False)),
                ('has_hidden_posts', models.BooleanField(default=False)),
                ('started_on', models.DateTimeField(db_index=True)),
                ('starter_name', models.CharField(max_length=255)),
                ('starter_slug', models.CharField(max_length=255)),
                ('last_post_on', models.DateTimeField(db_index=True)),
                ('last_poster_name',
                 models.CharField(max_length=255, null=True, blank=True)),
                ('last_poster_slug',
                 models.CharField(max_length=255, null=True, blank=True)),
                ('weight', models.PositiveIntegerField(default=0)),
                ('is_poll', models.BooleanField(default=False)),
                ('is_unapproved',
                 models.BooleanField(default=False, db_index=True)),
                ('is_hidden', models.BooleanField(default=False)),
                ('is_closed', models.BooleanField(default=False)),
            ],
            options={},
            bases=(models.Model, ),
        ),
        CreatePartialIndex(
            field='Thread.weight',
            index_name='misago_thread_is_global',
            condition='weight = 2',
        ),
        CreatePartialIndex(
            field='Thread.weight',
            index_name='misago_thread_is_local',
            condition='weight < 2',
        ),
        migrations.CreateModel(
            name='ThreadParticipant',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('thread', models.ForeignKey(to='misago_threads.Thread')),
                ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
                ('is_owner', models.BooleanField(default=False)),
            ],
            options={},
            bases=(models.Model, ),
        ),
        migrations.AddField(
            model_name='thread',
            name='participants',
            field=models.ManyToManyField(
                related_name='private_thread_set',
                through='misago_threads.ThreadParticipant',
                through_fields=('thread', 'user'),
                to=settings.AUTH_USER_MODEL),
            preserve_default=True,
        ),
        CreatePartialIndex(
            field='Thread.has_reported_posts',
            index_name='misago_thread_has_reported_posts_partial',
            condition='has_reported_posts = TRUE',
        ),
        CreatePartialIndex(
            field='Thread.has_unapproved_posts',
            index_name='misago_thread_has_unapproved_posts_partial',
            condition='has_unapproved_posts = TRUE',
        ),
        CreatePartialIndex(
            field='Thread.is_hidden',
            index_name='misago_thread_is_hidden_partial',
            condition='is_hidden = FALSE',
        ),
        CreatePartialIndex(
            field='Thread.weight',
            index_name='misago_thread_is_pinned_globally_partial',
            condition='weight = 2',
        ),
        CreatePartialIndex(
            field='Thread.weight',
            index_name='misago_thread_is_pinned_locally_partial',
            condition='weight = 1',
        ),
        CreatePartialIndex(
            field='Thread.weight',
            index_name='misago_thread_is_unpinned_partial',
            condition='weight = 0',
        ),
        migrations.AddField(
            model_name='post',
            name='thread',
            field=models.ForeignKey(to='misago_threads.Thread'),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='first_post',
            field=models.ForeignKey(
                related_name='+',
                on_delete=django.db.models.deletion.SET_NULL,
                blank=True,
                to='misago_threads.Post',
                null=True),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='category',
            field=models.ForeignKey(to='misago_categories.Category'),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='last_post',
            field=models.ForeignKey(
                related_name='+',
                on_delete=django.db.models.deletion.SET_NULL,
                blank=True,
                to='misago_threads.Post',
                null=True),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='last_poster',
            field=models.ForeignKey(
                related_name='last_poster_set',
                on_delete=django.db.models.deletion.SET_NULL,
                blank=True,
                to=settings.AUTH_USER_MODEL,
                null=True),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='starter',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.SET_NULL,
                blank=True,
                to=settings.AUTH_USER_MODEL,
                null=True),
            preserve_default=True,
        ),
        migrations.AlterIndexTogether(
            name='thread',
            index_together=set([
                ('category', 'id'),
                ('category', 'last_post_on'),
                ('category', 'replies'),
            ]),
        ),
        migrations.AlterIndexTogether(
            name='post',
            index_together=set([
                ('is_event', 'is_hidden'),
                ('poster', 'posted_on'),
            ]),
        ),
        migrations.CreateModel(
            name='Subscription',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('last_read_on',
                 models.DateTimeField(default=django.utils.timezone.now)),
                ('send_email', models.BooleanField(default=False)),
                ('category',
                 models.ForeignKey(to='misago_categories.Category')),
                ('thread', models.ForeignKey(to='misago_threads.Thread')),
                ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
            ],
            options={},
            bases=(models.Model, ),
        ),
        migrations.AlterIndexTogether(
            name='subscription',
            index_together=set([
                ('send_email', 'last_read_on'),
            ]),
        ),
    ]
Ejemplo n.º 2
0
class Migration(migrations.Migration):
    dependencies = [
        ('misago_categories', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Post',
            fields=[
                (
                    'id', models.AutoField(
                        verbose_name='ID', serialize=False, auto_created=True, primary_key=True
                    )
                ),
                ('poster_name', models.CharField(max_length=255)),
                ('poster_ip', models.GenericIPAddressField()),
                ('original', models.TextField()),
                ('parsed', models.TextField()),
                ('checksum', models.CharField(max_length=64, default='-')),
                ('attachments_cache', JSONField(null=True, blank=True)),
                ('posted_on', models.DateTimeField()),
                ('updated_on', models.DateTimeField()),
                ('edits', models.PositiveIntegerField(default=0)),
                ('last_editor_name', models.CharField(max_length=255, null=True, blank=True)),
                ('last_editor_slug', models.SlugField(max_length=255, null=True, blank=True)),
                (
                    'hidden_by', models.ForeignKey(
                        related_name='+',
                        on_delete=django.db.models.deletion.SET_NULL,
                        blank=True,
                        to=settings.AUTH_USER_MODEL,
                        null=True
                    )
                ),
                ('hidden_by_name', models.CharField(max_length=255, null=True, blank=True)),
                ('hidden_by_slug', models.SlugField(max_length=255, null=True, blank=True)),
                ('hidden_on', models.DateTimeField(default=django.utils.timezone.now)),
                ('has_reports', models.BooleanField(default=False)),
                ('has_open_reports', models.BooleanField(default=False)),
                ('is_unapproved', models.BooleanField(default=False, db_index=True)),
                ('is_hidden', models.BooleanField(default=False)),
                ('is_protected', models.BooleanField(default=False)),
                ('category', models.ForeignKey(to='misago_categories.Category')),
                (
                    'last_editor', models.ForeignKey(
                        related_name='+',
                        on_delete=django.db.models.deletion.SET_NULL,
                        blank=True,
                        to=settings.AUTH_USER_MODEL,
                        null=True
                    )
                ),
                (
                    'mentions', models.ManyToManyField(
                        related_name='mention_set', to=settings.AUTH_USER_MODEL
                    )
                ),
                (
                    'poster', models.ForeignKey(
                        on_delete=django.db.models.deletion.SET_NULL,
                        blank=True,
                        to=settings.AUTH_USER_MODEL,
                        null=True
                    )
                ),
                ('is_event', models.BooleanField(default=False, db_index=True)),
                ('event_type', models.CharField(max_length=255, null=True, blank=True)),
                ('event_context', JSONField(null=True, blank=True)),
                ('likes', models.PositiveIntegerField(default=0)),
                ('last_likes', JSONField(blank=True, null=True)),
                ('search_document', models.TextField(blank=True, null=True)),
                ('search_vector', SearchVectorField()),
            ],
            options={},
            bases=(models.Model, ),
        ),
        CreatePartialIndex(
            field='Post.has_open_reports',
            index_name='misago_post_has_open_reports_partial',
            condition='has_open_reports = TRUE',
        ),
        CreatePartialIndex(
            field='Post.is_hidden',
            index_name='misago_post_is_hidden_partial',
            condition='is_hidden = FALSE',
        ),
        migrations.CreateModel(
            name='Thread',
            fields=[
                (
                    'id', models.AutoField(
                        verbose_name='ID', serialize=False, auto_created=True, primary_key=True
                    )
                ),
                ('title', models.CharField(max_length=255)),
                ('slug', models.CharField(max_length=255)),
                ('replies', models.PositiveIntegerField(default=0, db_index=True)),
                ('has_events', models.BooleanField(default=False)),
                ('has_poll', models.BooleanField(default=False)),
                ('has_reported_posts', models.BooleanField(default=False)),
                ('has_open_reports', models.BooleanField(default=False)),
                ('has_unapproved_posts', models.BooleanField(default=False)),
                ('has_hidden_posts', models.BooleanField(default=False)),
                ('started_on', models.DateTimeField(db_index=True)),
                ('starter_name', models.CharField(max_length=255)),
                ('starter_slug', models.CharField(max_length=255)),
                ('last_post_is_event', models.BooleanField(default=False)),
                ('last_post_on', models.DateTimeField(db_index=True)),
                ('last_poster_name', models.CharField(max_length=255, null=True, blank=True)),
                ('last_poster_slug', models.CharField(max_length=255, null=True, blank=True)),
                ('weight', models.PositiveIntegerField(default=0)),
                ('is_unapproved', models.BooleanField(default=False, db_index=True)),
                ('is_hidden', models.BooleanField(default=False)),
                ('is_closed', models.BooleanField(default=False)),
            ],
            options={},
            bases=(models.Model, ),
        ),
        CreatePartialIndex(
            field='Thread.weight',
            index_name='misago_thread_is_global',
            condition='weight = 2',
        ),
        CreatePartialIndex(
            field='Thread.weight',
            index_name='misago_thread_is_local',
            condition='weight < 2',
        ),
        migrations.CreateModel(
            name='ThreadParticipant',
            fields=[
                (
                    'id', models.AutoField(
                        verbose_name='ID', serialize=False, auto_created=True, primary_key=True
                    )
                ),
                ('thread', models.ForeignKey(to='misago_threads.Thread')),
                ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
                ('is_owner', models.BooleanField(default=False)),
            ],
            options={},
            bases=(models.Model, ),
        ),
        migrations.AddField(
            model_name='thread',
            name='participants',
            field=models.ManyToManyField(
                related_name='privatethread_set',
                through='misago_threads.ThreadParticipant',
                to=settings.AUTH_USER_MODEL
            ),
            preserve_default=True,
        ),
        CreatePartialIndex(
            field='Thread.has_reported_posts',
            index_name='misago_thread_has_reported_posts_partial',
            condition='has_reported_posts = TRUE',
        ),
        CreatePartialIndex(
            field='Thread.has_unapproved_posts',
            index_name='misago_thread_has_unapproved_posts_partial',
            condition='has_unapproved_posts = TRUE',
        ),
        CreatePartialIndex(
            field='Thread.is_hidden',
            index_name='misago_thread_is_hidden_partial',
            condition='is_hidden = FALSE',
        ),
        CreatePartialIndex(
            field='Thread.weight',
            index_name='misago_thread_is_pinned_globally_partial',
            condition='weight = 2',
        ),
        CreatePartialIndex(
            field='Thread.weight',
            index_name='misago_thread_is_pinned_locally_partial',
            condition='weight = 1',
        ),
        CreatePartialIndex(
            field='Thread.weight',
            index_name='misago_thread_is_unpinned_partial',
            condition='weight = 0',
        ),
        migrations.AddField(
            model_name='post',
            name='thread',
            field=models.ForeignKey(to='misago_threads.Thread'),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='first_post',
            field=models.ForeignKey(
                related_name='+',
                on_delete=django.db.models.deletion.SET_NULL,
                blank=True,
                to='misago_threads.Post',
                null=True
            ),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='category',
            field=models.ForeignKey(to='misago_categories.Category'),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='last_post',
            field=models.ForeignKey(
                related_name='+',
                on_delete=django.db.models.deletion.SET_NULL,
                blank=True,
                to='misago_threads.Post',
                null=True
            ),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='last_poster',
            field=models.ForeignKey(
                related_name='last_poster_set',
                on_delete=django.db.models.deletion.SET_NULL,
                blank=True,
                to=settings.AUTH_USER_MODEL,
                null=True
            ),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='starter',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.SET_NULL,
                blank=True,
                to=settings.AUTH_USER_MODEL,
                null=True
            ),
            preserve_default=True,
        ),
        migrations.AlterIndexTogether(
            name='thread',
            index_together=set([
                ('category', 'id'),
                ('category', 'last_post_on'),
                ('category', 'replies'),
            ]),
        ),
        migrations.AlterIndexTogether(
            name='post',
            index_together=set([
                ('thread', 'id'),
                ('is_event', 'is_hidden'),
                ('poster', 'posted_on'),
            ]),
        ),
        migrations.CreateModel(
            name='Subscription',
            fields=[
                (
                    'id', models.AutoField(
                        verbose_name='ID', serialize=False, auto_created=True, primary_key=True
                    )
                ),
                ('last_read_on', models.DateTimeField(default=django.utils.timezone.now)),
                ('send_email', models.BooleanField(default=False)),
                ('category', models.ForeignKey(to='misago_categories.Category')),
                ('thread', models.ForeignKey(to='misago_threads.Thread')),
                ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
            ],
            options={},
            bases=(models.Model, ),
        ),
        migrations.AlterIndexTogether(
            name='subscription',
            index_together=set([
                ('send_email', 'last_read_on'),
            ]),
        ),
        migrations.CreateModel(
            name='PostEdit',
            fields=[
                (
                    'id', models.AutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name='ID'
                    )
                ),
                ('edited_on', models.DateTimeField(default=django.utils.timezone.now)),
                ('editor_name', models.CharField(max_length=255)),
                ('editor_slug', models.CharField(max_length=255)),
                ('editor_ip', models.GenericIPAddressField()),
                ('edited_from', models.TextField()),
                ('edited_to', models.TextField()),
                (
                    'category', models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='misago_categories.Category'
                    )
                ),
                (
                    'editor', models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL
                    )
                ),
                (
                    'post', models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='edits_record',
                        to='misago_threads.Post'
                    )
                ),
                (
                    'thread', models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to='misago_threads.Thread'
                    )
                ),
            ],
            options={
                'ordering': ['-id'],
            },
        ),
        migrations.CreateModel(
            name='Attachment',
            fields=[
                (
                    'id', models.AutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name='ID'
                    )
                ),
                ('secret', models.CharField(max_length=64)),
                (
                    'uploaded_on',
                    models.DateTimeField(default=django.utils.timezone.now, db_index=True)
                ),
                ('uploader_name', models.CharField(max_length=255)),
                ('uploader_slug', models.CharField(max_length=255, db_index=True)),
                ('uploader_ip', models.GenericIPAddressField()),
                ('filename', models.CharField(max_length=255, db_index=True)),
                ('size', models.PositiveIntegerField(default=0, db_index=True)),
                (
                    'thumbnail', models.ImageField(
                        max_length=255,
                        blank=True,
                        null=True,
                        upload_to=misago.threads.models.attachment.upload_to
                    )
                ),
                (
                    'image', models.ImageField(
                        max_length=255,
                        blank=True,
                        null=True,
                        upload_to=misago.threads.models.attachment.upload_to
                    )
                ),
                (
                    'file', models.FileField(
                        max_length=255,
                        blank=True,
                        null=True,
                        upload_to=misago.threads.models.attachment.upload_to
                    )
                ),
                (
                    'post', models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to='misago_threads.Post'
                    )
                ),
            ],
        ),
        migrations.CreateModel(
            name='AttachmentType',
            fields=[
                (
                    'id', models.AutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name='ID'
                    )
                ),
                ('name', models.CharField(max_length=255)),
                ('extensions', models.CharField(max_length=255)),
                ('mimetypes', models.CharField(blank=True, max_length=255, null=True)),
                ('size_limit', models.PositiveIntegerField(default=1024)),
                (
                    'status', models.PositiveIntegerField(
                        choices=[(0, 'Allow uploads and downloads'), (1, 'Allow downloads only'),
                                 (2, 'Disallow both uploading and downloading')],
                        default=0
                    )
                ),
                (
                    'limit_downloads_to', models.ManyToManyField(
                        blank=True,
                        related_name='_attachmenttype_limit_downloads_to_+',
                        to='misago_acl.Role'
                    )
                ),
                (
                    'limit_uploads_to', models.ManyToManyField(
                        blank=True,
                        related_name='_attachmenttype_limit_uploads_to_+',
                        to='misago_acl.Role'
                    )
                ),
            ],
        ),
        migrations.AddField(
            model_name='attachment',
            name='filetype',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE, to='misago_threads.AttachmentType'
            ),
        ),
        migrations.AddField(
            model_name='attachment',
            name='uploader',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to=settings.AUTH_USER_MODEL
            ),
        ),
        migrations.CreateModel(
            name='Poll',
            fields=[
                (
                    'id', models.AutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name='ID'
                    )
                ),
                ('poster_name', models.CharField(max_length=255)),
                ('poster_slug', models.CharField(max_length=255)),
                ('poster_ip', models.GenericIPAddressField()),
                ('posted_on', models.DateTimeField(default=django.utils.timezone.now)),
                ('length', models.PositiveIntegerField(default=0)),
                ('question', models.CharField(max_length=255)),
                ('choices', django.contrib.postgres.fields.jsonb.JSONField()),
                ('allowed_choices', models.PositiveIntegerField(default=1)),
                ('allow_revotes', models.BooleanField(default=False)),
                ('votes', models.PositiveIntegerField(default=0)),
                ('is_public', models.BooleanField(default=False)),
                (
                    'category', models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='misago_categories.Category'
                    )
                ),
                (
                    'poster', models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL
                    )
                ),
                (
                    'thread', models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE, to='misago_threads.Thread'
                    )
                ),
            ],
        ),
        migrations.CreateModel(
            name='PollVote',
            fields=[
                (
                    'id', models.AutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name='ID'
                    )
                ),
                ('voter_name', models.CharField(max_length=255)),
                ('voter_slug', models.CharField(max_length=255)),
                ('voter_ip', models.GenericIPAddressField()),
                ('voted_on', models.DateTimeField(default=django.utils.timezone.now)),
                ('choice_hash', models.CharField(db_index=True, max_length=12)),
                (
                    'category', models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='misago_categories.Category'
                    )
                ),
                (
                    'poll', models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to='misago_threads.Poll'
                    )
                ),
                (
                    'thread', models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to='misago_threads.Thread'
                    )
                ),
                (
                    'voter', models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL
                    )
                ),
            ],
        ),
        migrations.AlterIndexTogether(
            name='pollvote',
            index_together=set([
                ('poll', 'voter_name'),
            ]),
        ),
        migrations.CreateModel(
            name='PostLike',
            fields=[
                (
                    'id', models.AutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name='ID'
                    )
                ),
                ('liker_name', models.CharField(max_length=255, db_index=True)),
                ('liker_slug', models.CharField(max_length=255)),
                ('liker_ip', models.GenericIPAddressField()),
                ('liked_on', models.DateTimeField(default=django.utils.timezone.now)),
                (
                    'category', models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='misago_categories.Category'
                    )
                ),
            ],
            options={
                'ordering': ['-id'],
            },
        ),
        migrations.AddField(
            model_name='postlike',
            name='post',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE, to='misago_threads.Post'
            ),
        ),
        migrations.AddField(
            model_name='postlike',
            name='thread',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE, to='misago_threads.Thread'
            ),
        ),
        migrations.AddField(
            model_name='postlike',
            name='liker',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to=settings.AUTH_USER_MODEL
            ),
        ),
        migrations.AddField(
            model_name='post',
            name='liked_by',
            field=models.ManyToManyField(
                related_name='liked_post_set',
                through='misago_threads.PostLike',
                to=settings.AUTH_USER_MODEL
            ),
        ),
    ]
Ejemplo n.º 3
0
class Migration(migrations.Migration):

    dependencies = [
        ('auth', '0001_initial'),
        ('misago_acl', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='User',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('password',
                 models.CharField(max_length=128, verbose_name='password')),
                ('last_login',
                 models.DateTimeField(null=True,
                                      blank=True,
                                      verbose_name='last login')),
                ('username', models.CharField(max_length=30)),
                ('slug', models.CharField(unique=True, max_length=30)),
                ('email', models.EmailField(max_length=255, db_index=True)),
                ('email_hash', models.CharField(unique=True, max_length=32)),
                ('joined_on',
                 models.DateTimeField(default=django.utils.timezone.now,
                                      verbose_name='joined on')),
                ('joined_from_ip', models.GenericIPAddressField()),
                ('last_ip', models.GenericIPAddressField(null=True,
                                                         blank=True)),
                ('is_hiding_presence', models.BooleanField(default=False)),
                ('title',
                 models.CharField(max_length=255, null=True, blank=True)),
                ('requires_activation',
                 models.PositiveIntegerField(default=0)),
                ('is_staff',
                 models.BooleanField(
                     default=False,
                     help_text=
                     'Designates whether the user can log into admin sites.',
                     verbose_name='staff status')),
                ('is_superuser',
                 models.BooleanField(
                     default=False,
                     help_text=
                     'Designates that this user has all permissions without explicitly assigning them.',
                     verbose_name='superuser status')),
                ('acl_key',
                 models.CharField(max_length=12, null=True, blank=True)),
                ('is_active',
                 models.BooleanField(
                     db_index=True,
                     default=True,
                     verbose_name='active',
                     help_text=
                     ('Designates whether this user should be treated as active. Unselect this instead of deleting '
                      'accounts.'))),
                ('is_active_staff_message',
                 models.TextField(null=True, blank=True)),
                ('groups',
                 models.ManyToManyField(
                     related_query_name='user',
                     related_name='user_set',
                     to='auth.Group',
                     blank=True,
                     help_text=
                     'The groups this user belongs to. A user will get all permissions granted to each of his/her group.',
                     verbose_name='groups')),
                ('roles', models.ManyToManyField(to='misago_acl.Role')),
                ('user_permissions',
                 models.ManyToManyField(
                     related_query_name='user',
                     related_name='user_set',
                     to='auth.Permission',
                     blank=True,
                     help_text='Specific permissions for this user.',
                     verbose_name='user permissions')),
                ('avatar_tmp',
                 models.ImageField(
                     max_length=255,
                     upload_to=misago.users.avatars.store.upload_to,
                     null=True,
                     blank=True)),
                ('avatar_src',
                 models.ImageField(
                     max_length=255,
                     upload_to=misago.users.avatars.store.upload_to,
                     null=True,
                     blank=True)),
                ('avatar_crop',
                 models.CharField(max_length=255, null=True, blank=True)),
                ('avatars', JSONField(null=True, blank=True)),
                ('is_avatar_locked', models.BooleanField(default=False)),
                ('avatar_lock_user_message',
                 models.TextField(null=True, blank=True)),
                ('avatar_lock_staff_message',
                 models.TextField(null=True, blank=True)),
                ('signature', models.TextField(null=True, blank=True)),
                ('signature_parsed', models.TextField(null=True, blank=True)),
                ('signature_checksum',
                 models.CharField(max_length=64, null=True, blank=True)),
                ('is_signature_locked', models.BooleanField(default=False)),
                ('signature_lock_user_message',
                 models.TextField(null=True, blank=True)),
                ('signature_lock_staff_message',
                 models.TextField(null=True, blank=True)),
                ('following', models.PositiveIntegerField(default=0)),
                ('followers', models.PositiveIntegerField(default=0)),
                ('limits_private_thread_invites_to',
                 models.PositiveIntegerField(default=0)),
                ('unread_private_threads',
                 models.PositiveIntegerField(default=0)),
                ('sync_unread_private_threads',
                 models.BooleanField(default=False)),
                ('subscribe_to_started_threads',
                 models.PositiveIntegerField(default=0)),
                ('subscribe_to_replied_threads',
                 models.PositiveIntegerField(default=0)),
                ('threads', models.PositiveIntegerField(default=0)),
                ('posts', models.PositiveIntegerField(default=0,
                                                      db_index=True)),
                ('last_posted_on', models.DateTimeField(null=True,
                                                        blank=True)),
            ],
            options={
                'abstract': False,
            },
            bases=(models.Model, ),
        ),
        CreatePartialIndex(
            field='User.is_staff',
            index_name='misago_users_user_is_staff_partial',
            condition='is_staff = TRUE',
        ),
        CreatePartialIndex(
            field='User.requires_activation',
            index_name='misago_users_user_requires_activation_partial',
            condition='requires_activation > 0',
        ),
        migrations.CreateModel(
            name='Online',
            fields=[
                ('current_ip', models.GenericIPAddressField()),
                ('last_click',
                 models.DateTimeField(default=django.utils.timezone.now)),
                ('user',
                 models.OneToOneField(related_name='online_tracker',
                                      primary_key=True,
                                      serialize=False,
                                      to=settings.AUTH_USER_MODEL)),
            ],
            options={},
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='UsernameChange',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('changed_by_username', models.CharField(max_length=30)),
                ('changed_on',
                 models.DateTimeField(default=django.utils.timezone.now)),
                ('new_username', models.CharField(max_length=255)),
                ('old_username', models.CharField(max_length=255)),
                ('changed_by',
                 models.ForeignKey(
                     related_name='user_renames',
                     on_delete=django.db.models.deletion.SET_NULL,
                     blank=True,
                     to=settings.AUTH_USER_MODEL,
                     null=True)),
                ('user',
                 models.ForeignKey(related_name='namechanges',
                                   to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'get_latest_by': b'changed_on',
            },
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='Rank',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name', models.CharField(max_length=255)),
                ('slug', models.CharField(unique=True, max_length=255)),
                ('description', models.TextField(null=True, blank=True)),
                ('title',
                 models.CharField(max_length=255, null=True, blank=True)),
                ('css_class',
                 models.CharField(max_length=255, null=True, blank=True)),
                ('is_default', models.BooleanField(default=False)),
                ('is_tab', models.BooleanField(default=False)),
                ('order', models.IntegerField(default=0)),
                ('roles',
                 models.ManyToManyField(to='misago_acl.Role',
                                        null=True,
                                        blank=True)),
            ],
            options={
                'get_latest_by': b'order',
            },
            bases=(models.Model, ),
        ),
        migrations.AddField(
            model_name='user',
            name='rank',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.PROTECT,
                to_field='id',
                blank=True,
                to='misago_users.Rank',
                null=True),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='user',
            name='follows',
            field=models.ManyToManyField(related_name='followed_by',
                                         to=settings.AUTH_USER_MODEL),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='user',
            name='blocks',
            field=models.ManyToManyField(related_name='blocked_by',
                                         to=settings.AUTH_USER_MODEL),
            preserve_default=True,
        ),
        migrations.CreateModel(
            name='ActivityRanking',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('user',
                 models.ForeignKey(related_name='+',
                                   to=settings.AUTH_USER_MODEL)),
                ('score', models.PositiveIntegerField(default=0,
                                                      db_index=True)),
            ],
            options={},
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='Avatar',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('user',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL)),
                ('size', models.PositiveIntegerField(default=0)),
                ('image',
                 models.ImageField(
                     max_length=255,
                     upload_to=misago.users.avatars.store.upload_to)),
            ],
        ),
        migrations.CreateModel(
            name='AvatarGallery',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('gallery', models.CharField(max_length=255)),
                ('image',
                 models.ImageField(
                     max_length=255,
                     upload_to=misago.users.avatars.store.upload_to)),
            ],
            options={
                'ordering': ['gallery', 'pk'],
            },
        ),
        migrations.CreateModel(
            name='Ban',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('check_type',
                 models.PositiveIntegerField(default=0, db_index=True)),
                ('banned_value', models.CharField(max_length=255,
                                                  db_index=True)),
                ('user_message', models.TextField(null=True, blank=True)),
                ('staff_message', models.TextField(null=True, blank=True)),
                ('expires_on',
                 models.DateTimeField(null=True, blank=True, db_index=True)),
                ('is_checked', models.BooleanField(default=True,
                                                   db_index=True)),
            ],
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='BanCache',
            fields=[
                ('user_message', models.TextField(null=True, blank=True)),
                ('staff_message', models.TextField(null=True, blank=True)),
                ('bans_version', models.PositiveIntegerField(default=0)),
                ('expires_on', models.DateTimeField(null=True, blank=True)),
                ('ban',
                 models.ForeignKey(
                     on_delete=django.db.models.deletion.SET_NULL,
                     blank=True,
                     to='misago_users.Ban',
                     null=True)),
                ('user',
                 models.OneToOneField(related_name='ban_cache',
                                      primary_key=True,
                                      serialize=False,
                                      to=settings.AUTH_USER_MODEL)),
            ],
            options={},
            bases=(models.Model, ),
        ),
    ]
Ejemplo n.º 4
0
class Migration(migrations.Migration):

    dependencies = [
        ('misago_forums', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Label',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name', models.CharField(max_length=255)),
                ('slug', models.SlugField(max_length=255)),
                ('css_class',
                 models.CharField(max_length=255, null=True, blank=True)),
                ('forums', models.ManyToManyField(to='misago_forums.Forum')),
            ],
            options={},
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='Post',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('poster_name', models.CharField(max_length=255)),
                ('poster_ip', models.GenericIPAddressField()),
                ('original', models.TextField()),
                ('parsed', models.TextField()),
                ('checksum', models.CharField(max_length=64, default='-')),
                ('has_attachments', models.BooleanField(default=False)),
                ('pickled_attachments', models.TextField(null=True,
                                                         blank=True)),
                ('posted_on', models.DateTimeField()),
                ('updated_on', models.DateTimeField()),
                ('edits', models.PositiveIntegerField(default=0)),
                ('last_editor_name',
                 models.CharField(max_length=255, null=True, blank=True)),
                ('last_editor_slug',
                 models.SlugField(max_length=255, null=True, blank=True)),
                ('is_reported', models.BooleanField(default=False)),
                ('is_moderated',
                 models.BooleanField(default=False, db_index=True)),
                ('is_hidden', models.BooleanField(default=False)),
                ('is_protected', models.BooleanField(default=False)),
                ('forum', models.ForeignKey(to='misago_forums.Forum')),
                ('last_editor',
                 models.ForeignKey(
                     related_name=b'+',
                     on_delete=django.db.models.deletion.SET_NULL,
                     blank=True,
                     to=settings.AUTH_USER_MODEL,
                     null=True)),
                ('mentions',
                 models.ManyToManyField(related_name=b'mention_set',
                                        to=settings.AUTH_USER_MODEL)),
                ('poster',
                 models.ForeignKey(
                     on_delete=django.db.models.deletion.SET_NULL,
                     blank=True,
                     to=settings.AUTH_USER_MODEL,
                     null=True)),
            ],
            options={},
            bases=(models.Model, ),
        ),
        CreatePartialIndex(
            field='Post.is_reported',
            index_name='misago_post_is_reported_partial',
            condition='is_reported = TRUE',
        ),
        CreatePartialIndex(
            field='Post.is_hidden',
            index_name='misago_post_is_hidden_partial',
            condition='is_hidden = FALSE',
        ),
        migrations.CreateModel(
            name='Thread',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('title', models.CharField(max_length=255)),
                ('slug', models.CharField(max_length=255)),
                ('replies',
                 models.PositiveIntegerField(default=0, db_index=True)),
                ('has_reported_posts', models.BooleanField(default=False)),
                ('has_moderated_posts', models.BooleanField(default=False)),
                ('has_hidden_posts', models.BooleanField(default=False)),
                ('has_events', models.BooleanField(default=False)),
                ('started_on', models.DateTimeField(db_index=True)),
                ('starter_name', models.CharField(max_length=255)),
                ('starter_slug', models.CharField(max_length=255)),
                ('last_post_on', models.DateTimeField(db_index=True)),
                ('last_poster_name',
                 models.CharField(max_length=255, null=True, blank=True)),
                ('last_poster_slug',
                 models.CharField(max_length=255, null=True, blank=True)),
                ('is_pinned', models.BooleanField(default=False,
                                                  db_index=True)),
                ('is_poll', models.BooleanField(default=False)),
                ('is_moderated',
                 models.BooleanField(default=False, db_index=True)),
                ('is_hidden', models.BooleanField(default=False)),
                ('is_closed', models.BooleanField(default=False)),
            ],
            options={},
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='Event',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('author_name', models.CharField(max_length=255)),
                ('author_slug', models.CharField(max_length=255)),
                ('icon', models.CharField(max_length=255)),
                ('occured_on',
                 models.DateTimeField(default=django.utils.timezone.now,
                                      db_index=True)),
                ('message', models.CharField(max_length=255)),
                ('checksum', models.CharField(max_length=64, default='-')),
                ('is_hidden', models.BooleanField(default=False)),
                ('author',
                 models.ForeignKey(
                     on_delete=django.db.models.deletion.SET_NULL,
                     blank=True,
                     to=settings.AUTH_USER_MODEL,
                     null=True)),
                ('forum', models.ForeignKey(to='misago_forums.Forum')),
                ('thread', models.ForeignKey(to='misago_threads.Thread')),
            ],
            options={},
            bases=(models.Model, ),
        ),
        CreatePartialIndex(
            field='Thread.has_reported_posts',
            index_name='misago_thread_has_reported_posts_partial',
            condition='has_reported_posts = TRUE',
        ),
        CreatePartialIndex(
            field='Thread.has_moderated_posts',
            index_name='misago_thread_has_moderated_posts_partial',
            condition='has_moderated_posts = TRUE',
        ),
        CreatePartialIndex(
            field='Thread.is_hidden',
            index_name='misago_thread_is_hidden_partial',
            condition='is_hidden = FALSE',
        ),
        migrations.AddField(
            model_name='post',
            name='thread',
            field=models.ForeignKey(to='misago_threads.Thread'),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='first_post',
            field=models.ForeignKey(
                related_name=b'+',
                on_delete=django.db.models.deletion.SET_NULL,
                blank=True,
                to='misago_threads.Post',
                null=True),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='forum',
            field=models.ForeignKey(to='misago_forums.Forum'),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='last_post',
            field=models.ForeignKey(
                related_name=b'+',
                on_delete=django.db.models.deletion.SET_NULL,
                blank=True,
                to='misago_threads.Post',
                null=True),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='last_poster',
            field=models.ForeignKey(
                related_name=b'last_poster_set',
                on_delete=django.db.models.deletion.SET_NULL,
                blank=True,
                to=settings.AUTH_USER_MODEL,
                null=True),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='label',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.SET_NULL,
                blank=True,
                to='misago_threads.Label',
                null=True),
            preserve_default=True,
        ),
        migrations.AddField(
            model_name='thread',
            name='starter',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.SET_NULL,
                blank=True,
                to=settings.AUTH_USER_MODEL,
                null=True),
            preserve_default=True,
        ),
        migrations.AlterIndexTogether(
            name='thread',
            index_together=set([
                ('forum', 'id'),
                ('forum', 'last_post_on'),
                ('forum', 'replies'),
            ]),
        ),
    ]