Rewrite index view
This commit is contained in:
@ -4,14 +4,15 @@ import auto_prefetch
|
||||
import django.db.models.deletion
|
||||
import django.db.models.manager
|
||||
from django.db import migrations
|
||||
from django.db.migrations.operations.base import Operation
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
dependencies: list[tuple[str, str]] = [
|
||||
("twitch_app", "0005_alter_dropbenefit_options_alter_dropcampaign_options_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
operations: list[Operation] = [
|
||||
migrations.AlterModelOptions(
|
||||
name="dropbenefit",
|
||||
options={
|
||||
|
@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.0.6 on 2024-07-02 17:11
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.db.migrations.operations.base import Operation
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies: list[tuple[str, str]] = [
|
||||
("twitch_app", "0006_alter_dropbenefit_options_alter_dropcampaign_options_and_more"),
|
||||
]
|
||||
|
||||
operations: list[Operation] = [
|
||||
migrations.AlterField(
|
||||
model_name="dropcampaign",
|
||||
name="time_based_drops",
|
||||
field=models.ManyToManyField(related_name="drop_campaigns", to="twitch_app.timebaseddrop"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="timebaseddrop",
|
||||
name="benefits",
|
||||
field=models.ManyToManyField(related_name="time_based_drops", to="twitch_app.dropbenefit"),
|
||||
),
|
||||
]
|
@ -0,0 +1,33 @@
|
||||
# Generated by Django 5.0.6 on 2024-07-03 21:19
|
||||
|
||||
import auto_prefetch
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations
|
||||
from django.db.migrations.operations.base import Operation
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies: list[tuple[str, str]] = [
|
||||
("twitch_app", "0007_alter_dropcampaign_time_based_drops_and_more"),
|
||||
]
|
||||
|
||||
operations: list[Operation] = [
|
||||
migrations.AlterField(
|
||||
model_name="dropbenefit",
|
||||
name="game",
|
||||
field=auto_prefetch.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="drop_benefits",
|
||||
to="twitch_app.game",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="dropbenefit",
|
||||
name="owner_organization",
|
||||
field=auto_prefetch.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="drop_benefits",
|
||||
to="twitch_app.organization",
|
||||
),
|
||||
),
|
||||
]
|
@ -10,6 +10,11 @@ from simple_history.models import HistoricalRecords
|
||||
|
||||
|
||||
class Organization(auto_prefetch.Model):
|
||||
"""The company that owns the game.
|
||||
|
||||
For example, 2K games.
|
||||
"""
|
||||
|
||||
id = models.TextField(primary_key=True)
|
||||
name = models.TextField(blank=True, null=True)
|
||||
added_at = models.DateTimeField(blank=True, null=True, auto_now_add=True)
|
||||
@ -25,6 +30,11 @@ class Organization(auto_prefetch.Model):
|
||||
|
||||
|
||||
class Game(auto_prefetch.Model):
|
||||
"""The game that the drop campaign is for.
|
||||
|
||||
For example, MultiVersus.
|
||||
"""
|
||||
|
||||
id = models.TextField(primary_key=True)
|
||||
slug = models.TextField(blank=True, null=True)
|
||||
twitch_url = models.GeneratedField( # type: ignore # noqa: PGH003
|
||||
@ -56,6 +66,8 @@ class Game(auto_prefetch.Model):
|
||||
|
||||
|
||||
class DropBenefit(auto_prefetch.Model):
|
||||
"""Information about the drop."""
|
||||
|
||||
id = models.TextField(primary_key=True)
|
||||
created_at = models.DateTimeField(blank=True, null=True)
|
||||
entitlement_limit = models.IntegerField(blank=True, null=True)
|
||||
@ -65,8 +77,9 @@ class DropBenefit(auto_prefetch.Model):
|
||||
owner_organization = auto_prefetch.ForeignKey(
|
||||
Organization,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="drop_benefits",
|
||||
)
|
||||
game = auto_prefetch.ForeignKey(Game, on_delete=models.CASCADE)
|
||||
game = auto_prefetch.ForeignKey(Game, on_delete=models.CASCADE, related_name="drop_benefits")
|
||||
added_at = models.DateTimeField(blank=True, null=True, auto_now_add=True)
|
||||
modified_at = models.DateTimeField(blank=True, null=True, auto_now=True)
|
||||
history = HistoricalRecords()
|
||||
@ -81,13 +94,15 @@ class DropBenefit(auto_prefetch.Model):
|
||||
|
||||
|
||||
class TimeBasedDrop(auto_prefetch.Model):
|
||||
"""The actual drop that is being given out."""
|
||||
|
||||
id = models.TextField(primary_key=True)
|
||||
required_subs = models.IntegerField(blank=True, null=True)
|
||||
end_at = models.DateTimeField(blank=True, null=True)
|
||||
name = models.TextField(blank=True, null=True)
|
||||
required_minutes_watched = models.IntegerField(blank=True, null=True)
|
||||
start_at = models.DateTimeField(blank=True, null=True)
|
||||
benefits = models.ManyToManyField(DropBenefit)
|
||||
benefits = models.ManyToManyField(DropBenefit, related_name="time_based_drops")
|
||||
added_at = models.DateTimeField(blank=True, null=True, auto_now_add=True)
|
||||
modified_at = models.DateTimeField(blank=True, null=True, auto_now=True)
|
||||
history = HistoricalRecords()
|
||||
@ -106,6 +121,11 @@ class TimeBasedDrop(auto_prefetch.Model):
|
||||
|
||||
|
||||
class DropCampaign(auto_prefetch.Model):
|
||||
"""Drops are grouped into campaigns.
|
||||
|
||||
For example, MultiVersus S1 Drops
|
||||
"""
|
||||
|
||||
id = models.TextField(primary_key=True)
|
||||
account_link_url = models.URLField(blank=True, null=True)
|
||||
description = models.TextField(blank=True, null=True)
|
||||
@ -125,7 +145,7 @@ class DropCampaign(auto_prefetch.Model):
|
||||
on_delete=models.CASCADE,
|
||||
related_name="drop_campaigns",
|
||||
)
|
||||
time_based_drops = models.ManyToManyField(TimeBasedDrop)
|
||||
time_based_drops = models.ManyToManyField(TimeBasedDrop, related_name="drop_campaigns")
|
||||
added_at = models.DateTimeField(blank=True, null=True, auto_now_add=True)
|
||||
modified_at = models.DateTimeField(blank=True, null=True, auto_now=True)
|
||||
history = HistoricalRecords()
|
||||
|
Reference in New Issue
Block a user