85 lines
2.9 KiB
Python
85 lines
2.9 KiB
Python
import uuid
|
|
|
|
import django.db.models.deletion
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
("submissions", "0005_submission_event_required"),
|
|
("games", "0007_eventgame_apibot_token"),
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name="Scope",
|
|
fields=[
|
|
(
|
|
"id",
|
|
models.UUIDField(
|
|
default=uuid.uuid4,
|
|
editable=False,
|
|
primary_key=True,
|
|
serialize=False,
|
|
),
|
|
),
|
|
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
|
(
|
|
"external_id",
|
|
models.PositiveIntegerField(
|
|
blank=True,
|
|
help_text="Legacy AAndT match id, set when synced automatically.",
|
|
null=True,
|
|
),
|
|
),
|
|
("name", models.CharField(max_length=255)),
|
|
(
|
|
"is_active",
|
|
models.BooleanField(
|
|
default=True,
|
|
help_text="Whether submissions are currently accepted for this scope.",
|
|
),
|
|
),
|
|
(
|
|
"synced_at",
|
|
models.DateTimeField(
|
|
blank=True,
|
|
help_text="Last time this scope was synced from the AAndT API.",
|
|
null=True,
|
|
),
|
|
),
|
|
(
|
|
"assigned_users",
|
|
models.ManyToManyField(
|
|
blank=True,
|
|
help_text="Users allowed to submit scores for this scope.",
|
|
related_name="scopes",
|
|
to=settings.AUTH_USER_MODEL,
|
|
),
|
|
),
|
|
(
|
|
"event_game",
|
|
models.ForeignKey(
|
|
on_delete=django.db.models.deletion.CASCADE,
|
|
related_name="scopes",
|
|
to="games.eventgame",
|
|
),
|
|
),
|
|
],
|
|
options={
|
|
"ordering": ["-created_at"],
|
|
},
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name="scope",
|
|
constraint=models.UniqueConstraint(
|
|
condition=models.Q(("external_id__isnull", False)),
|
|
fields=("event_game", "external_id"),
|
|
name="unique_scope_external_id_per_event_game",
|
|
),
|
|
),
|
|
]
|