# Generated by Django 3.1.7 on 2021-05-03 17:04

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("community", "0016_add_package_listing_section"),
    ]

    operations = [
        migrations.AddField(
            model_name="community",
            name="require_package_listing_approval",
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name="packagelisting",
            name="review_status",
            field=models.CharField(
                choices=[
                    ("unreviewed", "unreviewed"),
                    ("approved", "approved"),
                    ("rejected", "rejected"),
                ],
                default="unreviewed",
                max_length=512,
            ),
        ),
        migrations.CreateModel(
            name="CommunityMembership",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("datetime_created", models.DateTimeField(auto_now_add=True)),
                ("datetime_updated", models.DateTimeField(auto_now=True)),
                (
                    "role",
                    models.CharField(
                        choices=[
                            ("owner", "owner"),
                            ("moderator", "moderator"),
                            ("member", "member"),
                        ],
                        default="member",
                        max_length=64,
                    ),
                ),
                (
                    "community",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="members",
                        to="community.community",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="community_memberships",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "community member",
                "verbose_name_plural": "community members",
            },
        ),
        migrations.AddConstraint(
            model_name="communitymembership",
            constraint=models.UniqueConstraint(
                fields=("user", "community"), name="one_community_membership_per_user"
            ),
        ),
    ]
