# Generated by Django 3.1.8 on 2021-04-22 19:40


# Disclaimer
# ----------
#
# Copyright (C) 2021 Helmholtz-Zentrum Hereon
# Copyright (C) 2020-2021 Helmholtz-Zentrum Geesthacht
#
# This file is part of django-academic-community and is released under the
# EUPL-1.2 license.
# See LICENSE in the root of the repository for full licensing details.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the EUROPEAN UNION PUBLIC LICENCE v. 1.2 or later
# as published by the European Commission.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# EUPL-1.2 license for more details.
#
# You should have received a copy of the EUPL-1.2 license along with this
# program. If not, see https://www.eupl.eu/.


import django.core.validators
import django.db.models.deletion
import djangocms_text_ckeditor.fields
from django.conf import settings
from django.db import migrations, models

import academic_community.history.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("activities", "0001_initial"),
        ("members", "0001_initial"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("institutions", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="Affiliation",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="Full name of the affiliation",
                        max_length=500,
                    ),
                ),
                (
                    "country",
                    models.ForeignKey(
                        help_text="Country of the organization",
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        to="institutions.country",
                    ),
                ),
                (
                    "organization",
                    models.OneToOneField(
                        blank=True,
                        help_text="The corresponding academic organization in the CLM-Community",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="assembly_affiliation",
                        to="institutions.academicorganization",
                    ),
                ),
            ],
            bases=(
                academic_community.history.models.RevisionMixin,
                models.Model,
            ),
        ),
        migrations.CreateModel(
            name="Author",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "first_name",
                    models.CharField(
                        help_text="First name of the (co-)author.",
                        max_length=50,
                    ),
                ),
                (
                    "last_name",
                    models.CharField(
                        help_text="Last name of the (co-)author.",
                        max_length=255,
                    ),
                ),
                (
                    "orcid",
                    models.CharField(
                        blank=True,
                        help_text="The ORCID of the community member, see <a href='https://orcid.org/'>orcid.org</a>",
                        max_length=19,
                        null=True,
                        validators=[
                            django.core.validators.RegexValidator(
                                "\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]"
                            )
                        ],
                    ),
                ),
            ],
            bases=(
                academic_community.history.models.RevisionMixin,
                models.Model,
            ),
        ),
        migrations.CreateModel(
            name="ContributingAuthor",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "is_presenter",
                    models.BooleanField(
                        default=False,
                        help_text="Is the author a presenting author?",
                    ),
                ),
                (
                    "authorlist_position",
                    models.PositiveIntegerField(
                        help_text="Order of the (co-)author in the author list",
                        validators=[
                            django.core.validators.MinValueValidator(1)
                        ],
                    ),
                ),
                (
                    "affiliation",
                    models.ManyToManyField(
                        help_text="The affiliation of the author in this contribution.",
                        related_name="contribution_map",
                        to="programme.Affiliation",
                    ),
                ),
                (
                    "author",
                    models.ForeignKey(
                        help_text="The author or co-author for this contribution.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="contribution_map",
                        to="programme.author",
                    ),
                ),
            ],
            options={
                "ordering": ["contribution", "authorlist_position"],
            },
            bases=(
                academic_community.history.models.RevisionMixin,
                models.Model,
            ),
        ),
        migrations.CreateModel(
            name="PresentationType",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="Description of the type",
                        max_length=30,
                        unique=True,
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Contribution",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "title",
                    models.CharField(
                        help_text="Title of the contribution", max_length=200
                    ),
                ),
                (
                    "abstract",
                    djangocms_text_ckeditor.fields.HTMLField(
                        help_text="Please provide an abstract (max. 4000 characters)",
                        max_length=4000,
                    ),
                ),
                (
                    "accepted",
                    models.BooleanField(
                        default=False,
                        help_text="Accept this contribution for the given activity.",
                    ),
                ),
                (
                    "can_be_published",
                    models.BooleanField(
                        choices=[(True, "Yes"), (False, "No")],
                        help_text="Can the abstract be made publicly available for non-communitymembers after the assembly under a<a href='https://creativecommons.org/licenses/by/4.0/'>CC BY 4.0</a> license?",
                    ),
                ),
                (
                    "comment",
                    models.TextField(
                        blank=True,
                        help_text="Any other comments to the Organizing Committee/Working Group Leader.",
                        max_length=1000,
                        null=True,
                        verbose_name="Other comments",
                    ),
                ),
                (
                    "activity",
                    models.ForeignKey(
                        help_text="Please select the working or project group that this contribution fits the best.",
                        on_delete=django.db.models.deletion.PROTECT,
                        to="activities.activity",
                        verbose_name="Working Group/Project Group",
                    ),
                ),
                (
                    "authors",
                    models.ManyToManyField(
                        help_text="Co-authors for this contribution",
                        related_name="coauthored_contributions",
                        through="programme.ContributingAuthor",
                        to="programme.Author",
                    ),
                ),
                (
                    "presentation_type",
                    models.ForeignKey(
                        blank=True,
                        help_text="Type of the contribution. You can also leave this open and it will be decided at a later point.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="programme.presentationtype",
                    ),
                ),
                (
                    "submitter",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "permissions": (
                    ("accept_contribution", "Can accept the contribution"),
                    ("withdraw_contribution", "Can withdraw the contribution"),
                    (
                        "change_activity",
                        "Can change the activity of the contribution",
                    ),
                ),
            },
            bases=(
                academic_community.history.models.RevisionMixin,
                models.Model,
            ),
        ),
        migrations.AddField(
            model_name="contributingauthor",
            name="contribution",
            field=models.ForeignKey(
                help_text="The underlying assembly contribution.",
                on_delete=django.db.models.deletion.CASCADE,
                to="programme.contribution",
            ),
        ),
        migrations.AddField(
            model_name="author",
            name="contributions",
            field=models.ManyToManyField(
                help_text="Contributions for this author",
                related_name="contributing_author",
                through="programme.ContributingAuthor",
                to="programme.Contribution",
            ),
        ),
        migrations.AddField(
            model_name="author",
            name="member",
            field=models.OneToOneField(
                blank=True,
                help_text="The corresponding community member.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="assembly_author",
                to="members.communitymember",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="contributingauthor",
            unique_together={
                ("contribution", "authorlist_position"),
                ("contribution", "author"),
            },
        ),
    ]
