Add support for Reward campaigns

This commit is contained in:
2024-07-31 03:54:07 +02:00
parent 5433e1d9ce
commit 354d66f7bc
24 changed files with 765 additions and 576 deletions

View File

@ -1,160 +1,90 @@
# Generated by Django 5.1b1 on 2024-07-09 22:26
# Generated by Django 5.1rc1 on 2024-07-30 21:49
import uuid
import auto_prefetch
import django.db.models.deletion
import django.db.models.functions.text
import django.db.models.manager
from django.db import migrations, models
from django.db.migrations.operations.base import Operation
class Migration(migrations.Migration):
initial = True
dependencies = []
dependencies: list[tuple[str, str]] = []
operations = [
migrations.CreateModel(
name="DropCampaign",
fields=[
("id", models.TextField(primary_key=True, serialize=False)),
("account_link_url", models.URLField(blank=True, null=True)),
("description", models.TextField(blank=True, null=True)),
("details_url", models.URLField(blank=True, null=True)),
("end_at", models.DateTimeField(blank=True, null=True)),
("image_url", models.URLField(blank=True, null=True)),
("name", models.TextField(blank=True, null=True)),
("start_at", models.DateTimeField(blank=True, null=True)),
("status", models.TextField(blank=True, null=True)),
("added_at", models.DateTimeField(auto_now_add=True, null=True)),
("modified_at", models.DateTimeField(auto_now=True, null=True)),
],
options={
"verbose_name": "Drop Campaign",
"verbose_name_plural": "Drop Campaigns",
"ordering": ("name",),
"abstract": False,
"base_manager_name": "prefetch_manager",
},
managers=[
("objects", django.db.models.manager.Manager()),
("prefetch_manager", django.db.models.manager.Manager()),
],
),
operations: list[Operation] = [
migrations.CreateModel(
name="Game",
fields=[
("id", models.TextField(primary_key=True, serialize=False)),
("slug", models.TextField(blank=True, null=True)),
(
"twitch_url",
models.GeneratedField( # type: ignore # noqa: PGH003
db_persist=True,
expression=django.db.models.functions.text.Concat(
models.Value("https://www.twitch.tv/directory/category/"),
"slug",
),
output_field=models.TextField(),
),
),
(
"image_url",
models.GeneratedField( # type: ignore # noqa: PGH003
db_persist=True,
expression=django.db.models.functions.text.Concat(
models.Value("https://static-cdn.jtvnw.net/ttv-boxart/"),
"id",
models.Value("_IGDB.jpg"),
),
output_field=models.URLField(),
),
),
("display_name", models.TextField(blank=True, null=True)),
("added_at", models.DateTimeField(auto_now_add=True, null=True)),
("modified_at", models.DateTimeField(auto_now=True, null=True)),
],
options={
"verbose_name": "Game",
"verbose_name_plural": "Games",
"ordering": ("display_name",),
"abstract": False,
"base_manager_name": "prefetch_manager",
},
managers=[
("objects", django.db.models.manager.Manager()),
("prefetch_manager", django.db.models.manager.Manager()),
("id", models.AutoField(primary_key=True, serialize=False)),
("slug", models.TextField()),
("display_name", models.TextField()),
("typename", models.TextField()),
],
),
migrations.CreateModel(
name="Organization",
name="Image",
fields=[
("id", models.TextField(primary_key=True, serialize=False)),
("name", models.TextField(blank=True, null=True)),
("added_at", models.DateTimeField(auto_now_add=True, null=True)),
("modified_at", models.DateTimeField(auto_now=True, null=True)),
],
options={
"verbose_name": "Organization",
"verbose_name_plural": "Organizations",
"ordering": ("name",),
"abstract": False,
"base_manager_name": "prefetch_manager",
},
managers=[
("objects", django.db.models.manager.Manager()),
("prefetch_manager", django.db.models.manager.Manager()),
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("image1_x_url", models.URLField()),
("typename", models.TextField()),
],
),
migrations.CreateModel(
name="Drop",
name="UnlockRequirements",
fields=[
("id", models.TextField(primary_key=True, serialize=False)),
("created_at", models.DateTimeField(blank=True, null=True)),
("entitlement_limit", models.IntegerField(blank=True, null=True)),
("image_asset_url", models.URLField(blank=True, null=True)),
("name", models.TextField(blank=True, null=True)),
("added_at", models.DateTimeField(auto_now_add=True, null=True)),
("modified_at", models.DateTimeField(auto_now=True, null=True)),
("required_subs", models.IntegerField(blank=True, null=True)),
("end_at", models.DateTimeField(blank=True, null=True)),
("required_minutes_watched", models.IntegerField(blank=True, null=True)),
("start_at", models.DateTimeField(blank=True, null=True)),
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("subs_goal", models.IntegerField()),
("minute_watched_goal", models.IntegerField()),
("typename", models.TextField()),
],
),
migrations.CreateModel(
name="Reward",
fields=[
("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
("name", models.TextField()),
("earnable_until", models.DateTimeField()),
("redemption_instructions", models.TextField()),
("redemption_url", models.URLField()),
("typename", models.TextField()),
(
"drop_campaign",
auto_prefetch.ForeignKey(
"banner_image",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="drops",
to="twitch_app.dropcampaign",
related_name="banner_rewards",
to="twitch_app.image",
),
),
(
"thumbnail_image",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="thumbnail_rewards",
to="twitch_app.image",
),
),
],
options={
"verbose_name": "Drop",
"verbose_name_plural": "Drops",
"ordering": ("name",),
"abstract": False,
"base_manager_name": "prefetch_manager",
},
managers=[
("objects", django.db.models.manager.Manager()),
("prefetch_manager", django.db.models.manager.Manager()),
),
migrations.CreateModel(
name="RewardCampaign",
fields=[
("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
("name", models.TextField()),
("brand", models.TextField()),
("starts_at", models.DateTimeField()),
("ends_at", models.DateTimeField()),
("status", models.TextField()),
("summary", models.TextField()),
("instructions", models.TextField()),
("external_url", models.URLField()),
("reward_value_url_param", models.TextField()),
("about_url", models.URLField()),
("is_sitewide", models.BooleanField()),
("typename", models.TextField()),
("game", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="twitch_app.game")),
("image", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="twitch_app.image")),
("rewards", models.ManyToManyField(to="twitch_app.reward")),
],
),
migrations.AddField(
model_name="dropcampaign",
name="game",
field=auto_prefetch.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="drop_campaigns",
to="twitch_app.game",
),
),
migrations.AddField(
model_name="game",
name="organization",
field=auto_prefetch.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="games",
to="twitch_app.organization",
),
),
]