# 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.db.models.deletion
import django.db.models.expressions
import djangocms_text_ckeditor.fields
from django.db import migrations, models

import academic_community.history.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("activities", "0001_initial"),
        ("members", "0001_initial"),
        ("institutions", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="CouplingComponent",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="Name of the component.", max_length=50
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="EvalData",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="The name of the evaluation dataset.",
                        max_length=50,
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Forcing",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="The name of the forcing dataset.",
                        max_length=50,
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Keyword",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="The name of the keyword.", max_length=150
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="LocalBoundaryCondition",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="The name of the <abbr title='Local Boundary Condition'>LBC</abbr>.",
                        max_length=150,
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="ModelCompartmentDevelopment",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="Name of the model compartment.",
                        max_length=50,
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Region",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="The name of the region.", max_length=50
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="SimulationModel",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="The name of the model.", max_length=50
                    ),
                ),
                (
                    "description",
                    models.CharField(
                        blank=True,
                        help_text="More details about the model.",
                        max_length=4000,
                        null=True,
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Topic",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="The name of the topic.", max_length=255
                    ),
                ),
                (
                    "id_name",
                    models.SlugField(
                        help_text="Unique identifier of the topic. Should consist of the abbreviated  institution number and another number. HZG-001 for instance.",
                        max_length=25,
                        unique=True,
                    ),
                ),
                (
                    "description",
                    djangocms_text_ckeditor.fields.HTMLField(
                        help_text="More details about the topic.",
                        max_length=10000,
                        null=True,
                    ),
                ),
                (
                    "desired_cooperations",
                    models.CharField(
                        blank=True,
                        help_text="More details about (desired) cooperations to other topics and communities.",
                        max_length=4000,
                        null=True,
                    ),
                ),
                (
                    "start_date",
                    models.DateField(
                        auto_now_add=True,
                        help_text="The starting date of the topic.",
                        null=True,
                    ),
                ),
                (
                    "end_date",
                    models.DateField(
                        blank=True,
                        help_text="The end date of the topic.",
                        null=True,
                    ),
                ),
                (
                    "last_modification_date",
                    models.DateField(
                        auto_now=True,
                        help_text="Date of the last update to the topic record.",
                        null=True,
                    ),
                ),
                (
                    "is_internal",
                    models.BooleanField(
                        default=True,
                        help_text="Is the topic for internal use only?.",
                    ),
                ),
                (
                    "resolution",
                    models.CharField(
                        blank=True,
                        help_text="Resolutions covered in the model [km].",
                        max_length=50,
                        null=True,
                    ),
                ),
                (
                    "min_resolution",
                    models.FloatField(
                        blank=True,
                        help_text="Minimum resolution of the models within the topic [km].",
                        null=True,
                    ),
                ),
                (
                    "max_resolution",
                    models.FloatField(
                        blank=True,
                        help_text="Maximum resolution of the models within the topic [km].",
                        null=True,
                    ),
                ),
                (
                    "model_availability",
                    models.DateField(
                        blank=True,
                        help_text="Planned availability of the developped model.",
                        null=True,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("ongoing", "Ongoing"),
                            ("planned", "Planned"),
                            ("finished", "Finished"),
                        ],
                        help_text="The status of the topic.",
                        max_length=8,
                        null=True,
                    ),
                ),
                (
                    "references",
                    models.CharField(
                        blank=True,
                        help_text="Other references to this topic.",
                        max_length=4000,
                        null=True,
                    ),
                ),
                (
                    "publication",
                    models.CharField(
                        blank=True,
                        help_text="Peer-reviewed articles published from this topic.",
                        max_length=4000,
                        null=True,
                    ),
                ),
                (
                    "program",
                    models.CharField(
                        blank=True,
                        help_text="Name of a superior program.",
                        max_length=255,
                        null=True,
                    ),
                ),
                (
                    "activity",
                    models.ManyToManyField(
                        help_text="Associated activities within the community.",
                        to="activities.Activity",
                    ),
                ),
                (
                    "compartment",
                    models.ForeignKey(
                        blank=True,
                        help_text="Model compartment.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="topics.modelcompartmentdevelopment",
                        verbose_name="Field of investigation.",
                    ),
                ),
                (
                    "component",
                    models.ForeignKey(
                        blank=True,
                        help_text="Name of the Component under development.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="topics.couplingcomponent",
                    ),
                ),
                (
                    "eval_data",
                    models.ManyToManyField(
                        blank=True,
                        help_text="Evaluation datasets.",
                        to="topics.EvalData",
                    ),
                ),
                (
                    "forcing",
                    models.ManyToManyField(
                        blank=True,
                        help_text="Forcing datasets used within the topic.",
                        to="topics.Forcing",
                    ),
                ),
                (
                    "keywords",
                    models.ManyToManyField(
                        blank=True,
                        help_text="Topic keywords.",
                        to="topics.Keyword",
                    ),
                ),
                (
                    "lbc",
                    models.ManyToManyField(
                        blank=True,
                        help_text="Local boundary conditions used for this topic.",
                        to="topics.LocalBoundaryCondition",
                        verbose_name="local boundary conditition",
                    ),
                ),
                (
                    "lead_organization",
                    models.ForeignKey(
                        help_text="The leading research organization (institution, department or unit) of this topic.",
                        on_delete=django.db.models.deletion.PROTECT,
                        to="institutions.academicorganization",
                    ),
                ),
                (
                    "leader",
                    models.ForeignKey(
                        help_text="The community member leading this activity.",
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="topic_lead",
                        to="members.communitymember",
                    ),
                ),
            ],
            options={
                "ordering": ["id_name"],
                "permissions": (
                    (
                        "approve_topicmembership",
                        "Can approve topic memberships",
                    ),
                    (
                        "change_topic_lead",
                        "Can change leader and lead organization",
                    ),
                ),
            },
            bases=(
                academic_community.history.models.RevisionMixin,
                models.Model,
            ),
        ),
        migrations.CreateModel(
            name="Usage",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="The description of the model usage.",
                        max_length=50,
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="TopicMembership",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "approved",
                    models.BooleanField(
                        default=False,
                        help_text="Topic membership approved by topic leader.",
                    ),
                ),
                (
                    "start_date",
                    models.DateField(
                        auto_now_add=True,
                        help_text="The date when the member joined the topic.",
                        null=True,
                    ),
                ),
                (
                    "end_date",
                    models.DateField(
                        blank=True,
                        help_text="The date when the member left the topic.",
                        null=True,
                    ),
                ),
                (
                    "member",
                    models.ForeignKey(
                        help_text="The members profile.",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="members.communitymember",
                    ),
                ),
                (
                    "topic",
                    models.ForeignKey(
                        help_text="The CLM-topic that the member contributes to.",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="topics.topic",
                    ),
                ),
            ],
            options={
                "ordering": [
                    django.db.models.expressions.OrderBy(
                        django.db.models.expressions.F("start_date"),
                        nulls_last=True,
                    )
                ],
                "permissions": (
                    ("end_topicmembership", "Can end topic memberships"),
                ),
            },
            bases=(
                academic_community.history.models.RevisionMixin,
                models.Model,
            ),
        ),
        migrations.AddField(
            model_name="topic",
            name="members",
            field=models.ManyToManyField(
                blank=True,
                help_text="Community members contributing to this topic.",
                through="topics.TopicMembership",
                to="members.CommunityMember",
            ),
        ),
        migrations.AddField(
            model_name="topic",
            name="region",
            field=models.ManyToManyField(
                blank=True,
                help_text="Focus regions of this topic.",
                to="topics.Region",
            ),
        ),
        migrations.AddField(
            model_name="topic",
            name="simulation_model",
            field=models.ManyToManyField(
                blank=True,
                help_text="Simulation models used within this topic.",
                to="topics.SimulationModel",
                verbose_name="Model version",
            ),
        ),
        migrations.AddField(
            model_name="topic",
            name="usage",
            field=models.ManyToManyField(
                blank=True, help_text="Usage of the topic.", to="topics.Usage"
            ),
        ),
        migrations.CreateModel(
            name="SimulationPeriod",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "start_year",
                    models.IntegerField(
                        help_text="Start year of the simulation period."
                    ),
                ),
                (
                    "end_year",
                    models.IntegerField(
                        blank=True,
                        help_text="End year of the simulation period.",
                        null=True,
                    ),
                ),
                (
                    "topic",
                    models.ForeignKey(
                        help_text="Related CLM-topic",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="topics.topic",
                    ),
                ),
            ],
        ),
    ]
