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

import academic_community.history.models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="Category",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="The name of the category.", max_length=255
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Activity",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="The name of the activity.", max_length=255
                    ),
                ),
                (
                    "abbreviation",
                    models.CharField(
                        help_text="The abbreviated name of the activity.",
                        max_length=20,
                        unique=True,
                    ),
                ),
                (
                    "description",
                    models.CharField(
                        blank=True,
                        help_text="More details about the activity.",
                        max_length=4000,
                        null=True,
                    ),
                ),
                (
                    "invitation_only",
                    models.BooleanField(
                        default=False,
                        help_text="If set, only the activity leader or deputy are able to add new members. Otherwise, community members can freely join and leave through their profile page or on the activity detail page.",
                    ),
                ),
                (
                    "start_date",
                    models.DateField(
                        auto_now_add=True,
                        help_text="The date when this activity started.",
                    ),
                ),
                (
                    "end_date",
                    models.DateField(
                        blank=True,
                        help_text="The date when this activity stopped.",
                        null=True,
                    ),
                ),
                (
                    "mailing_list",
                    models.CharField(
                        blank=True,
                        help_text="The name of the DFN mailing list, e.g. 'clm_co'.",
                        max_length=10,
                        null=True,
                    ),
                ),
                (
                    "category",
                    models.ForeignKey(
                        help_text="The category of this activity.",
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="activities.category",
                    ),
                ),
            ],
            options={
                "ordering": [
                    django.db.models.expressions.OrderBy(
                        django.db.models.expressions.F("category__name"),
                        nulls_last=True,
                    ),
                    django.db.models.expressions.OrderBy(
                        django.db.models.expressions.F("end_date"),
                        nulls_first=True,
                    ),
                ],
                "permissions": (
                    ("change_activity_lead", "Can change activity leader"),
                    ("change_activity_deputy", "Can change activity deputy"),
                ),
            },
            bases=(
                academic_community.history.models.RevisionMixin,
                models.Model,
            ),
        ),
    ]
