| 1 |
|
| 2 |
|
| 3 |
import django.db.models.deletion |
| 4 |
import django.utils.timezone |
| 5 |
from django.conf import settings |
| 6 |
from django.db import migrations |
| 7 |
from django.db import models |
| 8 |
|
| 9 |
import organizations.base |
| 10 |
import organizations.fields |
| 11 |
|
| 12 |
|
| 13 |
class Migration(migrations.Migration): |
| 14 |
initial = True |
| 15 |
|
| 16 |
dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)] |
| 17 |
|
| 18 |
operations = [ |
| 19 |
migrations.CreateModel( |
| 20 |
name="Organization", |
| 21 |
fields=[ |
| 22 |
( |
| 23 |
"id", |
| 24 |
models.AutoField( |
| 25 |
auto_created=True, |
| 26 |
primary_key=True, |
| 27 |
serialize=False, |
| 28 |
verbose_name="ID", |
| 29 |
), |
| 30 |
), |
| 31 |
( |
| 32 |
"name", |
| 33 |
models.CharField( |
| 34 |
help_text="The name of the organization", max_length=200 |
| 35 |
), |
| 36 |
), |
| 37 |
("is_active", models.BooleanField(default=True)), |
| 38 |
( |
| 39 |
"created", |
| 40 |
organizations.fields.AutoCreatedField( |
| 41 |
default=django.utils.timezone.now, editable=False |
| 42 |
), |
| 43 |
), |
| 44 |
( |
| 45 |
"modified", |
| 46 |
organizations.fields.AutoLastModifiedField( |
| 47 |
default=django.utils.timezone.now, editable=False |
| 48 |
), |
| 49 |
), |
| 50 |
( |
| 51 |
"slug", |
| 52 |
organizations.fields.SlugField( |
| 53 |
editable=True, |
| 54 |
help_text="The name in all lowercase, suitable for URL identification", |
| 55 |
max_length=200, |
| 56 |
populate_from="name", |
| 57 |
unique=True, |
| 58 |
), |
| 59 |
), |
| 60 |
], |
| 61 |
options={ |
| 62 |
"verbose_name": "organization", |
| 63 |
"verbose_name_plural": "organizations", |
| 64 |
"ordering": ["name"], |
| 65 |
"abstract": False, |
| 66 |
}, |
| 67 |
), |
| 68 |
migrations.CreateModel( |
| 69 |
name="OrganizationOwner", |
| 70 |
fields=[ |
| 71 |
( |
| 72 |
"id", |
| 73 |
models.AutoField( |
| 74 |
auto_created=True, |
| 75 |
primary_key=True, |
| 76 |
serialize=False, |
| 77 |
verbose_name="ID", |
| 78 |
), |
| 79 |
), |
| 80 |
( |
| 81 |
"created", |
| 82 |
organizations.fields.AutoCreatedField( |
| 83 |
default=django.utils.timezone.now, editable=False |
| 84 |
), |
| 85 |
), |
| 86 |
( |
| 87 |
"modified", |
| 88 |
organizations.fields.AutoLastModifiedField( |
| 89 |
default=django.utils.timezone.now, editable=False |
| 90 |
), |
| 91 |
), |
| 92 |
( |
| 93 |
"organization", |
| 94 |
models.OneToOneField( |
| 95 |
on_delete=django.db.models.deletion.CASCADE, |
| 96 |
related_name="owner", |
| 97 |
to="organizations.Organization", |
| 98 |
), |
| 99 |
), |
| 100 |
], |
| 101 |
options={ |
| 102 |
"verbose_name": "organization owner", |
| 103 |
"verbose_name_plural": "organization owners", |
| 104 |
"abstract": False, |
| 105 |
}, |
| 106 |
), |
| 107 |
migrations.CreateModel( |
| 108 |
name="OrganizationUser", |
| 109 |
fields=[ |
| 110 |
( |
| 111 |
"id", |
| 112 |
models.AutoField( |
| 113 |
auto_created=True, |
| 114 |
primary_key=True, |
| 115 |
serialize=False, |
| 116 |
verbose_name="ID", |
| 117 |
), |
| 118 |
), |
| 119 |
( |
| 120 |
"created", |
| 121 |
organizations.fields.AutoCreatedField( |
| 122 |
default=django.utils.timezone.now, editable=False |
| 123 |
), |
| 124 |
), |
| 125 |
( |
| 126 |
"modified", |
| 127 |
organizations.fields.AutoLastModifiedField( |
| 128 |
default=django.utils.timezone.now, editable=False |
| 129 |
), |
| 130 |
), |
| 131 |
("is_admin", models.BooleanField(default=False)), |
| 132 |
( |
| 133 |
"organization", |
| 134 |
models.ForeignKey( |
| 135 |
on_delete=django.db.models.deletion.CASCADE, |
| 136 |
related_name="organization_users", |
| 137 |
to="organizations.Organization", |
| 138 |
), |
| 139 |
), |
| 140 |
( |
| 141 |
"user", |
| 142 |
models.ForeignKey( |
| 143 |
on_delete=django.db.models.deletion.CASCADE, |
| 144 |
related_name="organizations_organizationuser", |
| 145 |
to=settings.AUTH_USER_MODEL, |
| 146 |
), |
| 147 |
), |
| 148 |
], |
| 149 |
options={ |
| 150 |
"verbose_name": "organization user", |
| 151 |
"verbose_name_plural": "organization users", |
| 152 |
"ordering": ["organization", "user"], |
| 153 |
"abstract": False, |
| 154 |
}, |
| 155 |
), |
| 156 |
migrations.AddField( |
| 157 |
model_name="organizationowner", |
| 158 |
name="organization_user", |
| 159 |
field=models.OneToOneField( |
| 160 |
on_delete=django.db.models.deletion.CASCADE, |
| 161 |
to="organizations.OrganizationUser", |
| 162 |
), |
| 163 |
), |
| 164 |
migrations.AddField( |
| 165 |
model_name="organization", |
| 166 |
name="users", |
| 167 |
field=models.ManyToManyField( |
| 168 |
related_name="organizations_organization", |
| 169 |
through="organizations.OrganizationUser", |
| 170 |
to=settings.AUTH_USER_MODEL, |
| 171 |
), |
| 172 |
), |
| 173 |
migrations.AlterUniqueTogether( |
| 174 |
name="organizationuser", unique_together={("user", "organization")} |
| 175 |
), |
| 176 |
] |